-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add the new workflow not executed
node type
#10030
Changes from all commits
0fdeb29
7b144e6
53d8a50
6217eea
4ea2a43
40c50cc
855f3e3
16e781a
b513cb9
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 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,21 +1,33 @@ | ||||||||||||||
import { Meta, StoryObj } from '@storybook/react'; | ||||||||||||||
|
||||||||||||||
import { WorkflowDiagramStepNodeData } from '@/workflow/workflow-diagram/types/WorkflowDiagram'; | ||||||||||||||
import { WorkflowDiagramNodeVariant } from '@/workflow/workflow-diagram/types/WorkflowDiagramNodeVariant'; | ||||||||||||||
import { fn } from '@storybook/test'; | ||||||||||||||
import '@xyflow/react/dist/style.css'; | ||||||||||||||
import { ComponentProps } from 'react'; | ||||||||||||||
import { CatalogDecorator, CatalogStory } from 'twenty-ui'; | ||||||||||||||
import { ReactflowDecorator } from '~/testing/decorators/ReactflowDecorator'; | ||||||||||||||
import { graphqlMocks } from '~/testing/graphqlMocks'; | ||||||||||||||
import { WorkflowDiagramStepNodeEditableContent } from '../WorkflowDiagramStepNodeEditableContent'; | ||||||||||||||
|
||||||||||||||
const meta: Meta<typeof WorkflowDiagramStepNodeEditableContent> = { | ||||||||||||||
type ComponentState = 'default' | 'hover' | 'selected'; | ||||||||||||||
|
||||||||||||||
type WrapperProps = ComponentProps< | ||||||||||||||
typeof WorkflowDiagramStepNodeEditableContent | ||||||||||||||
> & { state: ComponentState }; | ||||||||||||||
|
||||||||||||||
const Wrapper = (_props: WrapperProps) => { | ||||||||||||||
return <div></div>; | ||||||||||||||
}; | ||||||||||||||
Comment on lines
+19
to
+21
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. logic: Empty wrapper component doesn't render props. This could cause issues with storybook's prop table generation.
Suggested change
|
||||||||||||||
|
||||||||||||||
const meta: Meta<WrapperProps> = { | ||||||||||||||
title: 'Modules/Workflow/WorkflowDiagramStepNodeEditableContent', | ||||||||||||||
component: WorkflowDiagramStepNodeEditableContent, | ||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
export default meta; | ||||||||||||||
|
||||||||||||||
type Story = StoryObj<typeof WorkflowDiagramStepNodeEditableContent>; | ||||||||||||||
type Story = StoryObj<typeof Wrapper>; | ||||||||||||||
|
||||||||||||||
const ALL_STEPS = [ | ||||||||||||||
{ | ||||||||||||||
|
@@ -47,17 +59,13 @@ const ALL_STEPS = [ | |||||||||||||
{ nodeType: 'action', actionType: 'CODE', name: 'Code' }, | ||||||||||||||
] satisfies WorkflowDiagramStepNodeData[]; | ||||||||||||||
|
||||||||||||||
export const All: CatalogStory< | ||||||||||||||
Story, | ||||||||||||||
typeof WorkflowDiagramStepNodeEditableContent | ||||||||||||||
> = { | ||||||||||||||
export const Catalog: CatalogStory<Story, typeof Wrapper> = { | ||||||||||||||
args: { | ||||||||||||||
onDelete: fn(), | ||||||||||||||
variant: 'default', | ||||||||||||||
selected: false, | ||||||||||||||
}, | ||||||||||||||
parameters: { | ||||||||||||||
msw: graphqlMocks, | ||||||||||||||
pseudo: { hover: ['.hover'] }, | ||||||||||||||
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. I had a hard time making the pseudo states plugin work because I didn't want my underlying components to expose a 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. It seems a bit hacky but it works 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. I couldn't find a better option 😅 |
||||||||||||||
catalog: { | ||||||||||||||
options: { | ||||||||||||||
elementContainer: { | ||||||||||||||
|
@@ -71,159 +79,36 @@ export const All: CatalogStory< | |||||||||||||
values: ALL_STEPS, | ||||||||||||||
props: (data: WorkflowDiagramStepNodeData) => ({ data }), | ||||||||||||||
}, | ||||||||||||||
], | ||||||||||||||
}, | ||||||||||||||
}, | ||||||||||||||
decorators: [CatalogDecorator, ReactflowDecorator], | ||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
export const AllSelected: CatalogStory< | ||||||||||||||
Story, | ||||||||||||||
typeof WorkflowDiagramStepNodeEditableContent | ||||||||||||||
> = { | ||||||||||||||
args: { | ||||||||||||||
onDelete: fn(), | ||||||||||||||
variant: 'default', | ||||||||||||||
selected: true, | ||||||||||||||
}, | ||||||||||||||
parameters: { | ||||||||||||||
msw: graphqlMocks, | ||||||||||||||
catalog: { | ||||||||||||||
options: { | ||||||||||||||
elementContainer: { | ||||||||||||||
width: 250, | ||||||||||||||
style: { position: 'relative' }, | ||||||||||||||
className: 'selectable selected', | ||||||||||||||
}, | ||||||||||||||
}, | ||||||||||||||
dimensions: [ | ||||||||||||||
{ | ||||||||||||||
name: 'step type', | ||||||||||||||
values: ALL_STEPS, | ||||||||||||||
props: (data: WorkflowDiagramStepNodeData) => ({ data }), | ||||||||||||||
name: 'variant', | ||||||||||||||
values: [ | ||||||||||||||
'empty', | ||||||||||||||
'default', | ||||||||||||||
'success', | ||||||||||||||
'failure', | ||||||||||||||
'not-executed', | ||||||||||||||
] satisfies WorkflowDiagramNodeVariant[], | ||||||||||||||
props: (variant: WorkflowDiagramNodeVariant) => ({ variant }), | ||||||||||||||
}, | ||||||||||||||
], | ||||||||||||||
}, | ||||||||||||||
}, | ||||||||||||||
decorators: [CatalogDecorator, ReactflowDecorator], | ||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
export const AllSuccess: CatalogStory< | ||||||||||||||
Story, | ||||||||||||||
typeof WorkflowDiagramStepNodeEditableContent | ||||||||||||||
> = { | ||||||||||||||
args: { | ||||||||||||||
onDelete: fn(), | ||||||||||||||
variant: 'success', | ||||||||||||||
}, | ||||||||||||||
parameters: { | ||||||||||||||
msw: graphqlMocks, | ||||||||||||||
catalog: { | ||||||||||||||
options: { | ||||||||||||||
elementContainer: { | ||||||||||||||
width: 250, | ||||||||||||||
style: { position: 'relative' }, | ||||||||||||||
}, | ||||||||||||||
}, | ||||||||||||||
dimensions: [ | ||||||||||||||
{ | ||||||||||||||
name: 'step type', | ||||||||||||||
values: ALL_STEPS, | ||||||||||||||
props: (data: WorkflowDiagramStepNodeData) => ({ data }), | ||||||||||||||
name: 'state', | ||||||||||||||
values: ['default', 'hover', 'selected'] satisfies ComponentState[], | ||||||||||||||
props: (state: ComponentState) => ({ state }), | ||||||||||||||
}, | ||||||||||||||
], | ||||||||||||||
}, | ||||||||||||||
}, | ||||||||||||||
decorators: [CatalogDecorator, ReactflowDecorator], | ||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
export const AllSuccessSelected: CatalogStory< | ||||||||||||||
Story, | ||||||||||||||
typeof WorkflowDiagramStepNodeEditableContent | ||||||||||||||
> = { | ||||||||||||||
args: { | ||||||||||||||
onDelete: fn(), | ||||||||||||||
variant: 'success', | ||||||||||||||
selected: true, | ||||||||||||||
}, | ||||||||||||||
parameters: { | ||||||||||||||
msw: graphqlMocks, | ||||||||||||||
catalog: { | ||||||||||||||
options: { | ||||||||||||||
elementContainer: { | ||||||||||||||
width: 250, | ||||||||||||||
style: { position: 'relative' }, | ||||||||||||||
className: 'selectable selected', | ||||||||||||||
}, | ||||||||||||||
}, | ||||||||||||||
dimensions: [ | ||||||||||||||
{ | ||||||||||||||
name: 'step type', | ||||||||||||||
values: ALL_STEPS, | ||||||||||||||
props: (data: WorkflowDiagramStepNodeData) => ({ data }), | ||||||||||||||
}, | ||||||||||||||
], | ||||||||||||||
}, | ||||||||||||||
}, | ||||||||||||||
decorators: [CatalogDecorator, ReactflowDecorator], | ||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
export const AllFailure: CatalogStory< | ||||||||||||||
Story, | ||||||||||||||
typeof WorkflowDiagramStepNodeEditableContent | ||||||||||||||
> = { | ||||||||||||||
args: { | ||||||||||||||
onDelete: fn(), | ||||||||||||||
variant: 'failure', | ||||||||||||||
}, | ||||||||||||||
parameters: { | ||||||||||||||
msw: graphqlMocks, | ||||||||||||||
catalog: { | ||||||||||||||
options: { | ||||||||||||||
elementContainer: { | ||||||||||||||
width: 250, | ||||||||||||||
style: { position: 'relative' }, | ||||||||||||||
}, | ||||||||||||||
}, | ||||||||||||||
dimensions: [ | ||||||||||||||
{ | ||||||||||||||
name: 'step type', | ||||||||||||||
values: ALL_STEPS, | ||||||||||||||
props: (data: WorkflowDiagramStepNodeData) => ({ data }), | ||||||||||||||
}, | ||||||||||||||
], | ||||||||||||||
}, | ||||||||||||||
}, | ||||||||||||||
decorators: [CatalogDecorator, ReactflowDecorator], | ||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
export const AllFailureSelected: CatalogStory< | ||||||||||||||
Story, | ||||||||||||||
typeof WorkflowDiagramStepNodeEditableContent | ||||||||||||||
> = { | ||||||||||||||
args: { | ||||||||||||||
onDelete: fn(), | ||||||||||||||
variant: 'failure', | ||||||||||||||
selected: true, | ||||||||||||||
}, | ||||||||||||||
parameters: { | ||||||||||||||
msw: graphqlMocks, | ||||||||||||||
catalog: { | ||||||||||||||
options: { | ||||||||||||||
elementContainer: { | ||||||||||||||
width: 250, | ||||||||||||||
style: { position: 'relative' }, | ||||||||||||||
className: 'selectable selected', | ||||||||||||||
}, | ||||||||||||||
}, | ||||||||||||||
dimensions: [ | ||||||||||||||
{ | ||||||||||||||
name: 'step type', | ||||||||||||||
values: ALL_STEPS, | ||||||||||||||
props: (data: WorkflowDiagramStepNodeData) => ({ data }), | ||||||||||||||
}, | ||||||||||||||
], | ||||||||||||||
decorators: [ | ||||||||||||||
(Story, { args }) => { | ||||||||||||||
return ( | ||||||||||||||
<div | ||||||||||||||
className={`selectable ${args.state === 'selected' ? 'selected' : args.state === 'hover' ? 'workflow-node-container hover' : ''}`} | ||||||||||||||
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. style: Ternary expression could be simplified using a template literal and conditional classes |
||||||||||||||
> | ||||||||||||||
<Story /> | ||||||||||||||
</div> | ||||||||||||||
); | ||||||||||||||
}, | ||||||||||||||
}, | ||||||||||||||
decorators: [CatalogDecorator, ReactflowDecorator], | ||||||||||||||
CatalogDecorator, | ||||||||||||||
ReactflowDecorator, | ||||||||||||||
], | ||||||||||||||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Missing return statement for success and failure cases in this switch. Could lead to inconsistent styling when those variants are selected.