Custom Edit Panes #63
Closed
knolleary
started this conversation in
Design Proposals
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
With node-red/node-red#3130 the way edit dialogs are structured has changed. Each tab within the dialog (eg properties, description, appearance) is provided by a separate 'edit pane' component.
This allows for much cleaner code reuse between different edit dialog types.
It also allows for a new feature to be exposed - allowing a plugin to add a custom edit pane to any dialog.
The immediate use case we have for this is the Flow Testing plugin that wants to add a testing tab to the edit dialog for any node/flow.
The proposed API is the following:
idis a string id for the pane. The built-in panes areeditor-tab-propertieseditor-tab-description(although as an internal implementation detail, they are likely the change).definitionis a function the returns the edit pane definition for a given nodefilteris a function that returns true/false whether this edit pane should be displayed for a given nodeThe Edit pane definition returned by the
definitionfunction should be an object with the following properties:label: the title of the edit pane (should be i18n'd)name: the name of the edit pane (should be i18n'd)iconClass: the class to apply to the tab icon - should befa fa-somethingcreate: a function that is passed a DOM element in to which the edit pane should be createdresize: an optional function that is called when the dialog is resizedclose: an optional function called when the dialog is closed (regardless of whether it was cancelled or confirmed)show: an optional function called whenever this edit pane is shownapply: an optional function called when the dialog is confirmed and should do the work to apply any changes to the node object. It is also provided aneditStateobject that must be updated to ensure edit history is maintained.All of the functions are called with a common
thiscontext. So if thecreatefunction generates an UI element thatresizeneeds to refer to,createcould dothis.myInput = ....for theresizefunction to be able to access it asthis.myInput.Here's a skeleton example of an edit pane:
applyeditStateThe
applycallback is passed aneditStateobject. This contains two properties:changes: objectchanged: boolean.If the edit pane makes any modifications to the node, it must:
changesobject.changedto trueIt must not make any other modifications to the editState.
Beta Was this translation helpful? Give feedback.
All reactions