Skip to content

Workflow Editor Header: Save button with validation and permissions #3635

@theroinaochieng

Description

@theroinaochieng

User story

As a user with edit permissions, I can save workflow changes when validation passes and I have edit priority in collaborative editing.

Details

Display primary save button with complex disable logic and tooltips. Currently implemented as save_workflow_button/1 component at edit.ex:1215-1309, rendered at lines 217-226. This issue covers the main save button only (not GitHub sync dropdown).

Current behavior:

  • Enabled only when ALL conditions met:
    • Changeset is valid (changeset.valid?: true)
    • Workflow not deleted (data.deleted_at: nil)
    • User can edit (can_edit_workflow: true)
    • Viewing latest version (snapshot_version_tag: "latest")
    • Has presence priority (has_presence_priority: true)
    • AI not processing (sending_ai_message: false)
  • Disabled with specific tooltips for each failure condition:
    • Deleted: "Workflow has been deleted"
    • No permission: "You do not have permission to edit this workflow"
    • AI processing: "AI is currently processing your request"
    • Invalid: "You have unresolved errors in your workflow"
    • Snapshot: "You cannot edit an old snapshot of a workflow"
  • Ctrl+S keyboard shortcut via InspectorSaveViaCtrlS hook
  • Handles disconnection state automatically
  • Rounded corners adjust if GitHub sync available

Implementation notes

  • Disable logic and tooltips determined at lines 1216-1245 via pattern matching on assigns
  • Main button structure at lines 1251-1266:
    • Event: phx-click="save" (via JS.push)
    • Hook: "InspectorSaveViaCtrlS" for keyboard shortcut
    • ID: "top-bar-save-workflow-btn"
  • Event handler handle_event("save", params, socket) at line 1910:
    • Calls save_workflow/2
    • Links workflow to AI session if applicable
    • For new workflows: Changes live_action to :edit, updates base_url, shows AI chat if method was "ai"
    • Shows success flash message
    • Redirects to standard params URL via push_patch
  • Component positioned at bottom dropdown position
  • Depends on Workflow Editor Header: Core layout and breadcrumb container #3624, Workflow Editor Header: Changes indicator wrapper #3629

Release notes

N/A - Internal refactor maintaining existing functionality

User acceptance criteria

  • Save button enabled only when all conditions met
  • Appropriate tooltip shows for each disable reason
  • Ctrl+S keyboard shortcut triggers save
  • Successful save shows flash message
  • New workflow transitions from :new to :edit action after save
  • Button styling matches design system
  • Button handles disconnection state

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions