-
-
Notifications
You must be signed in to change notification settings - Fork 801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UI Plugin API #4256
Merged
Merged
UI Plugin API #4256
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
halkeye
pushed a commit
to halkeye/stash
that referenced
this pull request
Sep 1, 2024
* Add page registration * Add example plugin * First version of proper react plugins * Make reference react plugin * Add patching functions * Add tools link poc * NavItem poc * Add loading hook for lazily loaded components * Add documentation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduces a UI plugin API. The main interface can be viewed at
pluginApi.tsx
.Adds
PluginApi
to thewindow
object. ThePluginApi
object:PluginApi.register.route
. (egPluginApi.register.route("/plugin/test-react", TestPage);
)PluginApi.register.component
.PluginApi.patch.before
accepts a function that will be called before the target component function is run. The provided function is given the input arguments and is expected to return an array of arguments. This allows the arguments to be modified before the target component function is run.PluginApi.patch.instead
accepts a function that will be called instead of the target component function. The provided function is given the input arguments, plus the original component function. It is expected to return the rendered component.instead
may only be called once for a given component.PluginApi.patch.after
accepts a function that will be called after the target component function. The provided function is given the original input arguments, plus the result of the original component function. It is expected to return the rendered component.Examples of using
before
andinstead
are intestReact.tsx
. The example shows proof of concept for changing the scene card display, adding a test page route, and adding links for said page to the Tools page and to the main nav bar.The supported patchable components is not intended to be exhaustive, and more components can be made supportive of patching according to plugin developer needs.
Example of adding an icon link to the navbar:
Test page render
Added link in tools page
Example changing of scene card display: