Skip to content

Commit

Permalink
fixed workflow Save as (#1446)
Browse files Browse the repository at this point in the history
* fixed workflow Save as

* fixed lock file

* refactoring __typename removal

* refactored omiting of typename parameter

* es lint fix

---------

Co-authored-by: PeterL <[email protected]>
  • Loading branch information
plehocky and Skyedown authored Oct 10, 2023
1 parent 05f1be4 commit 2cd1dc4
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions packages/frinx-workflow-builder/src/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,10 @@ const Root: VoidFunctionComponent<Props> = ({ onClose }) => {
const tasks = jsonParse<Task[]>(workflowDetail.tasks);
const extendedTasks = tasks?.map(convertTaskToExtendedTask) ?? [];
const description = jsonParse<DescriptionJSON | null>(workflowDetail.description);

// eslint-disable-next-line @typescript-eslint/naming-convention
const { __typename, ...wfDetail } = workflowDetail;
setWorkflow({
...workflowDetail,
...wfDetail,
description: description?.description ?? null,
labels: description?.labels || [],
tasks: extendedTasks,
Expand Down Expand Up @@ -240,13 +241,26 @@ const Root: VoidFunctionComponent<Props> = ({ onClose }) => {
};

const handleWorkflowClone = async (wf: ClientWorkflow, wfName: string) => {
const updatedWorkflow = { ...wf, name: wfName, tasks: JSON.stringify(wf.tasks) };
await updateWorkflow({
const { hasSchedule, id, createdAt, updatedAt, labels, ...wfData } = wf;
const updatedWorkflow = { ...wfData, name: wfName, tasks: JSON.stringify(wf.tasks) };
const result = await updateWorkflow({
updateWorkflowId: wf.id,
input: {
workflow: updatedWorkflow,
},
});
if (result.data) {
onClose();
addToastNotification({
content: 'Workflow cloned',
type: 'success',
});
} else {
addToastNotification({
content: `Workflow clone failed: ${result.error}`,
type: 'error',
});
}
};

const handleWorkflowDelete = async () => {
Expand Down

0 comments on commit 2cd1dc4

Please sign in to comment.