From 9b26bd8f08a4893bd05777bddc72ab1a90eb49e0 Mon Sep 17 00:00:00 2001 From: "toyamagu2021@gmail.com" Date: Sun, 14 May 2023 13:43:34 +0900 Subject: [PATCH] feat: UI Resubmit [archived] workflows with parameter (#4662) Signed-off-by: toyamagu2021@gmail.com --- .../archived-workflow-details.tsx | 19 +--- .../parameters-input/parameters-input.tsx | 80 ++++++++++++++++ .../services/archived-workflows-service.ts | 5 +- .../app/shared/services/workflows-service.ts | 8 +- ui/src/app/shared/utils.ts | 10 +- ui/src/app/shared/workflow-operations-map.ts | 2 +- .../components/resubmit-workflow-panel.tsx | 94 +++++++++++++++++++ .../components/submit-workflow-panel.tsx | 82 ++-------------- .../workflow-details/workflow-details.tsx | 34 ++++--- ui/src/models/resubmit-opts.ts | 4 + 10 files changed, 229 insertions(+), 109 deletions(-) create mode 100644 ui/src/app/shared/components/parameters-input/parameters-input.tsx create mode 100644 ui/src/app/workflows/components/resubmit-workflow-panel.tsx create mode 100644 ui/src/models/resubmit-opts.ts diff --git a/ui/src/app/archived-workflows/components/archived-workflow-details/archived-workflow-details.tsx b/ui/src/app/archived-workflows/components/archived-workflow-details/archived-workflow-details.tsx index d88a98b6646d..34dc897911d6 100644 --- a/ui/src/app/archived-workflows/components/archived-workflow-details/archived-workflow-details.tsx +++ b/ui/src/app/archived-workflows/components/archived-workflow-details/archived-workflow-details.tsx @@ -17,6 +17,7 @@ import {WorkflowArtifacts} from '../../../workflows/components/workflow-artifact import {ANNOTATION_KEY_POD_NAME_VERSION} from '../../../shared/annotations'; import {getPodName, getTemplateNameFromNode} from '../../../shared/pod-name'; import {getResolvedTemplates} from '../../../shared/template-resolution'; +import {ResubmitWorkflowPanel} from '../../../workflows/components/resubmit-workflow-panel'; import {ArtifactPanel} from '../../../workflows/components/workflow-details/artifact-panel'; import {WorkflowResourcePanel} from '../../../workflows/components/workflow-details/workflow-resource-panel'; import {WorkflowLogsViewer} from '../../../workflows/components/workflow-logs-viewer/workflow-logs-viewer'; @@ -170,6 +171,7 @@ export const ArchivedWorkflowDetails = ({history, location, match}: RouteCompone setSidePanel(null)}> {sidePanel === 'yaml' && } {sidePanel === 'logs' && } + {sidePanel === 'resubmit' && } ); @@ -192,21 +194,6 @@ export const ArchivedWorkflowDetails = ({history, location, match}: RouteCompone }); }; - const resubmitArchivedWorkflow = () => { - if (!confirm('Are you sure you want to resubmit this archived workflow?')) { - return; - } - services.archivedWorkflows - .resubmit(workflow.metadata.uid, workflow.metadata.namespace) - .then(newWorkflow => (document.location.href = uiUrl(`workflows/${newWorkflow.metadata.namespace}/${newWorkflow.metadata.name}`))) - .catch(e => { - ctx.notifications.show({ - content: 'Failed to resubmit archived workflow ' + e, - type: NotificationType.Error - }); - }); - }; - const retryArchivedWorkflow = () => { if (!confirm('Are you sure you want to retry this archived workflow?')) { return; @@ -255,7 +242,7 @@ export const ArchivedWorkflowDetails = ({history, location, match}: RouteCompone title: 'Resubmit', iconClassName: 'fa fa-plus-circle', disabled: false, - action: () => resubmitArchivedWorkflow() + action: () => setSidePanel('resubmit') }, { title: 'Delete', diff --git a/ui/src/app/shared/components/parameters-input/parameters-input.tsx b/ui/src/app/shared/components/parameters-input/parameters-input.tsx new file mode 100644 index 000000000000..cfde6fa07ccd --- /dev/null +++ b/ui/src/app/shared/components/parameters-input/parameters-input.tsx @@ -0,0 +1,80 @@ +import {Select, Tooltip} from 'argo-ui'; +import * as React from 'react'; +import {Parameter} from '../../../../models'; +import {Utils} from '../../utils'; + +interface ParametersInputProps { + parameters: Parameter[]; + onChange?: (parameters: Parameter[]) => void; +} + +export class ParametersInput extends React.Component { + constructor(props: ParametersInputProps) { + super(props); + this.state = {parameters: props.parameters || []}; + } + + public render() { + return ( + <> + {this.props.parameters.map((parameter, index) => ( +
+ + {parameter.description && ( + + + + )} + {(parameter.enum && this.displaySelectFieldForEnumValues(parameter)) || this.displayInputFieldForSingleValue(parameter)} +
+ ))} + + ); + } + + private displaySelectFieldForEnumValues(parameter: Parameter) { + return ( +