Skip to content

Commit

Permalink
improve documentation for gosub
Browse files Browse the repository at this point in the history
  • Loading branch information
gsambrotta committed Nov 8, 2024
1 parent ed40663 commit 7e2e6d7
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/workflow/blocks/context_block.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ Security and access control
There is currently no access control or protection in state. Any path in the global state is accessible (read and write) to any flow.
In the future some form of restriction may be implemented.

Subroutines
+++++++++++
Subroutines (Gosub)
+++++++++++++++++++

Subroutines are Flows that are configured separately and used within a parent Flow.
All data saved in a subroutine is stored in the context or state of the parent Flow.
Expand Down
80 changes: 78 additions & 2 deletions docs/workflow/blocks/gosub.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,85 @@ A Flow embedded within a Flow.
This allows composition of larger building blocks to create Flows that
are easier to manage, and DRY (don't repeat yourself).

Default config
--------------

.. code-block:: json
{
"type": "gosub",
"adapterName": "",
"workflowId": ""
}
Supported properties
--------------------

- **adapterName**: the name of the Flow's adapter that will be embedded.
- **workflowId**: the id of the Flow's adapter that will be embedded.

Typical use-cases for this are creating custom form widgets that can
be referenced from a form's ``uiSchema``. Or, creating dashboards
that are made up of multiple other Flows combined with a ``multi``
be referenced from a form's ``uiSchema``.
The form property's name must match the data property name.
In this way the data will be passed down to the embedded Flow.




.. code-block:: json
// Parent Flow data
{
"asset_name": "Gioconda",
"location": "https://someimages.com",
"asset_manager_id": "1"
}
{
"type": "form",
"jsonSchema": {
"type": "object",
"properties": {
"asset_title": {
"title": "Asset",
"type": "string"
},
"location": {
"title": "Location",
"type": "string"
},
"asset_manager_id": {
"type": "string",
"title": "Asset Manager"
}
}
},
"uiSchema": {
"location": {
"ui:widget": "remote-image"
},
"asset_manager_id": {
"ui:widget": "blocks",
"blocksConfig": {
"blocks": [
{
"type": "gosub",
"adapterName": "culturebanked",
"workflowId": "artist2-select-asset-manager"
}
]
}
}
}
}
In the example above, there are two Flows: the primary Flow, where the above configuration is written, and a secondary Flow with the Adapter "culturebanked" and Workflow ID "artist2-select-asset-manager".
The "artist2-select-asset-manager" Flow is rendered as part of the parent Flow and is initiated with the data { "asset_manager_id": "1" }.
If the property is modified in the uiSchema, the property name must be the same as the original data both in
the jsonSchema and in the uiSchema.

Or, creating dashboards that are made up of multiple other Flows combined with a ``multi``
multiplex Flow block.

All data saved in a gosub is stored in the context or state of the parent Flow.
Expand Down
2 changes: 1 addition & 1 deletion src/app/dialogs/add-block-dialog/block-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ export const BLOCK_TYPES = [
},
{
type: 'gosub',
label: 'Subroutine',
label: 'Subroutine (Gosub)',
description: 'Embed another workflow or partial workflow',
icon: 'autorenew',
hasEditor: true,
Expand Down

0 comments on commit 7e2e6d7

Please sign in to comment.