Skip to content

Commit

Permalink
refactor(ui): heavily simplify WorkflowCreator effect (#13094)
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
  • Loading branch information
agilgur5 committed May 27, 2024
1 parent 4d8f972 commit 0076cc2
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions ui/src/app/workflows/components/workflow-creator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,28 @@ export function WorkflowCreator({namespace, onCreate}: {namespace: string; onCre
}, [namespace]);

useEffect(() => {
switch (stage) {
case 'full-editor':
if (workflowTemplate) {
setWorkflow({
metadata: {
generateName: workflowTemplate.metadata.name + '-',
namespace,
labels: {
'workflows.argoproj.io/workflow-template': workflowTemplate.metadata.name,
'submit-from-ui': 'true'
}
},
spec: {
arguments: workflowTemplate.spec.arguments,
workflowTemplateRef: {
name: workflowTemplate.metadata.name
}
}
});
} else {
setWorkflow(exampleWorkflow(Utils.getNamespaceWithDefault(namespace)));
}
break;
if (stage !== 'full-editor') return;
if (!workflowTemplate) {
setWorkflow(exampleWorkflow(Utils.getNamespaceWithDefault(namespace)));
return;
}

setWorkflow({
metadata: {
generateName: workflowTemplate.metadata.name + '-',
namespace,
labels: {
'workflows.argoproj.io/workflow-template': workflowTemplate.metadata.name,
'submit-from-ui': 'true'
}
},
spec: {
arguments: workflowTemplate.spec.arguments,
workflowTemplateRef: {
name: workflowTemplate.metadata.name
}
}
});
}, [stage]);

useEffect(() => {
Expand Down

0 comments on commit 0076cc2

Please sign in to comment.