Remove dead code about workflow leaf nodes (#10901)
Leaf nodes is no longer a concept in the workflow diagrams. This PR removes dead code. Closes https://github.com/twentyhq/core-team-issues/issues/386
This commit is contained in:
committed by
GitHub
parent
1bc30e9b21
commit
5b7b58c85f
@ -10,7 +10,6 @@ import { workflowDiagramState } from '@/workflow/workflow-diagram/states/workflo
|
|||||||
|
|
||||||
import { addCreateStepNodes } from '@/workflow/workflow-diagram/utils/addCreateStepNodes';
|
import { addCreateStepNodes } from '@/workflow/workflow-diagram/utils/addCreateStepNodes';
|
||||||
import { getWorkflowVersionDiagram } from '@/workflow/workflow-diagram/utils/getWorkflowVersionDiagram';
|
import { getWorkflowVersionDiagram } from '@/workflow/workflow-diagram/utils/getWorkflowVersionDiagram';
|
||||||
import { markLeafNodes } from '@/workflow/workflow-diagram/utils/markLeafNodes';
|
|
||||||
import { mergeWorkflowDiagrams } from '@/workflow/workflow-diagram/utils/mergeWorkflowDiagrams';
|
import { mergeWorkflowDiagrams } from '@/workflow/workflow-diagram/utils/mergeWorkflowDiagrams';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useRecoilCallback, useSetRecoilState } from 'recoil';
|
import { useRecoilCallback, useSetRecoilState } from 'recoil';
|
||||||
@ -33,8 +32,8 @@ export const WorkflowDiagramEffect = ({
|
|||||||
workflowDiagramState,
|
workflowDiagramState,
|
||||||
);
|
);
|
||||||
|
|
||||||
const nextWorkflowDiagram = markLeafNodes(
|
const nextWorkflowDiagram = addCreateStepNodes(
|
||||||
addCreateStepNodes(getWorkflowVersionDiagram(currentVersion)),
|
getWorkflowVersionDiagram(currentVersion),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mergedWorkflowDiagram = nextWorkflowDiagram;
|
let mergedWorkflowDiagram = nextWorkflowDiagram;
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { WorkflowDiagramStepNodeBase } from '@/workflow/workflow-diagram/components/WorkflowDiagramStepNodeBase';
|
import { WorkflowDiagramStepNodeBase } from '@/workflow/workflow-diagram/components/WorkflowDiagramStepNodeBase';
|
||||||
import { WorkflowDiagramEmptyTriggerNodeData } from '@/workflow/workflow-diagram/types/WorkflowDiagram';
|
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
const StyledStepNodeLabelIconContainer = styled.div`
|
const StyledStepNodeLabelIconContainer = styled.div`
|
||||||
@ -11,18 +10,13 @@ const StyledStepNodeLabelIconContainer = styled.div`
|
|||||||
padding: ${({ theme }) => theme.spacing(3)};
|
padding: ${({ theme }) => theme.spacing(3)};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const WorkflowDiagramEmptyTrigger = ({
|
export const WorkflowDiagramEmptyTrigger = () => {
|
||||||
data,
|
|
||||||
}: {
|
|
||||||
data: WorkflowDiagramEmptyTriggerNodeData;
|
|
||||||
}) => {
|
|
||||||
return (
|
return (
|
||||||
<WorkflowDiagramStepNodeBase
|
<WorkflowDiagramStepNodeBase
|
||||||
name="Add a Trigger"
|
name="Add a Trigger"
|
||||||
nodeType="trigger"
|
nodeType="trigger"
|
||||||
variant="empty"
|
variant="empty"
|
||||||
Icon={<StyledStepNodeLabelIconContainer />}
|
Icon={<StyledStepNodeLabelIconContainer />}
|
||||||
isLeafNode={data.isLeafNode}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -194,14 +194,12 @@ export const WorkflowDiagramStepNodeBase = ({
|
|||||||
variant,
|
variant,
|
||||||
Icon,
|
Icon,
|
||||||
RightFloatingElement,
|
RightFloatingElement,
|
||||||
isLeafNode,
|
|
||||||
}: {
|
}: {
|
||||||
nodeType: WorkflowDiagramStepNodeData['nodeType'];
|
nodeType: WorkflowDiagramStepNodeData['nodeType'];
|
||||||
name: string;
|
name: string;
|
||||||
variant: WorkflowDiagramNodeVariant;
|
variant: WorkflowDiagramNodeVariant;
|
||||||
Icon?: React.ReactNode;
|
Icon?: React.ReactNode;
|
||||||
RightFloatingElement?: React.ReactNode;
|
RightFloatingElement?: React.ReactNode;
|
||||||
isLeafNode: boolean;
|
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<StyledStepNodeContainer className="workflow-node-container">
|
<StyledStepNodeContainer className="workflow-node-container">
|
||||||
@ -227,9 +225,7 @@ export const WorkflowDiagramStepNodeBase = ({
|
|||||||
) : null}
|
) : null}
|
||||||
</StyledStepNodeInnerContainer>
|
</StyledStepNodeInnerContainer>
|
||||||
|
|
||||||
{!isLeafNode && (
|
<StyledSourceHandle type="source" position={Position.Bottom} />
|
||||||
<StyledSourceHandle type="source" position={Position.Bottom} />
|
|
||||||
)}
|
|
||||||
</StyledStepNodeContainer>
|
</StyledStepNodeContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -30,7 +30,6 @@ export const WorkflowDiagramStepNodeEditableContent = ({
|
|||||||
/>
|
/>
|
||||||
) : undefined
|
) : undefined
|
||||||
}
|
}
|
||||||
isLeafNode={data.isLeafNode}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -34,7 +34,6 @@ export const WorkflowDiagramStepNodeReadonly = ({
|
|||||||
variant={getNodeVariantFromRunStatus(data.runStatus)}
|
variant={getNodeVariantFromRunStatus(data.runStatus)}
|
||||||
nodeType={data.nodeType}
|
nodeType={data.nodeType}
|
||||||
Icon={<WorkflowDiagramStepNodeIcon data={data} />}
|
Icon={<WorkflowDiagramStepNodeIcon data={data} />}
|
||||||
isLeafNode={data.isLeafNode}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import { useWorkflowVersion } from '@/workflow/hooks/useWorkflowVersion';
|
|||||||
import { flowState } from '@/workflow/states/flowState';
|
import { flowState } from '@/workflow/states/flowState';
|
||||||
import { workflowDiagramState } from '@/workflow/workflow-diagram/states/workflowDiagramState';
|
import { workflowDiagramState } from '@/workflow/workflow-diagram/states/workflowDiagramState';
|
||||||
import { getWorkflowVersionDiagram } from '@/workflow/workflow-diagram/utils/getWorkflowVersionDiagram';
|
import { getWorkflowVersionDiagram } from '@/workflow/workflow-diagram/utils/getWorkflowVersionDiagram';
|
||||||
import { markLeafNodes } from '@/workflow/workflow-diagram/utils/markLeafNodes';
|
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useSetRecoilState } from 'recoil';
|
import { useSetRecoilState } from 'recoil';
|
||||||
import { isDefined } from 'twenty-shared';
|
import { isDefined } from 'twenty-shared';
|
||||||
@ -39,9 +38,7 @@ export const WorkflowVersionVisualizerEffect = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const nextWorkflowDiagram = markLeafNodes(
|
const nextWorkflowDiagram = getWorkflowVersionDiagram(workflowVersion);
|
||||||
getWorkflowVersionDiagram(workflowVersion),
|
|
||||||
);
|
|
||||||
|
|
||||||
setWorkflowDiagram(nextWorkflowDiagram);
|
setWorkflowDiagram(nextWorkflowDiagram);
|
||||||
}, [setWorkflowDiagram, workflowVersion]);
|
}, [setWorkflowDiagram, workflowVersion]);
|
||||||
|
|||||||
@ -64,7 +64,6 @@ export const DefaultEdge: Story = {
|
|||||||
nodeType: 'trigger',
|
nodeType: 'trigger',
|
||||||
triggerType: 'DATABASE_EVENT',
|
triggerType: 'DATABASE_EVENT',
|
||||||
name: 'When record is created',
|
name: 'When record is created',
|
||||||
isLeafNode: false,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -75,7 +74,6 @@ export const DefaultEdge: Story = {
|
|||||||
nodeType: 'action',
|
nodeType: 'action',
|
||||||
actionType: 'CREATE_RECORD',
|
actionType: 'CREATE_RECORD',
|
||||||
name: 'Create record',
|
name: 'Create record',
|
||||||
isLeafNode: false,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -139,7 +137,6 @@ export const SuccessEdge: Story = {
|
|||||||
nodeType: 'trigger',
|
nodeType: 'trigger',
|
||||||
triggerType: 'DATABASE_EVENT',
|
triggerType: 'DATABASE_EVENT',
|
||||||
name: 'When record is created',
|
name: 'When record is created',
|
||||||
isLeafNode: false,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -150,7 +147,6 @@ export const SuccessEdge: Story = {
|
|||||||
nodeType: 'action',
|
nodeType: 'action',
|
||||||
actionType: 'CREATE_RECORD',
|
actionType: 'CREATE_RECORD',
|
||||||
name: 'Create record',
|
name: 'Create record',
|
||||||
isLeafNode: false,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@ -11,7 +11,6 @@ const meta: Meta<typeof WorkflowDiagramEmptyTrigger> = {
|
|||||||
args: {
|
args: {
|
||||||
data: {
|
data: {
|
||||||
nodeType: 'empty-trigger',
|
nodeType: 'empty-trigger',
|
||||||
isLeafNode: true,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -42,21 +41,3 @@ export const Selected: Story = {
|
|||||||
ComponentDecorator,
|
ComponentDecorator,
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const IsNotLeafNode: Story = {
|
|
||||||
decorators: [
|
|
||||||
(Story) => (
|
|
||||||
<div style={{ position: 'relative' }}>
|
|
||||||
<Story />
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
ComponentDecorator,
|
|
||||||
ReactflowDecorator,
|
|
||||||
],
|
|
||||||
args: {
|
|
||||||
data: {
|
|
||||||
nodeType: 'empty-trigger',
|
|
||||||
isLeafNode: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|||||||
@ -37,43 +37,36 @@ const ALL_STEPS = [
|
|||||||
nodeType: 'trigger',
|
nodeType: 'trigger',
|
||||||
triggerType: 'DATABASE_EVENT',
|
triggerType: 'DATABASE_EVENT',
|
||||||
name: 'Record is Created',
|
name: 'Record is Created',
|
||||||
isLeafNode: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
nodeType: 'trigger',
|
nodeType: 'trigger',
|
||||||
triggerType: 'MANUAL',
|
triggerType: 'MANUAL',
|
||||||
name: 'Manual',
|
name: 'Manual',
|
||||||
isLeafNode: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
nodeType: 'action',
|
nodeType: 'action',
|
||||||
actionType: 'CREATE_RECORD',
|
actionType: 'CREATE_RECORD',
|
||||||
name: 'Create Record',
|
name: 'Create Record',
|
||||||
isLeafNode: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
nodeType: 'action',
|
nodeType: 'action',
|
||||||
actionType: 'UPDATE_RECORD',
|
actionType: 'UPDATE_RECORD',
|
||||||
name: 'Update Record',
|
name: 'Update Record',
|
||||||
isLeafNode: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
nodeType: 'action',
|
nodeType: 'action',
|
||||||
actionType: 'DELETE_RECORD',
|
actionType: 'DELETE_RECORD',
|
||||||
name: 'Delete Record',
|
name: 'Delete Record',
|
||||||
isLeafNode: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
nodeType: 'action',
|
nodeType: 'action',
|
||||||
actionType: 'SEND_EMAIL',
|
actionType: 'SEND_EMAIL',
|
||||||
name: 'Send Email',
|
name: 'Send Email',
|
||||||
isLeafNode: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
nodeType: 'action',
|
nodeType: 'action',
|
||||||
actionType: 'CODE',
|
actionType: 'CODE',
|
||||||
name: 'Code',
|
name: 'Code',
|
||||||
isLeafNode: true,
|
|
||||||
},
|
},
|
||||||
] satisfies WorkflowDiagramStepNodeData[];
|
] satisfies WorkflowDiagramStepNodeData[];
|
||||||
|
|
||||||
@ -130,22 +123,3 @@ export const Catalog: CatalogStory<Story, typeof Wrapper> = {
|
|||||||
ReactflowDecorator,
|
ReactflowDecorator,
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const IsNotLeafNode: Story = {
|
|
||||||
args: {
|
|
||||||
data: {
|
|
||||||
...ALL_STEPS[0],
|
|
||||||
isLeafNode: false,
|
|
||||||
},
|
|
||||||
state: 'default',
|
|
||||||
variant: 'default',
|
|
||||||
},
|
|
||||||
decorators: [
|
|
||||||
(Story) => (
|
|
||||||
<div style={{ position: 'relative' }}>
|
|
||||||
<Story />
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
ReactflowDecorator,
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|||||||
@ -7,7 +7,6 @@ export const WORKFLOW_DIAGRAM_EMPTY_TRIGGER_NODE_DEFINITION = {
|
|||||||
type: 'empty-trigger',
|
type: 'empty-trigger',
|
||||||
data: {
|
data: {
|
||||||
nodeType: 'empty-trigger',
|
nodeType: 'empty-trigger',
|
||||||
isLeafNode: false,
|
|
||||||
} satisfies WorkflowDiagramEmptyTriggerNodeData,
|
} satisfies WorkflowDiagramEmptyTriggerNodeData,
|
||||||
position: {
|
position: {
|
||||||
x: 0,
|
x: 0,
|
||||||
|
|||||||
@ -33,25 +33,21 @@ export type WorkflowDiagramStepNodeData =
|
|||||||
name: string;
|
name: string;
|
||||||
icon?: string;
|
icon?: string;
|
||||||
runStatus?: WorkflowDiagramRunStatus;
|
runStatus?: WorkflowDiagramRunStatus;
|
||||||
isLeafNode: boolean;
|
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
nodeType: 'action';
|
nodeType: 'action';
|
||||||
actionType: WorkflowActionType;
|
actionType: WorkflowActionType;
|
||||||
name: string;
|
name: string;
|
||||||
runStatus?: WorkflowDiagramRunStatus;
|
runStatus?: WorkflowDiagramRunStatus;
|
||||||
isLeafNode: boolean;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type WorkflowDiagramCreateStepNodeData = {
|
export type WorkflowDiagramCreateStepNodeData = {
|
||||||
nodeType: 'create-step';
|
nodeType: 'create-step';
|
||||||
parentNodeId: string;
|
parentNodeId: string;
|
||||||
isLeafNode?: never;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type WorkflowDiagramEmptyTriggerNodeData = {
|
export type WorkflowDiagramEmptyTriggerNodeData = {
|
||||||
nodeType: 'empty-trigger';
|
nodeType: 'empty-trigger';
|
||||||
isLeafNode: boolean;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type WorkflowDiagramNodeData =
|
export type WorkflowDiagramNodeData =
|
||||||
|
|||||||
@ -21,7 +21,6 @@ describe('generateWorkflowDiagram', () => {
|
|||||||
expect(result.nodes[0]).toMatchObject({
|
expect(result.nodes[0]).toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
nodeType: 'trigger',
|
nodeType: 'trigger',
|
||||||
isLeafNode: false,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -88,7 +87,6 @@ describe('generateWorkflowDiagram', () => {
|
|||||||
nodeType: 'action',
|
nodeType: 'action',
|
||||||
actionType: 'CODE',
|
actionType: 'CODE',
|
||||||
name: step.name,
|
name: step.name,
|
||||||
isLeafNode: false,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -121,7 +121,6 @@ describe('generateWorkflowRunDiagram', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"icon": "IconPlaylistAdd",
|
"icon": "IconPlaylistAdd",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "Company created",
|
"name": "Company created",
|
||||||
"nodeType": "trigger",
|
"nodeType": "trigger",
|
||||||
"runStatus": "success",
|
"runStatus": "success",
|
||||||
@ -136,7 +135,6 @@ describe('generateWorkflowRunDiagram', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"actionType": "CODE",
|
"actionType": "CODE",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "Step 1",
|
"name": "Step 1",
|
||||||
"nodeType": "action",
|
"nodeType": "action",
|
||||||
"runStatus": "failure",
|
"runStatus": "failure",
|
||||||
@ -150,7 +148,6 @@ describe('generateWorkflowRunDiagram', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"actionType": "CODE",
|
"actionType": "CODE",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "Step 2",
|
"name": "Step 2",
|
||||||
"nodeType": "action",
|
"nodeType": "action",
|
||||||
"runStatus": "not-executed",
|
"runStatus": "not-executed",
|
||||||
@ -164,7 +161,6 @@ describe('generateWorkflowRunDiagram', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"actionType": "CODE",
|
"actionType": "CODE",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "Step 3",
|
"name": "Step 3",
|
||||||
"nodeType": "action",
|
"nodeType": "action",
|
||||||
"runStatus": "not-executed",
|
"runStatus": "not-executed",
|
||||||
@ -300,7 +296,6 @@ describe('generateWorkflowRunDiagram', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"icon": "IconPlaylistAdd",
|
"icon": "IconPlaylistAdd",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "Company created",
|
"name": "Company created",
|
||||||
"nodeType": "trigger",
|
"nodeType": "trigger",
|
||||||
"runStatus": "success",
|
"runStatus": "success",
|
||||||
@ -315,7 +310,6 @@ describe('generateWorkflowRunDiagram', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"actionType": "CODE",
|
"actionType": "CODE",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "Step 1",
|
"name": "Step 1",
|
||||||
"nodeType": "action",
|
"nodeType": "action",
|
||||||
"runStatus": "success",
|
"runStatus": "success",
|
||||||
@ -329,7 +323,6 @@ describe('generateWorkflowRunDiagram', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"actionType": "CODE",
|
"actionType": "CODE",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "Step 2",
|
"name": "Step 2",
|
||||||
"nodeType": "action",
|
"nodeType": "action",
|
||||||
"runStatus": "success",
|
"runStatus": "success",
|
||||||
@ -343,7 +336,6 @@ describe('generateWorkflowRunDiagram', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"actionType": "CODE",
|
"actionType": "CODE",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "Step 3",
|
"name": "Step 3",
|
||||||
"nodeType": "action",
|
"nodeType": "action",
|
||||||
"runStatus": "success",
|
"runStatus": "success",
|
||||||
@ -464,7 +456,6 @@ describe('generateWorkflowRunDiagram', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"icon": "IconPlaylistAdd",
|
"icon": "IconPlaylistAdd",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "Company created",
|
"name": "Company created",
|
||||||
"nodeType": "trigger",
|
"nodeType": "trigger",
|
||||||
"runStatus": "success",
|
"runStatus": "success",
|
||||||
@ -479,7 +470,6 @@ describe('generateWorkflowRunDiagram', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"actionType": "CODE",
|
"actionType": "CODE",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "Step 1",
|
"name": "Step 1",
|
||||||
"nodeType": "action",
|
"nodeType": "action",
|
||||||
"runStatus": "running",
|
"runStatus": "running",
|
||||||
@ -493,7 +483,6 @@ describe('generateWorkflowRunDiagram', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"actionType": "CODE",
|
"actionType": "CODE",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "Step 2",
|
"name": "Step 2",
|
||||||
"nodeType": "action",
|
"nodeType": "action",
|
||||||
"runStatus": "not-executed",
|
"runStatus": "not-executed",
|
||||||
@ -507,7 +496,6 @@ describe('generateWorkflowRunDiagram', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"actionType": "CODE",
|
"actionType": "CODE",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "Step 3",
|
"name": "Step 3",
|
||||||
"nodeType": "action",
|
"nodeType": "action",
|
||||||
"runStatus": "not-executed",
|
"runStatus": "not-executed",
|
||||||
@ -661,7 +649,6 @@ describe('generateWorkflowRunDiagram', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"icon": "IconPlaylistAdd",
|
"icon": "IconPlaylistAdd",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "Company created",
|
"name": "Company created",
|
||||||
"nodeType": "trigger",
|
"nodeType": "trigger",
|
||||||
"runStatus": "success",
|
"runStatus": "success",
|
||||||
@ -676,7 +663,6 @@ describe('generateWorkflowRunDiagram', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"actionType": "CODE",
|
"actionType": "CODE",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "Step 1",
|
"name": "Step 1",
|
||||||
"nodeType": "action",
|
"nodeType": "action",
|
||||||
"runStatus": "success",
|
"runStatus": "success",
|
||||||
@ -690,7 +676,6 @@ describe('generateWorkflowRunDiagram', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"actionType": "CODE",
|
"actionType": "CODE",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "Step 2",
|
"name": "Step 2",
|
||||||
"nodeType": "action",
|
"nodeType": "action",
|
||||||
"runStatus": "running",
|
"runStatus": "running",
|
||||||
@ -704,7 +689,6 @@ describe('generateWorkflowRunDiagram', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"actionType": "CODE",
|
"actionType": "CODE",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "Step 3",
|
"name": "Step 3",
|
||||||
"nodeType": "action",
|
"nodeType": "action",
|
||||||
"runStatus": "not-executed",
|
"runStatus": "not-executed",
|
||||||
@ -718,7 +702,6 @@ describe('generateWorkflowRunDiagram', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"actionType": "CODE",
|
"actionType": "CODE",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "Step 4",
|
"name": "Step 4",
|
||||||
"nodeType": "action",
|
"nodeType": "action",
|
||||||
"runStatus": "not-executed",
|
"runStatus": "not-executed",
|
||||||
|
|||||||
@ -36,7 +36,6 @@ describe('getWorkflowVersionDiagram', () => {
|
|||||||
"nodes": [
|
"nodes": [
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"isLeafNode": false,
|
|
||||||
"nodeType": "empty-trigger",
|
"nodeType": "empty-trigger",
|
||||||
},
|
},
|
||||||
"id": "trigger",
|
"id": "trigger",
|
||||||
@ -75,7 +74,6 @@ describe('getWorkflowVersionDiagram', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"icon": "IconPlaylistAdd",
|
"icon": "IconPlaylistAdd",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "Record is created",
|
"name": "Record is created",
|
||||||
"nodeType": "trigger",
|
"nodeType": "trigger",
|
||||||
"triggerType": "DATABASE_EVENT",
|
"triggerType": "DATABASE_EVENT",
|
||||||
@ -144,7 +142,6 @@ describe('getWorkflowVersionDiagram', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"icon": "IconPlaylistAdd",
|
"icon": "IconPlaylistAdd",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "Company created",
|
"name": "Company created",
|
||||||
"nodeType": "trigger",
|
"nodeType": "trigger",
|
||||||
"triggerType": "DATABASE_EVENT",
|
"triggerType": "DATABASE_EVENT",
|
||||||
@ -158,7 +155,6 @@ describe('getWorkflowVersionDiagram', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"actionType": "CODE",
|
"actionType": "CODE",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "",
|
"name": "",
|
||||||
"nodeType": "action",
|
"nodeType": "action",
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,69 +0,0 @@
|
|||||||
import { WorkflowStep, WorkflowTrigger } from '@/workflow/types/Workflow';
|
|
||||||
import { generateWorkflowDiagram } from '@/workflow/workflow-diagram/utils/generateWorkflowDiagram';
|
|
||||||
import { markLeafNodes } from '../markLeafNodes';
|
|
||||||
|
|
||||||
describe('markLeafNodes', () => {
|
|
||||||
const createTrigger = (): WorkflowTrigger => ({
|
|
||||||
name: 'Company created',
|
|
||||||
type: 'DATABASE_EVENT',
|
|
||||||
settings: {
|
|
||||||
eventName: 'company.created',
|
|
||||||
outputSchema: {},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const createStep = (id: string): WorkflowStep => ({
|
|
||||||
id,
|
|
||||||
name: `Step ${id}`,
|
|
||||||
type: 'CODE',
|
|
||||||
valid: true,
|
|
||||||
settings: {
|
|
||||||
errorHandlingOptions: {
|
|
||||||
retryOnFailure: { value: true },
|
|
||||||
continueOnFailure: { value: false },
|
|
||||||
},
|
|
||||||
input: {
|
|
||||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
|
||||||
serverlessFunctionVersion: '1',
|
|
||||||
serverlessFunctionInput: {},
|
|
||||||
},
|
|
||||||
outputSchema: {},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
it('handles empty workflow with only trigger', () => {
|
|
||||||
const trigger = createTrigger();
|
|
||||||
const steps: WorkflowStep[] = [];
|
|
||||||
|
|
||||||
const diagram = generateWorkflowDiagram({ trigger, steps });
|
|
||||||
const diagramWithLeafNodes = markLeafNodes(diagram);
|
|
||||||
|
|
||||||
expect(diagramWithLeafNodes.nodes).toHaveLength(1);
|
|
||||||
expect(diagramWithLeafNodes.nodes[0].data.isLeafNode).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('handles workflow with single step', () => {
|
|
||||||
const trigger = createTrigger();
|
|
||||||
const steps = [createStep('step1')];
|
|
||||||
|
|
||||||
const diagram = generateWorkflowDiagram({ trigger, steps });
|
|
||||||
const diagramWithLeafNodes = markLeafNodes(diagram);
|
|
||||||
|
|
||||||
expect(diagramWithLeafNodes.nodes).toHaveLength(2);
|
|
||||||
expect(diagramWithLeafNodes.nodes[0].data.isLeafNode).toBe(false);
|
|
||||||
expect(diagramWithLeafNodes.nodes[1].data.isLeafNode).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('handles workflow with two steps', () => {
|
|
||||||
const trigger = createTrigger();
|
|
||||||
const steps = [createStep('step1'), createStep('step2')];
|
|
||||||
|
|
||||||
const diagram = generateWorkflowDiagram({ trigger, steps });
|
|
||||||
const diagramWithLeafNodes = markLeafNodes(diagram);
|
|
||||||
|
|
||||||
expect(diagramWithLeafNodes.nodes).toHaveLength(3);
|
|
||||||
expect(diagramWithLeafNodes.nodes[0].data.isLeafNode).toBe(false);
|
|
||||||
expect(diagramWithLeafNodes.nodes[1].data.isLeafNode).toBe(false);
|
|
||||||
expect(diagramWithLeafNodes.nodes[2].data.isLeafNode).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -9,7 +9,6 @@ it('Preserves the properties defined in the previous version but not in the next
|
|||||||
nodeType: 'action',
|
nodeType: 'action',
|
||||||
name: '',
|
name: '',
|
||||||
actionType: 'CODE',
|
actionType: 'CODE',
|
||||||
isLeafNode: true,
|
|
||||||
},
|
},
|
||||||
id: '1',
|
id: '1',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
@ -25,7 +24,6 @@ it('Preserves the properties defined in the previous version but not in the next
|
|||||||
nodeType: 'action',
|
nodeType: 'action',
|
||||||
name: '',
|
name: '',
|
||||||
actionType: 'CODE',
|
actionType: 'CODE',
|
||||||
isLeafNode: true,
|
|
||||||
},
|
},
|
||||||
id: '1',
|
id: '1',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
@ -42,7 +40,6 @@ it('Preserves the properties defined in the previous version but not in the next
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"actionType": "CODE",
|
"actionType": "CODE",
|
||||||
"isLeafNode": true,
|
|
||||||
"name": "",
|
"name": "",
|
||||||
"nodeType": "action",
|
"nodeType": "action",
|
||||||
},
|
},
|
||||||
@ -66,7 +63,6 @@ it('Replaces duplicated properties with the next value', () => {
|
|||||||
nodeType: 'action',
|
nodeType: 'action',
|
||||||
name: '',
|
name: '',
|
||||||
actionType: 'CODE',
|
actionType: 'CODE',
|
||||||
isLeafNode: true,
|
|
||||||
},
|
},
|
||||||
id: '1',
|
id: '1',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
@ -81,7 +77,6 @@ it('Replaces duplicated properties with the next value', () => {
|
|||||||
nodeType: 'action',
|
nodeType: 'action',
|
||||||
name: '2',
|
name: '2',
|
||||||
actionType: 'CODE',
|
actionType: 'CODE',
|
||||||
isLeafNode: false,
|
|
||||||
},
|
},
|
||||||
id: '1',
|
id: '1',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
@ -98,7 +93,6 @@ it('Replaces duplicated properties with the next value', () => {
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"actionType": "CODE",
|
"actionType": "CODE",
|
||||||
"isLeafNode": false,
|
|
||||||
"name": "2",
|
"name": "2",
|
||||||
"nodeType": "action",
|
"nodeType": "action",
|
||||||
},
|
},
|
||||||
|
|||||||
@ -55,7 +55,6 @@ export const generateWorkflowDiagram = ({
|
|||||||
nodeType: 'action',
|
nodeType: 'action',
|
||||||
actionType: step.type,
|
actionType: step.type,
|
||||||
name: step.name,
|
name: step.name,
|
||||||
isLeafNode: false,
|
|
||||||
} satisfies WorkflowDiagramStepNodeData,
|
} satisfies WorkflowDiagramStepNodeData,
|
||||||
position: {
|
position: {
|
||||||
x: xPos,
|
x: xPos,
|
||||||
|
|||||||
@ -99,7 +99,6 @@ export const generateWorkflowRunDiagram = ({
|
|||||||
nodeType: 'action',
|
nodeType: 'action',
|
||||||
actionType: step.type,
|
actionType: step.type,
|
||||||
name: step.name,
|
name: step.name,
|
||||||
isLeafNode: false,
|
|
||||||
runStatus,
|
runStatus,
|
||||||
},
|
},
|
||||||
position: {
|
position: {
|
||||||
|
|||||||
@ -64,7 +64,6 @@ export const getWorkflowDiagramTriggerNode = ({
|
|||||||
triggerType: trigger.type,
|
triggerType: trigger.type,
|
||||||
name: isDefined(trigger.name) ? trigger.name : triggerDefaultLabel,
|
name: isDefined(trigger.name) ? trigger.name : triggerDefaultLabel,
|
||||||
icon: triggerIcon,
|
icon: triggerIcon,
|
||||||
isLeafNode: false,
|
|
||||||
} satisfies WorkflowDiagramStepNodeData,
|
} satisfies WorkflowDiagramStepNodeData,
|
||||||
position: {
|
position: {
|
||||||
x: 0,
|
x: 0,
|
||||||
|
|||||||
@ -1,31 +0,0 @@
|
|||||||
import {
|
|
||||||
WorkflowDiagram,
|
|
||||||
WorkflowDiagramNode,
|
|
||||||
} from '@/workflow/workflow-diagram/types/WorkflowDiagram';
|
|
||||||
import { isCreateStepNode } from '@/workflow/workflow-diagram/utils/isCreateStepNode';
|
|
||||||
|
|
||||||
export const markLeafNodes = ({
|
|
||||||
nodes,
|
|
||||||
edges,
|
|
||||||
}: WorkflowDiagram): WorkflowDiagram => {
|
|
||||||
const sourceNodeIds = new Set(edges.map((edge) => edge.source));
|
|
||||||
|
|
||||||
const updatedNodes = nodes.map((node) => {
|
|
||||||
if (isCreateStepNode(node)) {
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
...node,
|
|
||||||
data: {
|
|
||||||
...node.data,
|
|
||||||
isLeafNode: !sourceNodeIds.has(node.id),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
nodes: updatedNodes as WorkflowDiagramNode[],
|
|
||||||
edges,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user