diff --git a/ui/src/app/shared/components/parameters-input/parameters-input.tsx b/ui/src/app/shared/components/parameters-input/parameters-input.tsx index cfde6fa07ccd..593879198cb7 100644 --- a/ui/src/app/shared/components/parameters-input/parameters-input.tsx +++ b/ui/src/app/shared/components/parameters-input/parameters-input.tsx @@ -1,38 +1,24 @@ import {Select, Tooltip} from 'argo-ui'; -import * as React from 'react'; +import React from 'react'; import {Parameter} from '../../../../models'; import {Utils} from '../../utils'; interface ParametersInputProps { parameters: Parameter[]; - onChange?: (parameters: Parameter[]) => void; + onChange: (parameters: Parameter[]) => void; } -export class ParametersInput extends React.Component { - constructor(props: ParametersInputProps) { - super(props); - this.state = {parameters: props.parameters || []}; +export function ParametersInput(props: ParametersInputProps) { + function onParameterChange(parameter: Parameter, value: string) { + const newParameters: Parameter[] = props.parameters.map(p => ({ + name: p.name, + value: p.name === parameter.name ? value : Utils.getValueFromParameter(p), + enum: p.enum + })); + props.onChange(newParameters); } - public render() { - return ( - <> - {this.props.parameters.map((parameter, index) => ( -
- - {parameter.description && ( - - - - )} - {(parameter.enum && this.displaySelectFieldForEnumValues(parameter)) || this.displayInputFieldForSingleValue(parameter)} -
- ))} - - ); - } - - private displaySelectFieldForEnumValues(parameter: Parameter) { + function displaySelectFieldForEnumValues(parameter: Parameter) { return (