Files
twenty/packages/twenty-front/src/modules/workflow/components/WorkflowDiagramStepNodeBase.tsx
T
Thomas Trompette 5ec6cb0e6f Make workflow step name editable (#8677)
- Use TextInput in header title
- add onTitleChange prop
- rename field name instead of label

To fix :
- padding right on title comes from current TextInput component. It
needs to be refactored


https://github.com/user-attachments/assets/535cd6d3-866b-4a61-9c5d-cdbe7710396a
2024-11-22 15:25:01 +00:00

110 lines
3.1 KiB
TypeScript

import { WorkflowDiagramBaseStepNode } from '@/workflow/components/WorkflowDiagramBaseStepNode';
import { WorkflowDiagramStepNodeData } from '@/workflow/types/WorkflowDiagram';
import { assertUnreachable } from '@/workflow/utils/assertUnreachable';
import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import {
IconAddressBook,
IconCode,
IconHandMove,
IconMail,
IconPlaylistAdd,
} from 'twenty-ui';
const StyledStepNodeLabelIconContainer = styled.div`
align-items: center;
background: ${({ theme }) => theme.background.transparent.light};
border-radius: ${({ theme }) => theme.spacing(1)};
display: flex;
justify-content: center;
padding: ${({ theme }) => theme.spacing(1)};
`;
export const WorkflowDiagramStepNodeBase = ({
data,
RightFloatingElement,
}: {
data: WorkflowDiagramStepNodeData;
RightFloatingElement?: React.ReactNode;
}) => {
const theme = useTheme();
const renderStepIcon = () => {
switch (data.nodeType) {
case 'trigger': {
switch (data.triggerType) {
case 'DATABASE_EVENT': {
return (
<StyledStepNodeLabelIconContainer>
<IconPlaylistAdd
size={theme.icon.size.lg}
color={theme.font.color.tertiary}
/>
</StyledStepNodeLabelIconContainer>
);
}
case 'MANUAL': {
return (
<StyledStepNodeLabelIconContainer>
<IconHandMove
size={theme.icon.size.lg}
color={theme.font.color.tertiary}
/>
</StyledStepNodeLabelIconContainer>
);
}
}
return assertUnreachable(data.triggerType);
}
case 'action': {
switch (data.actionType) {
case 'CODE': {
return (
<StyledStepNodeLabelIconContainer>
<IconCode
size={theme.icon.size.lg}
color={theme.color.orange}
/>
</StyledStepNodeLabelIconContainer>
);
}
case 'SEND_EMAIL': {
return (
<StyledStepNodeLabelIconContainer>
<IconMail size={theme.icon.size.lg} color={theme.color.blue} />
</StyledStepNodeLabelIconContainer>
);
}
case 'RECORD_CRUD.CREATE': {
return (
<StyledStepNodeLabelIconContainer>
<IconAddressBook
size={theme.icon.size.lg}
color={theme.font.color.tertiary}
stroke={theme.icon.stroke.sm}
/>
</StyledStepNodeLabelIconContainer>
);
}
case 'RECORD_CRUD.DELETE':
case 'RECORD_CRUD.UPDATE': {
return null;
}
}
}
}
return assertUnreachable(data);
};
return (
<WorkflowDiagramBaseStepNode
name={data.name}
nodeType={data.nodeType}
Icon={renderStepIcon()}
RightFloatingElement={RightFloatingElement}
/>
);
};