Skip to content

Commit 994ff74

Browse files
authored
fix(UI): use default params on template submit form (argoproj#6858)
Signed-off-by: Kenny Trytek <[email protected]>
1 parent 7677cbc commit 994ff74

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

ui/src/app/workflows/components/submit-workflow-panel.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export class SubmitWorkflowPanel extends React.Component<Props, State> {
120120
return (
121121
<Select
122122
key={parameter.name}
123-
value={parameter.value}
123+
value={this.getValue(parameter)}
124124
options={parameter.enum.map(value => ({
125125
value,
126126
title: value
@@ -129,7 +129,7 @@ export class SubmitWorkflowPanel extends React.Component<Props, State> {
129129
this.setState({
130130
parameters: this.state.parameters.map(p => ({
131131
name: p.name,
132-
value: p.name === parameter.name ? event.value : p.value,
132+
value: p.name === parameter.name ? event.value : this.getValue(p),
133133
enum: p.enum
134134
}))
135135
});
@@ -142,12 +142,12 @@ export class SubmitWorkflowPanel extends React.Component<Props, State> {
142142
return (
143143
<input
144144
className='argo-field'
145-
value={parameter.value}
145+
value={this.getValue(parameter)}
146146
onChange={event => {
147147
this.setState({
148148
parameters: this.state.parameters.map(p => ({
149149
name: p.name,
150-
value: p.name === parameter.name ? event.target.value : p.value,
150+
value: p.name === parameter.name ? event.target.value : this.getValue(p),
151151
enum: p.enum
152152
}))
153153
});
@@ -156,11 +156,19 @@ export class SubmitWorkflowPanel extends React.Component<Props, State> {
156156
);
157157
}
158158

159+
private getValue(p: Parameter) {
160+
if (p.value === undefined) {
161+
return p.default;
162+
} else {
163+
return p.value;
164+
}
165+
}
166+
159167
private submit() {
160168
services.workflows
161169
.submit(this.props.kind, this.props.name, this.props.namespace, {
162170
entryPoint: this.state.entrypoint === workflowEntrypoint ? null : this.state.entrypoint,
163-
parameters: this.state.parameters.map(p => p.name + '=' + p.value),
171+
parameters: this.state.parameters.filter(p => this.getValue(p) !== undefined).map(p => p.name + '=' + this.getValue(p)),
164172
labels: this.state.labels.join(',')
165173
})
166174
.then((submitted: Workflow) => (document.location.href = uiUrl(`workflows/${submitted.metadata.namespace}/${submitted.metadata.name}`)))

ui/src/models/workflows.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export interface Parameter {
8787
/**
8888
* Default is the default value to use for an input parameter if a value was not supplied
8989
*/
90-
_default?: string;
90+
default?: string;
9191
/**
9292
* Name is the parameter name
9393
*/

0 commit comments

Comments
 (0)