-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Design: dynamic palette
Design notes for #322
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.
As of 0.9, we only support adding/removing nodes by npm module name. We do not support installing by filename or by uploading a zip. The npm module name must also be a simple name - we do not support the full range of module names that npm does (name@version, http://example.com/file.tgz foo/bar).
See Definitions for a description of node/node set/node module/node pack.
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.
To add a new node to the palette:
-
a request is POSTed to
{admin root}/nodes
to trigger the add. ItsContent-Type
must beapplication/json
. The post body is a JSON structure that identifies where the node information comes from. As of 0.9, onlymodule
is supported.{ module: "npm module name" }
-
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 it has been disabled by the user.
-
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.
To remove a node from the palette:
- a DELETE http request is sent to
{admin root}/nodes/{module-name}
to trigger the removal. - If the any of the corresponding nodes are in use, the request is rejected
- The runtime registry removes the corresponding nodes and npm module
- An event is fired over the comms link telling any connected editors that the nodes have been removed.
-
a PUT http request is sent to
{admin root}/nodes/{node-set-id}
. ItsContent-Type
must beapplication/json
.The PUT body is a JSON structure that identifies the desired state of the node set'senabled
property.{ enabled: true | false }
-
if the request succeeds, it returns the updated node information object.
-
the request will fail if the request is to disable a node that is currently in use.
- Create UI for enabling/disabling nodes
- Create UI for uninstalling nodes