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

Add go_live/2 and switch_to_draft/2 workflow transitions#4869

Merged
elias-ba merged 1 commit into
sandbox-devx from
4857-lifecycle-transitions
Jun 16, 2026
Merged

Add go_live/2 and switch_to_draft/2 workflow transitions #4869
elias-ba merged 1 commit into
sandbox-devx from
4857-lifecycle-transitions

Conversation

@elias-ba

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

Copy link
Copy Markdown
Contributor

Description

Adds two lifecycle transitions to Lightning.Workflows:

  • go_live/2: sets a workflow's state to :live and enables its triggers.
  • switch_to_draft/2: sets it back to :draft and disables its triggers.

Both go through the existing save_workflow/3 path, so each transition captures a snapshot and records a version in one transaction. No UI wiring and no read-only lock yet (those are the next slices), so nothing user-facing changes from this PR alone.

Part of #4857. Targets the sandbox-devx integration branch, not main.

Validation steps

  1. For a draft workflow with disabled triggers, call Workflows.go_live/2 and confirm the workflow is :live and all its triggers are enabled.
  2. For a live workflow, call Workflows.switch_to_draft/2 and confirm it is :draft and all its triggers are disabled.

Additional notes for the reviewer

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.
    (N/A: no authorization changes in this slice)
  • I have updated the changelog. (deferred to the final epic PR)
  • I have ticked a box in "AI usage" in this PR

go_live sets a workflow to :live and enables its triggers; switch_to_draft
sets it to :draft and disables them. Both go through the existing
save_workflow path (snapshot + version recording). No UI wiring yet.
Part of #4857 

Copy link
Copy Markdown

Security Review ✅

  • S0 (project scoping): N/A — go_live/2 and switch_to_draft/2 operate on a %Workflow{} passed by the caller; they introduce no new query or web-layer entrypoint that accepts a project_id.
  • S1 (authorization): N/A — no new LiveView events or controller actions were added; the new functions are context-layer helpers that callers must continue to gate with the existing Lightning.Policies checks.
  • S2 (audit trail): PASS — both helpers route through save_workflow/3 (workflows.ex:1038, 1052), whose Ecto.Multi includes maybe_audit_workflow_state_changes (workflows.ex:228, 546), so the trigger enable/disable flip is recorded as a workflow_state_changed audit entry in the same transaction.

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@ Coverage Diff @@
## sandbox-devx #4869 +/- ##
==============================================
 Coverage ? 90.5% 
==============================================
 Files ? 445 
 Lines ? 22723 
 Branches ? 0 
==============================================
 Hits ? 20553 
 Misses ? 2170 
 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 elias-ba merged commit 4f5f8b4 into sandbox-devx Jun 16, 2026
8 checks passed
@elias-ba elias-ba deleted the 4857-lifecycle-transitions branch June 16, 2026 15:25
@github-project-automation github-project-automation Bot moved this from New Issues to Done in Core Jun 16, 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 によって変換されたページ (->オリジナル) /