OpenFn / lightning

OpenFn/Lightning ⚡️ is the newest version of the OpenFn DPG and provides a web UI to visually manage complex workflow automation projects.
https://openfn.github.io/lightning/
GNU Lesser General Public License v3.0
115 stars 31 forks source link

Workflow Snapshots UI #2176

Closed elias-ba closed 2 days ago

elias-ba commented 3 weeks ago

Description

This PR introduces support for Workflow Snapshots in the UI, enhancing some sort of version control and historical accuracy within the workflow canvas. Two main areas are updated: the Workflow Canvas and the History Page.

In the Workflow Canvas

A kind of versioning system is implemented, tracked through the workflow lock_version property. The version is passed via the URL parameter v to load specific snapshots.

Snapshots are rendered in the canvas according to the version specified in the URL. If a snapshot is not the latest version, the UI switches to read-only mode. A toggle allows switching to the latest version for editing. Only the latest version can be edited; previous versions are view-only.

In the History Page

Runs now display using snapshots. If a run was executed with a non-latest version, rerunning it will use the latest workflow version. A tooltip on the rerun button informs users about this behavior.

When inspecting a run, it loads in the Workflow Canvas with its specific version. Users can toggle to the latest version using the same switch as in the Workflow Canvas.

Validation Steps

  1. Create a New Workflow: Start by creating a new workflow in the app. Verify that the workflow is tagged as the latest version.
  2. Edit Your Workflow: Make various edits to your workflow such as adding nodes, edges, and editing the job. Confirm that the workflow remains tagged as the latest version.
  3. Run Your Workflow: Execute your workflow by running it. Ensure the run completes successfully.
  4. Make Additional Changes: Continue editing the workflow by making further modifications. The workflow should still be tagged as the latest version.
  5. Run Your Workflow Again: Execute the workflow once more. Confirm the second run completes successfully.
  6. Navigate to the History Page: Go to the history page to view your workflow runs. Ensure all runs are displayed correctly.
  7. Inspect the First Run: Open the first run and inspect it in detail. Verify it is tagged as non-latest with a shortened UUID of the snapshot ID.
  8. Read-Only Mode Verification: Check that the UI is in read-only mode for the inspected run.
  9. Toggle Button for Workflow Snapshot Version: Locate the workflow snapshot version switcher toggle button. Ensure the toggle button is present and functional.
  10. Switch to the Latest Version: Use the toggle button to switch to the latest version of the workflow. Observe the content changes and confirm the UI transitions to edit mode.
  11. Perform Additional Edits: Make further edits to the workflow. Execute the workflow again to ensure the changes are properly integrated.

Notes for the reviewer

Related issue

Fixes #1843 #1825 #2027

Review checklist

codecov[bot] commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 96.49805% with 9 lines in your changes missing coverage. Please review.

Project coverage is 88.98%. Comparing base (1af3a01) to head (e0d8200).

Files Patch % Lines
lib/lightning_web/live/workflow_live/edit.ex 95.90% 7 Missing :warning:
lib/lightning/workflows/workflow.ex 66.66% 1 Missing :warning:
lib/lightning_web/live/run_live/show.ex 92.85% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2176 +/- ## ========================================== + Coverage 88.93% 88.98% +0.05% ========================================== Files 278 278 Lines 9145 9315 +170 ========================================== + Hits 8133 8289 +156 - Misses 1012 1026 +14 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

elias-ba commented 1 week ago

Review change requests checklist

From @christad92

From @taylordowns2000