Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflows with XState #1019

Open
wants to merge 64 commits into
base: feature/svelte
Choose a base branch
from
Open

Conversation

FyreByrd
Copy link

Uses the XState library to create FSM instances that model the desired workflow behavior.

Features:

  • Persistence: Each instance has an associated DB record (in WorkflowInstances) that stores enough information to restore to the current state.
  • User Tasks: Each instance updates the UserTasks table with the appropriate information.
  • Product Transitions: Each instance updates the ProductTransitions table with the appropriate information.
  • Tasks: The appropriate actions are provided based on the user in the /tasks/[product_id] and are handled by the FSM.
  • Admin: A barebones table of instances is provided in /admin/workflows.
    • Clicking on an entry will take a user to a visualization in /admin/workflows/[product_id]
    • While in the visualization, a user can select a state node and then press a button in a menu to jump the machine state to the selected state

Future Priorities:

  • Hook actions into backend
  • Authentication
  • Republish and Rebuild workflows
  • Workflow instance filtering/sorting in /admin/workflows
  • Improve visualization (and visualization efficiency)

FyreByrd and others added 30 commits September 18, 2024 18:14
Send task name and actions to corresponding page.svelte

Handle form submission and redirect to /tasks
Based on workflow state:
- Select form title
- Select form instructions
- Select specific fields
- Conditionally return reviewers
- Conditionally return productArtifacts and filter by artifact type
- Show some product information
- Jump state is now a button in the menu rather than a contextmenu event
there are no records in db currently, so can't test this yet.
The frontend is not hooked into this yet.
Does not work yet. Resolving import issues.
@FyreByrd FyreByrd marked this pull request as ready for review September 24, 2024 21:05
Copy link

@7dev7urandom 7dev7urandom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good; well done.

Here's a first-look review. I haven't reviewed the default-workflow.ts stuff at all, and I haven't tested anything, but here's some comments I have looking through it rather quickly. Some questions are probably somewhat ignorant because I'm not entirely clear what your goal is, but I think they'll be helpful.

One larger thing: you're handling the state machines with a lot of functional programming. You have a lot of functions that take WorkflowMachine or WorkflowContext as (often the first) argument, which makes me wonder if it could be done in a more object-oriented way, making things more intuitive to write.

@FyreByrd FyreByrd marked this pull request as draft September 25, 2024 20:44
@FyreByrd
Copy link
Author

I have created a wrapper class for DefaultWorkflow and have updated all the rest of the code in accordance with that change.
I have also fixed a few small things that I noticed while working on that change (they are related to workflow, so still valid for the PR).

@FyreByrd FyreByrd marked this pull request as ready for review September 27, 2024 17:47
Copy link

@7dev7urandom 7dev7urandom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, it does look a lot better and easier to use. Let me know what you think of my feedback.

- constructor is now private
- create and restore are static functions that return a Workflow instance
- getSnapshot is also static now
- updated parameters of the modified functions
Copy link

@7dev7urandom 7dev7urandom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, let's try it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants