github.com/argoproj/argo-cd@v1.8.7/ui/src/app/applications/components/application-parameters/vars-input-field.tsx (about)

     1  import {Checkbox} from 'argo-ui';
     2  import * as React from 'react';
     3  import * as ReactForm from 'react-form';
     4  
     5  import {ArrayInput, NameValueEditor} from '../../../shared/components';
     6  
     7  export interface Var {
     8      name: string;
     9      value: string;
    10      code: boolean;
    11  }
    12  
    13  const VarInputEditor = (item: Var, onChange: (item: Var) => any) => (
    14      <React.Fragment>
    15          {NameValueEditor(item, onChange)}
    16          &nbsp;
    17          <Checkbox checked={!!item.code} onChange={val => onChange({...item, code: val})} />
    18          &nbsp;
    19      </React.Fragment>
    20  );
    21  
    22  export const VarsInputField = ReactForm.FormField((props: {fieldApi: ReactForm.FieldApi}) => {
    23      const {
    24          fieldApi: {getValue, setValue, setTouched}
    25      } = props;
    26      const val = getValue() || [];
    27      return (
    28          <ArrayInput
    29              editor={VarInputEditor}
    30              items={val}
    31              onChange={items => {
    32                  setTouched(true);
    33                  setValue(items);
    34              }}
    35          />
    36      );
    37  });