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

Delete workflow step #7373

Merged
merged 4 commits into from
Oct 1, 2024
Merged

Delete workflow step #7373

merged 4 commits into from
Oct 1, 2024

Conversation

Devessier
Copy link
Contributor

@Devessier Devessier commented Oct 1, 2024

  • Allows the deletion of triggers and steps in workflows. If the workflow can not be edited right now, we create a new draft version.
  • The workflow right drawer can now render nothing. It's necessary to behave that way because a deleted step will still be displayed for a short amount of time in the drawer. The drawer will be filled with blank content when it disappears.
CleanShot.2024-10-01.at.16.28.38.mp4

Closes #7057

Comment on lines +36 to +42
const workflowWithCurrentVersion = useWorkflowWithCurrentVersion(workflowId);
assertWorkflowWithCurrentVersionIsDefined(workflowWithCurrentVersion);

const { deleteOneStep } = useDeleteOneStep({
workflow: workflowWithCurrentVersion,
stepId: id,
});
Copy link
Contributor Author

@Devessier Devessier Oct 1, 2024

Choose a reason for hiding this comment

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

I don't feel it is good to subscribe to workflow changes in every Reactflow node. I only need to know what are the current trigger and steps in the deleteOneStep function, so I think it might be better to get the data from the cache at this moment. The data are expected to be defined here.

@Devessier Devessier marked this pull request as ready for review October 1, 2024 15:00
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This pull request implements the functionality to delete workflow steps, enhancing the workflow management capabilities of the application.

  • Added useDeleteOneStep hook in useDeleteOneStep.tsx for handling step deletion logic, including creating new workflow versions when necessary
  • Implemented delete button in WorkflowDiagramStepNode.tsx, allowing users to remove steps directly from the workflow diagram
  • Created removeStep utility function in removeStep.ts for safely removing steps from the workflow structure
  • Added unit tests in removeStep.test.ts to ensure proper functionality of the step removal process
  • Updated RightDrawerWorkflowEditStepContent.tsx to handle potential undefined steps after deletion, improving robustness

8 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings

stepId,
}: {
steps: Array<WorkflowStep>;
stepId: string | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: stepId is allowed to be undefined. Ensure this is handled correctly in findStepPositionOrThrow

stepId,
});

parentStepPosition.steps.splice(parentStepPosition.index, 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

style: This mutation directly affects the cloned steps. Consider returning a new array instead for better immutability

@Devessier Devessier merged commit 3536109 into main Oct 1, 2024
7 of 12 checks passed
@Devessier Devessier deleted the delete-workflow-step branch October 1, 2024 16:14
Copy link

github-actions bot commented Oct 1, 2024

Thanks @Devessier for your contribution!
This marks your 11th PR on the repo. You're top 3% of all our contributors 🎉
See contributor page - Share on LinkedIn - Share on Twitter

Contributions

harshit078 pushed a commit to harshit078/twenty that referenced this pull request Oct 14, 2024
- Allows the deletion of triggers and steps in workflows. If the
workflow can not be edited right now, we create a new draft version.
- The workflow right drawer can now render nothing. It's necessary to
behave that way because a deleted step will still be displayed for a
short amount of time in the drawer. The drawer will be filled with blank
content when it disappears.


https://github.com/user-attachments/assets/abd5184e-d3db-4fe7-8870-ccc78ff23d41

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

Successfully merging this pull request may close these issues.

Allow deleting workflow nodes
2 participants