-
Notifications
You must be signed in to change notification settings - Fork 5.7k
If else node followup changes #16974
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
Changes from 10 commits
e6677c7
b880eb3
0ef56fa
ec18f65
85808f4
403724b
4d0150e
813185b
5fdeda7
b8cb712
0bbfdcd
3d42f38
ef982c5
4157ef9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -208,6 +208,7 @@ export const WorkflowDiagramCanvasBase = ({ | |
| const [connectionStartInfo, setConnectionStartInfo] = useState<{ | ||
| nodeId: string; | ||
| handleId: string; | ||
| startPosition: { x: number; y: number }; | ||
| } | null>(null); | ||
|
|
||
| const { nodes, edges } = useMemo(() => { | ||
|
|
@@ -501,13 +502,24 @@ export const WorkflowDiagramCanvasBase = ({ | |
| }, [clearEdgeHover]); | ||
|
|
||
| const handleConnectStart = ( | ||
| _: MouseEvent | TouchEvent, | ||
| event: MouseEvent | TouchEvent, | ||
| params: OnConnectStartParams, | ||
| ) => { | ||
| if (isDefined(params.nodeId) && isDefined(params.handleId)) { | ||
| const mouseEvent = event instanceof MouseEvent ? event : null; | ||
| if (!isDefined(mouseEvent) || !isDefined(containerRef.current)) { | ||
| return; | ||
| } | ||
|
|
||
| const bounds = containerRef.current.getBoundingClientRect(); | ||
|
|
||
| setConnectionStartInfo({ | ||
| nodeId: params.nodeId, | ||
| handleId: params.handleId, | ||
| startPosition: { | ||
| x: mouseEvent.clientX - bounds.left, | ||
| y: mouseEvent.clientY - bounds.top, | ||
| }, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this useful ? can't we simply deactivate the handle when the node is an if-else?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The startPosition is needed to differentiate between a simple click on the handle and an actual drag (when the user drags from the handle to create a new node). Without tracking the start position, we can’t measure the drag distance, and every handle click would end up creating a node. This behavior applies to all node types, not just if-else. |
||
| }); | ||
| } | ||
| }; | ||
|
|
@@ -542,6 +554,15 @@ export const WorkflowDiagramCanvasBase = ({ | |
| y: event.clientY - bounds.top, | ||
| }; | ||
|
|
||
| const MIN_DRAG_DISTANCE = 5; | ||
| const deltaX = screenPosition.x - startInfo.startPosition.x; | ||
| const deltaY = screenPosition.y - startInfo.startPosition.y; | ||
| const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY); | ||
|
|
||
| if (distance < MIN_DRAG_DISTANCE) { | ||
| return; | ||
| } | ||
|
|
||
| const flowPosition = workflowDiagramScreenToFlowPosition(screenPosition); | ||
|
|
||
| if (!isDefined(flowPosition)) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient'; | ||
| import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; | ||
| import { useFindOneRecordQuery } from '@/object-record/hooks/useFindOneRecordQuery'; | ||
| import { DELETE_WORKFLOW_VERSION_STEP } from '@/workflow/graphql/mutations/deleteWorkflowVersionStep'; | ||
| import { useUpdateWorkflowVersionCache } from '@/workflow/workflow-steps/hooks/useUpdateWorkflowVersionCache'; | ||
| import { useMutation } from '@apollo/client'; | ||
|
|
@@ -13,6 +15,11 @@ export const useDeleteWorkflowVersionStep = () => { | |
|
|
||
| const { updateWorkflowVersionCache } = useUpdateWorkflowVersionCache(); | ||
|
|
||
| const { findOneRecordQuery: findOneWorkflowVersionQuery } = | ||
| useFindOneRecordQuery({ | ||
| objectNameSingular: CoreObjectNameSingular.WorkflowVersion, | ||
| }); | ||
|
|
||
| const [mutate] = useMutation< | ||
| DeleteWorkflowVersionStepMutation, | ||
| DeleteWorkflowVersionStepMutationVariables | ||
|
|
@@ -23,7 +30,16 @@ export const useDeleteWorkflowVersionStep = () => { | |
| const deleteWorkflowVersionStep = async ( | ||
| input: DeleteWorkflowVersionStepInput, | ||
| ) => { | ||
| const result = await mutate({ variables: { input } }); | ||
| const result = await mutate({ | ||
| variables: { input }, | ||
| awaitRefetchQueries: true, | ||
| refetchQueries: [ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we stop removing the empty node, we can remove that refetch logic. Updating cache will be enough
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @FelixMalfait suggested that we should remove the empty nodes. LMK what should we do @thomtrp ?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's keep it for now |
||
| { | ||
| query: findOneWorkflowVersionQuery, | ||
| variables: { objectRecordId: input.workflowVersionId }, | ||
| }, | ||
| ], | ||
| }); | ||
|
|
||
| const workflowVersionStepChanges = result?.data?.deleteWorkflowVersionStep; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,12 @@ const isParentStep = ({ | |
| ); | ||
| } | ||
|
|
||
| if (potentialParentStep.type === 'IF_ELSE') { | ||
| return !!potentialParentStep.settings.input.branches?.some((branch) => | ||
| branch.nextStepIds?.includes(currentStep.id), | ||
| ); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👌 |
||
|
|
||
| if (currentStep.type === 'ITERATOR') { | ||
| return !!( | ||
| potentialParentStep.nextStepIds?.includes(currentStep.id) && | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.