Copy Workflow step names

Feature description:

When workflow steps are copied and pasted, preserve the step name.

:slightly_smiling_face: This will make it less work to use content copied from a workflow.

Current behavior:

When using the new “Workflows” core plugin, I found that I would regularly need to implement things similar to what I did in another workflow, or elsewhere in the same workflow. Fortunately, the plugin has support for copy and pasting steps.

Unfortunately, the step names are reset to default when pasted. I prefer to use custom step names in order to clearly communicate the function of the step. So this means I have to go through and rename each of the added steps after performing a paste operation. This also risks introducing errors into the workflow, since the step name is the identifier used to reference its output in subsequent steps (e.g., $("Foo step").first().json.bar).

Reproducible steps:

  1. Log into a Discourse forum account with admin permissions, on a site that has the new “Workflows” plugin enabled.
  2. Open the “Workflows” page (/admin/plugins/discourse-workflows/workflows).
  3. Click the “+ New workflow” button.
    A new workflow will be created.
  4. Click the + button.
    The “Add step” panel will open.
  5. Select Flow > If from the panel.
    I chose this specific step type arbitrarily. The name reset behavior occurs for any step type.
  6. Double click on the newly added “If” step.
    The configuration dialog for the step will open.
  7. Click the pencil icon (“Edit”) to the right of the step name, near the top left hand corner of the dialog.
    The step name will become an editable text field.
  8. Type Foo step into the step name field.
  9. Click the icon to the right of the field.
    The name change will be committed.
  10. Click the X icon at the top right hand corner of the dialog.
    The dialog will close.
  11. Right click on the “Foo step” step.
    A context menu will open.
  12. Select “Copy” from the menu.
  13. Select the “Workflows” tab near the top of the page.
    The “Workflows” page will open.
  14. Click the “+ New workflow” button.
    A new workflow will be created.
  15. Right click on the workflow canvas.
    A context menu will open.
  16. Select “Paste” from the menu.

:slightly_frowning_face: The pasted step has the default name “If”.

Discourse version:

1a47bbf0af779342d6762eadb6da07f9ecf68717

Additional context:

I understand that preservation of the step name verbatim will result in a name collision in the case where the step is being pasted into the source workflow. The Workflows plugin already ensures unique names when adding steps normally by adding a numeric suffix to the step name that would otherwise collide. That approach could be adopted for the paste feature. Alternatively, the plugin could simply display a dialog to inform the user of the collision, as is already done when the user manually sets a non-unique name in a step:

An error occurred: Node names must be unique within a workflow. Duplicates: Foo step

3 Likes