mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Updated Design: dynamic palette (markdown)
parent
c6df7debc1
commit
78894ac364
@ -1,70 +1,71 @@
|
|||||||
Design notes for #322
|
Design notes for #322
|
||||||
|
|
||||||
Currently, the palette of nodes is loaded when the runtime starts and does not change.
|
Currently, the palette of nodes is loaded when the runtime starts and does not change.
|
||||||
|
|
||||||
The runtime needs to allow nodes to be added/removed dynamically.
|
The runtime needs to allow nodes to be added/removed dynamically.
|
||||||
|
|
||||||
Some points that need to be considered:
|
Some points that need to be considered:
|
||||||
|
|
||||||
- nodes can be added by dropping files into the node path, or by npm. Both of these mechanisms should be supported by this feature
|
- nodes can be added by dropping files into the node path, or by npm. Both of these mechanisms should be supported by this feature
|
||||||
- adding by file will expect the file to have already been copied into node path
|
- adding by file will expect the file to have already been copied into node path
|
||||||
- adding by npm will trigger an npm install of the module
|
- adding by npm will trigger an npm install of the module
|
||||||
- future support for importing a zip or files themselves?
|
- future support for importing a zip or files themselves?
|
||||||
- removing a node cannot 'unload' the module - care must be taken if the node creates any 'static' resources
|
- removing a node cannot 'unload' the module - care must be taken if the node creates any 'static' resources
|
||||||
- removing a node in the editor must allow it to remove any artefacts added to the page (eg, debug node's tab)
|
- removing a node in the editor must allow it to remove any artefacts added to the page (eg, debug node's tab)
|
||||||
- a node file or module can contain multiple nodes. Making a request to remove a single node type may trigger the removal of multiple node types.
|
- a node file or module can contain multiple nodes. Making a request to remove a single node type may trigger the removal of multiple node types.
|
||||||
- what to do if the node is being used in the current flow? Safest option is to reject the removal.
|
- what to do if the node is being used in the current flow? Safest option is to reject the removal.
|
||||||
- removing a node, without also removing the files, will mean it returns to the palette on the next restart. That would be unexpected.
|
- removing a node, without also removing the files, will mean it returns to the palette on the next restart. That would be unexpected.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
See [[Definitions]] for a description of node/node set/node module/node pack.
|
See [[Definitions]] for a description of node/node set/node module/node pack.
|
||||||
|
|
||||||
### Add/Remove vs Enable/Disable
|
### Add/Remove vs Enable/Disable
|
||||||
The Add/Remove api is for getting new nodes installed into the runtime as well as removing them. It operates at either the js/html level, or the node module level.
|
The Add/Remove api is for getting new nodes installed into the runtime as well as removing them. It operates at either the js/html level, or the node module level.
|
||||||
|
|
||||||
The Enable/Disable api is used with **node sets**. This is how a user can install a **node module** using the Add/Remove API, then elect to disable one or more of the **node sets** it contains so they don't appear in the palette.
|
The Enable/Disable api is used with **node sets**. This is how a user can install a **node module** using the Add/Remove API, then elect to disable one or more of the **node sets** it contains so they don't appear in the palette.
|
||||||
|
|
||||||
### Adding a node set/module
|
### Adding a node set/module
|
||||||
To add a new node to the palette:
|
To add a new node to the palette:
|
||||||
|
|
||||||
1. a request is POSTed to `{admin root}/nodes` to trigger the add. Its `Content-Type` _must_ be `application/json`.
|
1. a request is POSTed to `{admin root}/nodes` to trigger the add. Its `Content-Type` _must_ be `application/json`.
|
||||||
The post body is a JSON structure that identifies where the node information comes from, either a local file (`file`) or an npm module (`module`).
|
The post body is a JSON structure that identifies where the node information comes from, either a local file (`file`) or an npm module (`module`).
|
||||||
|
|
||||||
{
|
{
|
||||||
file: "path to local node .js file or package.json",
|
file: "path to local node .js file or package.json",
|
||||||
module: "npm module name"
|
module: "npm module name"
|
||||||
}
|
}
|
||||||
|
|
||||||
2. The response to this request is the corresponding node information object. This is a json object containing the node set id, a list of the specific types in the set and a boolean flag to show if it is enabled or not. If not enabled, it may also list an error message describing why it is not enabled - unless if has been disabled by the user.
|
2. The response to this request is the corresponding node information object. This is a json object containing the node set id, a list of the specific types in the set and a boolean flag to show if it is enabled or not. If not enabled, it may also list an error message describing why it is not enabled - unless if has been disabled by the user.
|
||||||
|
|
||||||
3. An event is fired over the comms link telling any connected editors that nodes have been added. This triggers a HTTP Get back to `{admin root}/nodes/{node-set-id}` to load the node definition/help/edit template.
|
3. An event is fired over the comms link telling any connected editors that nodes have been added. This triggers a HTTP Get back to `{admin root}/nodes/{node-set-id}` to load the node definition/help/edit template.
|
||||||
|
|
||||||
### Remove node set/module
|
### Remove node set/module
|
||||||
To remove a node from the palette:
|
To remove a node from the palette:
|
||||||
|
|
||||||
1. a DELETE http request is sent to `{admin root}/nodes/{node-set-id}` to trigger the removal.
|
1. a DELETE http request is sent to `{admin root}/nodes/{node-set-id}` to trigger the removal.
|
||||||
2. If the any of the corresponding nodes are in use, the request is rejected
|
2. If the any of the corresponding nodes are in use, the request is rejected
|
||||||
3. The runtime registry removes the corresponding nodes.
|
3. The runtime registry removes the corresponding nodes.
|
||||||
4. An event is fired over the comms link telling any connected editors that the nodes have been removed.
|
4. An event is fired over the comms link telling any connected editors that the nodes have been removed.
|
||||||
|
|
||||||
### Enable/Disable a node set
|
### Enable/Disable a node set
|
||||||
|
|
||||||
1. a PUT http request is sent to `{admin root}/nodes/{node-set-id}`. Its `Content-Type` _must_ be `application/json`.The PUT body is a JSON structure that identifies the desired state of the **node set's** `enabled` property.
|
1. a PUT http request is sent to `{admin root}/nodes/{node-set-id}`. Its `Content-Type` _must_ be `application/json`.The PUT body is a JSON structure that identifies the desired state of the **node set's** `enabled` property.
|
||||||
|
|
||||||
{
|
{
|
||||||
enabled: true | false
|
enabled: true | false
|
||||||
}
|
}
|
||||||
|
|
||||||
2. if the request succeeds, it returns the updated node information object.
|
2. if the request succeeds, it returns the updated node information object.
|
||||||
3. the request will fail if the request is to disable a node that is currently in use.
|
3. the request will fail if the request is to disable a node that is currently in use.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## ToDo
|
## ToDo
|
||||||
|
|
||||||
- [ ] Create UI for enabling/disabling nodes
|
- [ ] Create UI for enabling/disabling nodes
|
||||||
- [x] Editor registry of types that is populated with the node list
|
- [ ] Create UI for uninstalling nodes
|
||||||
- [x] Update registry in response to `node/enabled`/`node/disabled` events
|
- [x] Editor registry of types that is populated with the node list
|
||||||
- [x] Remove node from palette on `node/disabled` event
|
- [x] Update registry in response to `node/enabled`/`node/disabled` events
|
||||||
- [x] Add node back to palette on `node/enabled` event - definition should already be loaded
|
- [x] Remove node from palette on `node/disabled` event
|
||||||
|
- [x] Add node back to palette on `node/enabled` event - definition should already be loaded
|
Loading…
Reference in New Issue
Block a user