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 { getWorkflowVersionDiagram } from '@/workflow/workflow-diagram/utils/getWorkflowVersionDiagram';
|
||||
import { markLeafNodes } from '@/workflow/workflow-diagram/utils/markLeafNodes';
|
||||
import { mergeWorkflowDiagrams } from '@/workflow/workflow-diagram/utils/mergeWorkflowDiagrams';
|
||||
import { useEffect } from 'react';
|
||||
import { useRecoilCallback, useSetRecoilState } from 'recoil';
|
||||
@ -33,8 +32,8 @@ export const WorkflowDiagramEffect = ({
|
||||
workflowDiagramState,
|
||||
);
|
||||
|
||||
const nextWorkflowDiagram = markLeafNodes(
|
||||
addCreateStepNodes(getWorkflowVersionDiagram(currentVersion)),
|
||||
const nextWorkflowDiagram = addCreateStepNodes(
|
||||
getWorkflowVersionDiagram(currentVersion),
|
||||
);
|
||||
|
||||
let mergedWorkflowDiagram = nextWorkflowDiagram;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { WorkflowDiagramStepNodeBase } from '@/workflow/workflow-diagram/components/WorkflowDiagramStepNodeBase';
|
||||
import { WorkflowDiagramEmptyTriggerNodeData } from '@/workflow/workflow-diagram/types/WorkflowDiagram';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
const StyledStepNodeLabelIconContainer = styled.div`
|
||||
@ -11,18 +10,13 @@ const StyledStepNodeLabelIconContainer = styled.div`
|
||||
padding: ${({ theme }) => theme.spacing(3)};
|
||||
`;
|
||||
|
||||
export const WorkflowDiagramEmptyTrigger = ({
|
||||
data,
|
||||
}: {
|
||||
data: WorkflowDiagramEmptyTriggerNodeData;
|
||||
}) => {
|
||||
export const WorkflowDiagramEmptyTrigger = () => {
|
||||
return (
|
||||
<WorkflowDiagramStepNodeBase
|
||||
name="Add a Trigger"
|
||||
nodeType="trigger"
|
||||
variant="empty"
|
||||
Icon={<StyledStepNodeLabelIconContainer />}
|
||||
isLeafNode={data.isLeafNode}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@ -194,14 +194,12 @@ export const WorkflowDiagramStepNodeBase = ({
|
||||
variant,
|
||||
Icon,
|
||||
RightFloatingElement,
|
||||
isLeafNode,
|
||||
}: {
|
||||
nodeType: WorkflowDiagramStepNodeData['nodeType'];
|
||||
name: string;
|
||||
variant: WorkflowDiagramNodeVariant;
|
||||
Icon?: React.ReactNode;
|
||||
RightFloatingElement?: React.ReactNode;
|
||||
isLeafNode: boolean;
|
||||
}) => {
|
||||
return (
|
||||
<StyledStepNodeContainer className="workflow-node-container">
|
||||
@ -227,9 +225,7 @@ export const WorkflowDiagramStepNodeBase = ({
|
||||
) : null}
|
||||
</StyledStepNodeInnerContainer>
|
||||
|
||||
{!isLeafNode && (
|
||||
<StyledSourceHandle type="source" position={Position.Bottom} />
|
||||
)}
|
||||
<StyledSourceHandle type="source" position={Position.Bottom} />
|
||||
</StyledStepNodeContainer>
|
||||
);
|
||||
};
|
||||
|
||||
@ -30,7 +30,6 @@ export const WorkflowDiagramStepNodeEditableContent = ({
|
||||
/>
|
||||
) : undefined
|
||||
}
|
||||
isLeafNode={data.isLeafNode}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@ -34,7 +34,6 @@ export const WorkflowDiagramStepNodeReadonly = ({
|
||||
variant={getNodeVariantFromRunStatus(data.runStatus)}
|
||||
nodeType={data.nodeType}
|
||||
Icon={<WorkflowDiagramStepNodeIcon data={data} />}
|
||||
isLeafNode={data.isLeafNode}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@ -3,7 +3,6 @@ import { useWorkflowVersion } from '@/workflow/hooks/useWorkflowVersion';
|
||||
import { flowState } from '@/workflow/states/flowState';
|
||||
import { workflowDiagramState } from '@/workflow/workflow-diagram/states/workflowDiagramState';
|
||||
import { getWorkflowVersionDiagram } from '@/workflow/workflow-diagram/utils/getWorkflowVersionDiagram';
|
||||
import { markLeafNodes } from '@/workflow/workflow-diagram/utils/markLeafNodes';
|
||||
import { useEffect } from 'react';
|
||||
import { useSetRecoilState } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
@ -39,9 +38,7 @@ export const WorkflowVersionVisualizerEffect = ({
|
||||
return;
|
||||
}
|
||||
|
||||
const nextWorkflowDiagram = markLeafNodes(
|
||||
getWorkflowVersionDiagram(workflowVersion),
|
||||
);
|
||||
const nextWorkflowDiagram = getWorkflowVersionDiagram(workflowVersion);
|
||||
|
||||
setWorkflowDiagram(nextWorkflowDiagram);
|
||||
}, [setWorkflowDiagram, workflowVersion]);
|
||||
|
||||
@ -64,7 +64,6 @@ export const DefaultEdge: Story = {
|
||||
nodeType: 'trigger',
|
||||
triggerType: 'DATABASE_EVENT',
|
||||
name: 'When record is created',
|
||||
isLeafNode: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -75,7 +74,6 @@ export const DefaultEdge: Story = {
|
||||
nodeType: 'action',
|
||||
actionType: 'CREATE_RECORD',
|
||||
name: 'Create record',
|
||||
isLeafNode: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -139,7 +137,6 @@ export const SuccessEdge: Story = {
|
||||
nodeType: 'trigger',
|
||||
triggerType: 'DATABASE_EVENT',
|
||||
name: 'When record is created',
|
||||
isLeafNode: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -150,7 +147,6 @@ export const SuccessEdge: Story = {
|
||||
nodeType: 'action',
|
||||
actionType: 'CREATE_RECORD',
|
||||
name: 'Create record',
|
||||
isLeafNode: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@ -11,7 +11,6 @@ const meta: Meta<typeof WorkflowDiagramEmptyTrigger> = {
|
||||
args: {
|
||||
data: {
|
||||
nodeType: 'empty-trigger',
|
||||
isLeafNode: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
@ -42,21 +41,3 @@ export const Selected: Story = {
|
||||
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',
|
||||
triggerType: 'DATABASE_EVENT',
|
||||
name: 'Record is Created',
|
||||
isLeafNode: true,
|
||||
},
|
||||
{
|
||||
nodeType: 'trigger',
|
||||
triggerType: 'MANUAL',
|
||||
name: 'Manual',
|
||||
isLeafNode: true,
|
||||
},
|
||||
{
|
||||
nodeType: 'action',
|
||||
actionType: 'CREATE_RECORD',
|
||||
name: 'Create Record',
|
||||
isLeafNode: true,
|
||||
},
|
||||
{
|
||||
nodeType: 'action',
|
||||
actionType: 'UPDATE_RECORD',
|
||||
name: 'Update Record',
|
||||
isLeafNode: true,
|
||||
},
|
||||
{
|
||||
nodeType: 'action',
|
||||
actionType: 'DELETE_RECORD',
|
||||
name: 'Delete Record',
|
||||
isLeafNode: true,
|
||||
},
|
||||
{
|
||||
nodeType: 'action',
|
||||
actionType: 'SEND_EMAIL',
|
||||
name: 'Send Email',
|
||||
isLeafNode: true,
|
||||
},
|
||||
{
|
||||
nodeType: 'action',
|
||||
actionType: 'CODE',
|
||||
name: 'Code',
|
||||
isLeafNode: true,
|
||||
},
|
||||
] satisfies WorkflowDiagramStepNodeData[];
|
||||
|
||||
@ -130,22 +123,3 @@ export const Catalog: CatalogStory<Story, typeof Wrapper> = {
|
||||
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',
|
||||
data: {
|
||||
nodeType: 'empty-trigger',
|
||||
isLeafNode: false,
|
||||
} satisfies WorkflowDiagramEmptyTriggerNodeData,
|
||||
position: {
|
||||
x: 0,
|
||||
|
||||
@ -33,25 +33,21 @@ export type WorkflowDiagramStepNodeData =
|
||||
name: string;
|
||||
icon?: string;
|
||||
runStatus?: WorkflowDiagramRunStatus;
|
||||
isLeafNode: boolean;
|
||||
}
|
||||
| {
|
||||
nodeType: 'action';
|
||||
actionType: WorkflowActionType;
|
||||
name: string;
|
||||
runStatus?: WorkflowDiagramRunStatus;
|
||||
isLeafNode: boolean;
|
||||
};
|
||||
|
||||
export type WorkflowDiagramCreateStepNodeData = {
|
||||
nodeType: 'create-step';
|
||||
parentNodeId: string;
|
||||
isLeafNode?: never;
|
||||
};
|
||||
|
||||
export type WorkflowDiagramEmptyTriggerNodeData = {
|
||||
nodeType: 'empty-trigger';
|
||||
isLeafNode: boolean;
|
||||
};
|
||||
|
||||
export type WorkflowDiagramNodeData =
|
||||
|
||||
@ -21,7 +21,6 @@ describe('generateWorkflowDiagram', () => {
|
||||
expect(result.nodes[0]).toMatchObject({
|
||||
data: {
|
||||
nodeType: 'trigger',
|
||||
isLeafNode: false,
|
||||
},
|
||||
});
|
||||
});
|
||||
@ -88,7 +87,6 @@ describe('generateWorkflowDiagram', () => {
|
||||
nodeType: 'action',
|
||||
actionType: 'CODE',
|
||||
name: step.name,
|
||||
isLeafNode: false,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -121,7 +121,6 @@ describe('generateWorkflowRunDiagram', () => {
|
||||
{
|
||||
"data": {
|
||||
"icon": "IconPlaylistAdd",
|
||||
"isLeafNode": false,
|
||||
"name": "Company created",
|
||||
"nodeType": "trigger",
|
||||
"runStatus": "success",
|
||||
@ -136,7 +135,6 @@ describe('generateWorkflowRunDiagram', () => {
|
||||
{
|
||||
"data": {
|
||||
"actionType": "CODE",
|
||||
"isLeafNode": false,
|
||||
"name": "Step 1",
|
||||
"nodeType": "action",
|
||||
"runStatus": "failure",
|
||||
@ -150,7 +148,6 @@ describe('generateWorkflowRunDiagram', () => {
|
||||
{
|
||||
"data": {
|
||||
"actionType": "CODE",
|
||||
"isLeafNode": false,
|
||||
"name": "Step 2",
|
||||
"nodeType": "action",
|
||||
"runStatus": "not-executed",
|
||||
@ -164,7 +161,6 @@ describe('generateWorkflowRunDiagram', () => {
|
||||
{
|
||||
"data": {
|
||||
"actionType": "CODE",
|
||||
"isLeafNode": false,
|
||||
"name": "Step 3",
|
||||
"nodeType": "action",
|
||||
"runStatus": "not-executed",
|
||||
@ -300,7 +296,6 @@ describe('generateWorkflowRunDiagram', () => {
|
||||
{
|
||||
"data": {
|
||||
"icon": "IconPlaylistAdd",
|
||||
"isLeafNode": false,
|
||||
"name": "Company created",
|
||||
"nodeType": "trigger",
|
||||
"runStatus": "success",
|
||||
@ -315,7 +310,6 @@ describe('generateWorkflowRunDiagram', () => {
|
||||
{
|
||||
"data": {
|
||||
"actionType": "CODE",
|
||||
"isLeafNode": false,
|
||||
"name": "Step 1",
|
||||
"nodeType": "action",
|
||||
"runStatus": "success",
|
||||
@ -329,7 +323,6 @@ describe('generateWorkflowRunDiagram', () => {
|
||||
{
|
||||
"data": {
|
||||
"actionType": "CODE",
|
||||
"isLeafNode": false,
|
||||
"name": "Step 2",
|
||||
"nodeType": "action",
|
||||
"runStatus": "success",
|
||||
@ -343,7 +336,6 @@ describe('generateWorkflowRunDiagram', () => {
|
||||
{
|
||||
"data": {
|
||||
"actionType": "CODE",
|
||||
"isLeafNode": false,
|
||||
"name": "Step 3",
|
||||
"nodeType": "action",
|
||||
"runStatus": "success",
|
||||
@ -464,7 +456,6 @@ describe('generateWorkflowRunDiagram', () => {
|
||||
{
|
||||
"data": {
|
||||
"icon": "IconPlaylistAdd",
|
||||
"isLeafNode": false,
|
||||
"name": "Company created",
|
||||
"nodeType": "trigger",
|
||||
"runStatus": "success",
|
||||
@ -479,7 +470,6 @@ describe('generateWorkflowRunDiagram', () => {
|
||||
{
|
||||
"data": {
|
||||
"actionType": "CODE",
|
||||
"isLeafNode": false,
|
||||
"name": "Step 1",
|
||||
"nodeType": "action",
|
||||
"runStatus": "running",
|
||||
@ -493,7 +483,6 @@ describe('generateWorkflowRunDiagram', () => {
|
||||
{
|
||||
"data": {
|
||||
"actionType": "CODE",
|
||||
"isLeafNode": false,
|
||||
"name": "Step 2",
|
||||
"nodeType": "action",
|
||||
"runStatus": "not-executed",
|
||||
@ -507,7 +496,6 @@ describe('generateWorkflowRunDiagram', () => {
|
||||
{
|
||||
"data": {
|
||||
"actionType": "CODE",
|
||||
"isLeafNode": false,
|
||||
"name": "Step 3",
|
||||
"nodeType": "action",
|
||||
"runStatus": "not-executed",
|
||||
@ -661,7 +649,6 @@ describe('generateWorkflowRunDiagram', () => {
|
||||
{
|
||||
"data": {
|
||||
"icon": "IconPlaylistAdd",
|
||||
"isLeafNode": false,
|
||||
"name": "Company created",
|
||||
"nodeType": "trigger",
|
||||
"runStatus": "success",
|
||||
@ -676,7 +663,6 @@ describe('generateWorkflowRunDiagram', () => {
|
||||
{
|
||||
"data": {
|
||||
"actionType": "CODE",
|
||||
"isLeafNode": false,
|
||||
"name": "Step 1",
|
||||
"nodeType": "action",
|
||||
"runStatus": "success",
|
||||
@ -690,7 +676,6 @@ describe('generateWorkflowRunDiagram', () => {
|
||||
{
|
||||
"data": {
|
||||
"actionType": "CODE",
|
||||
"isLeafNode": false,
|
||||
"name": "Step 2",
|
||||
"nodeType": "action",
|
||||
"runStatus": "running",
|
||||
@ -704,7 +689,6 @@ describe('generateWorkflowRunDiagram', () => {
|
||||
{
|
||||
"data": {
|
||||
"actionType": "CODE",
|
||||
"isLeafNode": false,
|
||||
"name": "Step 3",
|
||||
"nodeType": "action",
|
||||
"runStatus": "not-executed",
|
||||
@ -718,7 +702,6 @@ describe('generateWorkflowRunDiagram', () => {
|
||||
{
|
||||
"data": {
|
||||
"actionType": "CODE",
|
||||
"isLeafNode": false,
|
||||
"name": "Step 4",
|
||||
"nodeType": "action",
|
||||
"runStatus": "not-executed",
|
||||
|
||||
@ -36,7 +36,6 @@ describe('getWorkflowVersionDiagram', () => {
|
||||
"nodes": [
|
||||
{
|
||||
"data": {
|
||||
"isLeafNode": false,
|
||||
"nodeType": "empty-trigger",
|
||||
},
|
||||
"id": "trigger",
|
||||
@ -75,7 +74,6 @@ describe('getWorkflowVersionDiagram', () => {
|
||||
{
|
||||
"data": {
|
||||
"icon": "IconPlaylistAdd",
|
||||
"isLeafNode": false,
|
||||
"name": "Record is created",
|
||||
"nodeType": "trigger",
|
||||
"triggerType": "DATABASE_EVENT",
|
||||
@ -144,7 +142,6 @@ describe('getWorkflowVersionDiagram', () => {
|
||||
{
|
||||
"data": {
|
||||
"icon": "IconPlaylistAdd",
|
||||
"isLeafNode": false,
|
||||
"name": "Company created",
|
||||
"nodeType": "trigger",
|
||||
"triggerType": "DATABASE_EVENT",
|
||||
@ -158,7 +155,6 @@ describe('getWorkflowVersionDiagram', () => {
|
||||
{
|
||||
"data": {
|
||||
"actionType": "CODE",
|
||||
"isLeafNode": false,
|
||||
"name": "",
|
||||
"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',
|
||||
name: '',
|
||||
actionType: 'CODE',
|
||||
isLeafNode: true,
|
||||
},
|
||||
id: '1',
|
||||
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',
|
||||
name: '',
|
||||
actionType: 'CODE',
|
||||
isLeafNode: true,
|
||||
},
|
||||
id: '1',
|
||||
position: { x: 0, y: 0 },
|
||||
@ -42,7 +40,6 @@ it('Preserves the properties defined in the previous version but not in the next
|
||||
{
|
||||
"data": {
|
||||
"actionType": "CODE",
|
||||
"isLeafNode": true,
|
||||
"name": "",
|
||||
"nodeType": "action",
|
||||
},
|
||||
@ -66,7 +63,6 @@ it('Replaces duplicated properties with the next value', () => {
|
||||
nodeType: 'action',
|
||||
name: '',
|
||||
actionType: 'CODE',
|
||||
isLeafNode: true,
|
||||
},
|
||||
id: '1',
|
||||
position: { x: 0, y: 0 },
|
||||
@ -81,7 +77,6 @@ it('Replaces duplicated properties with the next value', () => {
|
||||
nodeType: 'action',
|
||||
name: '2',
|
||||
actionType: 'CODE',
|
||||
isLeafNode: false,
|
||||
},
|
||||
id: '1',
|
||||
position: { x: 0, y: 0 },
|
||||
@ -98,7 +93,6 @@ it('Replaces duplicated properties with the next value', () => {
|
||||
{
|
||||
"data": {
|
||||
"actionType": "CODE",
|
||||
"isLeafNode": false,
|
||||
"name": "2",
|
||||
"nodeType": "action",
|
||||
},
|
||||
|
||||
@ -55,7 +55,6 @@ export const generateWorkflowDiagram = ({
|
||||
nodeType: 'action',
|
||||
actionType: step.type,
|
||||
name: step.name,
|
||||
isLeafNode: false,
|
||||
} satisfies WorkflowDiagramStepNodeData,
|
||||
position: {
|
||||
x: xPos,
|
||||
|
||||
@ -99,7 +99,6 @@ export const generateWorkflowRunDiagram = ({
|
||||
nodeType: 'action',
|
||||
actionType: step.type,
|
||||
name: step.name,
|
||||
isLeafNode: false,
|
||||
runStatus,
|
||||
},
|
||||
position: {
|
||||
|
||||
@ -64,7 +64,6 @@ export const getWorkflowDiagramTriggerNode = ({
|
||||
triggerType: trigger.type,
|
||||
name: isDefined(trigger.name) ? trigger.name : triggerDefaultLabel,
|
||||
icon: triggerIcon,
|
||||
isLeafNode: false,
|
||||
} satisfies WorkflowDiagramStepNodeData,
|
||||
position: {
|
||||
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