Skip to content

Commit

Permalink
fix: Allow setting workflow input parameters in UI. Fixes #4234
Browse files Browse the repository at this point in the history
 - Allow workflow input parameters as well as entrypoint parameters.

Signed-off-by: Kenny Trytek <kenneth.g.trytek@gmail.com>
  • Loading branch information
kennytrytek committed Jun 14, 2021
1 parent 2f1d965 commit e1e45ab
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export const ClusterWorkflowTemplateDetails = ({history, location, match}: Route
name={template.metadata.name}
entrypoint={template.spec.entrypoint}
templates={template.spec.templates || []}
workflowParameters={template.spec.arguments.parameters || []}
/>
</SlidingPanel>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export const WorkflowTemplateDetails = ({history, location, match}: RouteCompone
name={name}
entrypoint={template.spec.entrypoint}
templates={template.spec.templates || []}
workflowParameters={template.spec.arguments.parameters || []}
/>
)}
{sidePanel === 'share' && <WidgetGallery namespace={namespace} label={'workflows.argoproj.io/workflow-template=' + name} />}
Expand Down
19 changes: 14 additions & 5 deletions ui/src/app/workflows/components/submit-workflow-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface Props {
name: string;
entrypoint: string;
templates: Template[];
workflowParameters: Parameter[];
}

interface State {
Expand All @@ -25,15 +26,23 @@ interface State {
error?: Error;
}

const workflowEntrypoint = '<default>';

export class SubmitWorkflowPanel extends React.Component<Props, State> {
constructor(props: any) {
super(props);
const defaultTemplate: Template = {
name: workflowEntrypoint,
inputs: {
parameters: this.props.workflowParameters
}
};
const state = {
entrypoint: this.props.entrypoint || (this.props.templates.length > 0 && this.props.templates[0].name),
entrypoint: workflowEntrypoint,
entrypoints: this.props.templates.map(t => t.name),
selectedTemplate: this.props.templates.length > 0 && this.props.templates[0],
parameters: (this.props.templates.length > 0 && this.props.templates[0].inputs.parameters) || [],
templates: this.props.templates,
selectedTemplate: defaultTemplate,
parameters: this.props.workflowParameters || [],
templates: [defaultTemplate].concat(this.props.templates),
labels: ['submit-from-ui=true']
};
this.state = state;
Expand Down Expand Up @@ -150,7 +159,7 @@ export class SubmitWorkflowPanel extends React.Component<Props, State> {
private submit() {
services.workflows
.submit(this.props.kind, this.props.name, this.props.namespace, {
entryPoint: this.state.entrypoint,
entryPoint: this.state.entrypoint === workflowEntrypoint ? null : this.state.entrypoint,
parameters: this.state.parameters.map(p => p.name + '=' + p.value),
labels: this.state.labels.join(',')
})
Expand Down
1 change: 1 addition & 0 deletions ui/src/app/workflows/components/workflow-creator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const WorkflowCreator = ({namespace, onCreate}: {namespace: string; onCre
name={workflowTemplate.metadata.name}
entrypoint={workflowTemplate.spec.entrypoint}
templates={workflowTemplate.spec.templates || []}
workflowParameters={workflowTemplate.spec.arguments.parameters || []}
/>
<a onClick={() => setStage('full-editor')}>
Edit using full workflow options <i className='fa fa-caret-right' />
Expand Down

0 comments on commit e1e45ab

Please sign in to comment.