Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Lifecycle editor UI: state badge, Go live, Switch to draft#4873

Merged
elias-ba merged 5 commits into
sandbox-devx from
4857-lifecycle-editor-ui
Jun 17, 2026
Merged

Lifecycle editor UI: state badge, Go live, Switch to draft #4873
elias-ba merged 5 commits into
sandbox-devx from
4857-lifecycle-editor-ui

Conversation

@elias-ba

@elias-ba elias-ba commented Jun 16, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Description

Final slice for #4857: surfaces the workflow lifecycle in the collaborative editor and wires the transitions end to end.

  • A draft / live badge in the editor header.
  • A state-driven primary action: Go live when the workflow is a draft, Switch to draft (behind a confirmation dialog: "This will stop the workflow from processing data.") when it is live.
  • A Session.set_workflow_state/3 transition that flips the lifecycle state and trigger enablement and persists them with the document in a single save, reconciled back into the Y.Doc. It reuses the existing save pipeline (do_save_workflow), so going live and switching to draft are atomic and consistent with the collaborative session. Driven by new go_live / switch_to_draft channel events.
  • The workflow's state is now serialized to the editor (Jason.Encoder derive + BaseWorkflow schema) and read via a new useSessionWorkflow hook. After a transition the session context is re-fetched so the badge and the read-only lock update immediately.

Closes #4857

Validation steps

  1. Create a workflow: it shows a Draft badge and is editable.
  2. Click Go live: the badge becomes Live, triggers are enabled, and the editor becomes read-only on the main project.
  3. Click Switch to draft, confirm the dialog: the workflow goes offline (triggers disabled), the badge returns to Draft, and it is editable again.

Additional notes for the reviewer

The state lives on the DB row, not the Y.Doc (it gates editing globally, not per-edit). Transitions go through the Session GenServer (like save_workflow) so the trigger and lock-version changes reconcile into the live document. Verified: backend session/channel/workflows tests pass; frontend type-checks (changed files), bundle builds, store/editor suites pass. Recommend a manual run-through of the three validation steps before merge.

AI Usage

Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):

  • I have used Claude Code
  • I have used another model
  • I have not used AI

You can read more details in our
Responsible AI Policy

Pre-submission checklist

  • I have performed an AI review of my code (we recommend using /review
    with Claude Code)
  • I have implemented and tested all related authorization policies.
    (transitions reuse the role-based :edit_workflow authorization)
  • I have updated the changelog. (deferred to the final epic PR)
  • I have ticked a box in "AI usage" in this PR

Surfaces the workflow lifecycle in the collaborative editor:
- draft/live badge and a state-driven primary action (Go live when a
 draft, Switch to draft with a confirmation when live).
- A Session transition (set_workflow_state) that flips state + trigger
 enablement and persists with the document in one save, reconciled into
 the Y.Doc; driven by go_live / switch_to_draft channel events.
- The workflow's state is serialized to the editor and read via a new
 useSessionWorkflow hook; after a transition the session context is
 re-fetched so the badge and read-only lock update.
Completes #4857 

Copy link
Copy Markdown

Security Review ✅

  • S0 (project scoping): New set_workflow_state/3 reuses do_save_workflow, which resolves the workflow against state.workflow.project_id (set at session join from the project-scoped load_workflow/WorkflowResolver), never from client params.
  • S1 (authorization): Both new handle_in("go_live", ...) and handle_in("switch_to_draft", ...) dispatch through transition_lifecycle_state/2 at lib/lightning_web/channels/workflow_channel.ex:1110, which gates on authorize_edit_workflow/1 (:edit_workflow policy, restricted to :owner/:admin/:editor).
  • S2 (audit trail): Lifecycle transitions flow through the shared save_workflow multi, whose maybe_audit_workflow_state_changes/2 records enabled/disabled audit events when update_triggers_enabled_state/2 flips trigger state — matching the existing Workflows.go_live/2 and switch_to_draft/2 audit behavior.

elias-ba added 2 commits June 16, 2026 23:24
Run (test) is only meaningful in editable states (draft, sandbox). It is
now hidden when the editor is read-only, matching the concept where live
and archived states have no Run action.
Part of #4857 
The Header now reads the session-context workflow via useSessionWorkflow;
the keyboard test mocks useSessionContext, so it needs the new export or
the Header throws on render.
Part of #4857 

codecov Bot commented Jun 17, 2026
edited
Loading

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (sandbox-devx@60709be). Learn more about missing BASE report.

Additional details and impacted files
@@ Coverage Diff @@
## sandbox-devx #4873 +/- ##
==============================================
 Coverage ? 90.6% 
==============================================
 Files ? 445 
 Lines ? 22736 
 Branches ? 0 
==============================================
 Hits ? 20593 
 Misses ? 2143 
 Partials ? 0 

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

elias-ba added 2 commits June 17, 2026 01:44
Channel tests drive go_live and switch_to_draft (happy path + unauthorized
rejection) through a joined socket, covering the handlers and
transition_lifecycle_state. A session test covers the no-shared-doc error
branch of the shared save pipeline.
Part of #4857 
Adds a test that triggers an interpolated changeset error (concurrency < 1)
to cover the error-formatting path, and wraps the two genuinely-defensive
save branches (:wrong_project, documented unreachable; :deserialization_failed,
a catch-all rescue) in coveralls-ignore, matching the repo convention.
Part of #4857 
@elias-ba elias-ba merged commit ec5952f into sandbox-devx Jun 17, 2026
7 checks passed
@elias-ba elias-ba deleted the 4857-lifecycle-editor-ui branch June 17, 2026 14:10
@github-project-automation github-project-automation Bot moved this from New Issues to Done in Core Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

Status: Done

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /