In this PR: - Refactored components to clarify their behavior. For example, I renamed the `Workflow` component to `WorkflowVisualizer`. This moved forward the issue #7010. - Create two variants of several workflow-related components: one version for editing and another for viewing. For instance, there is `WorkflowDiagramCanvasEditable.tsx` and `WorkflowDiagramCanvasReadonly.tsx` - Implement the show page for workflow versions. On this page, we display a readonly workflow visualizer. Users can click on nodes and it will expand the right drawer. - I added buttons in the header of the RecordShowPage for workflow versions: users can activate, deactivate or use the currently viewed version as the next draft. **There are many cache desynchronisation and I'll fix them really soon.** ## Demo (Turn sound on) https://github.com/user-attachments/assets/97fafa48-8902-4dab-8b39-f40848bf041e
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import { FloatingIconButton } from '@/ui/input/button/components/FloatingIconButton';
|
|
import { WorkflowDiagramStepNodeBase } from '@/workflow/components/WorkflowDiagramStepNodeBase';
|
|
import { useDeleteOneStep } from '@/workflow/hooks/useDeleteOneStep';
|
|
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
|
import { workflowIdState } from '@/workflow/states/workflowIdState';
|
|
import { WorkflowDiagramStepNodeData } from '@/workflow/types/WorkflowDiagram';
|
|
import { assertWorkflowWithCurrentVersionIsDefined } from '@/workflow/utils/assertWorkflowWithCurrentVersionIsDefined';
|
|
import { useRecoilValue } from 'recoil';
|
|
import { IconTrash } from 'twenty-ui';
|
|
|
|
export const WorkflowDiagramStepNodeEditable = ({
|
|
id,
|
|
data,
|
|
selected,
|
|
}: {
|
|
id: string;
|
|
data: WorkflowDiagramStepNodeData;
|
|
selected?: boolean;
|
|
}) => {
|
|
const workflowId = useRecoilValue(workflowIdState);
|
|
|
|
const workflowWithCurrentVersion = useWorkflowWithCurrentVersion(workflowId);
|
|
assertWorkflowWithCurrentVersionIsDefined(workflowWithCurrentVersion);
|
|
|
|
const { deleteOneStep } = useDeleteOneStep({
|
|
workflow: workflowWithCurrentVersion,
|
|
stepId: id,
|
|
});
|
|
|
|
return (
|
|
<WorkflowDiagramStepNodeBase
|
|
data={data}
|
|
RightFloatingElement={
|
|
selected ? (
|
|
<FloatingIconButton
|
|
Icon={IconTrash}
|
|
onClick={() => {
|
|
return deleteOneStep();
|
|
}}
|
|
/>
|
|
) : undefined
|
|
}
|
|
/>
|
|
);
|
|
};
|