From a08147758267cc6a07b7e303772d1d010df6e118 Mon Sep 17 00:00:00 2001 From: Tianchu Zhao Date: Sat, 9 Oct 2021 01:44:10 +1100 Subject: [PATCH] feat(ui): resume on selected node. Fixes #5763 (#6885) Signed-off-by: Tianchu Zhao --- .../app/shared/services/workflows-service.ts | 7 ++- ui/src/app/shared/workflow-operations-map.ts | 2 +- .../workflow-details/workflow-details.tsx | 9 +++ .../workflow-node-info/workflow-node-info.tsx | 7 ++- workflow/util/util.go | 1 + workflow/util/util_test.go | 61 +++++++++++++++++++ 6 files changed, 83 insertions(+), 4 deletions(-) diff --git a/ui/src/app/shared/services/workflows-service.ts b/ui/src/app/shared/services/workflows-service.ts index e2a02e77201e..e00a394b7a62 100644 --- a/ui/src/app/shared/services/workflows-service.ts +++ b/ui/src/app/shared/services/workflows-service.ts @@ -112,8 +112,11 @@ export class WorkflowsService { return requests.put(`api/v1/workflows/${namespace}/${name}/suspend`).then(res => res.body as Workflow); } - public resume(name: string, namespace: string) { - return requests.put(`api/v1/workflows/${namespace}/${name}/resume`).then(res => res.body as Workflow); + public resume(name: string, namespace: string, nodeFieldSelector: string) { + return requests + .put(`api/v1/workflows/${namespace}/${name}/resume`) + .send({nodeFieldSelector}) + .then(res => res.body as Workflow); } public stop(name: string, namespace: string) { diff --git a/ui/src/app/shared/workflow-operations-map.ts b/ui/src/app/shared/workflow-operations-map.ts index 28804bb32ac9..665b32600d8f 100644 --- a/ui/src/app/shared/workflow-operations-map.ts +++ b/ui/src/app/shared/workflow-operations-map.ts @@ -48,7 +48,7 @@ export const WorkflowOperationsMap: WorkflowOperations = { title: 'RESUME', iconClassName: 'fa fa-play', disabled: (wf: Workflow) => !Utils.isWorkflowSuspended(wf), - action: (wf: Workflow) => services.workflows.resume(wf.metadata.name, wf.metadata.namespace) + action: (wf: Workflow) => services.workflows.resume(wf.metadata.name, wf.metadata.namespace, null) }, STOP: { title: 'STOP', diff --git a/ui/src/app/workflows/components/workflow-details/workflow-details.tsx b/ui/src/app/workflows/components/workflow-details/workflow-details.tsx index 6d6af66d9ff9..23750cdd783f 100644 --- a/ui/src/app/workflows/components/workflow-details/workflow-details.tsx +++ b/ui/src/app/workflows/components/workflow-details/workflow-details.tsx @@ -224,6 +224,14 @@ export const WorkflowDetails = ({history, location, match}: RouteComponentProps< } }; + const renderResumePopup = () => { + return popup.confirm('Confirm', `Are you sure you want to resume node: ${nodeId}?`).then(yes => { + if (yes) { + services.workflows.resume(workflow.metadata.name, workflow.metadata.namespace, 'id=' + nodeId).catch(setError); + } + }); + }; + const selectedNode = workflow && workflow.status && workflow.status.nodes && workflow.status.nodes[nodeId]; return ( setSidePanel(`events:${nodeId}`)} onShowYaml={() => setSidePanel(`yaml:${nodeId}`)} archived={false} + onResume={() => renderResumePopup()} /> )} diff --git a/ui/src/app/workflows/components/workflow-node-info/workflow-node-info.tsx b/ui/src/app/workflows/components/workflow-node-info/workflow-node-info.tsx index 716f9b594eb5..b5621fa1f3aa 100644 --- a/ui/src/app/workflows/components/workflow-node-info/workflow-node-info.tsx +++ b/ui/src/app/workflows/components/workflow-node-info/workflow-node-info.tsx @@ -61,6 +61,7 @@ interface Props { onShowYaml?: (nodeId: string) => any; onTabSelected?: (tabSelected: string) => void; selectedTabKey?: string; + onResume?: () => void; } const AttributeRow = (attr: {title: string; value: any}) => ( @@ -149,12 +150,16 @@ const WorkflowNodeSummary = (props: Props) => { value: }); } - const showLogs = (x = 'main') => props.onShowContainerLogs(props.node.id, x); return (
{}
+ {props.node.type === 'Suspend' && props.onResume && ( + + )}{' '} {props.node.type !== 'Container' && props.onShowYaml && }{' '} {props.node.type === 'Pod' && props.onShowContainerLogs && (