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:
id
is a string id for the pane. The built-in panes areeditor-tab-properties
editor-tab-description
(although as an internal implementation detail, they are likely the change).definition
is a function the returns the edit pane definition for a given nodefilter
is a function that returns true/false whether this edit pane should be displayed for a given nodeThe Edit pane definition returned by the
definition
function 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-something
create
: 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 aneditState
object that must be updated to ensure edit history is maintained.All of the functions are called with a common
this
context. So if thecreate
function generates an UI element thatresize
needs to refer to,create
could dothis.myInput = ....
for theresize
function to be able to access it asthis.myInput
.Here's a skeleton example of an edit pane:
apply
editStateThe
apply
callback is passed aneditState
object. This contains two properties:changes
: objectchanged
: boolean.If the edit pane makes any modifications to the node, it must:
changes
object.changed
to trueIt must not make any other modifications to the editState.
Beta Was this translation helpful? Give feedback.
All reactions