X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/5c3b7d928914321c16aae5549b4ae2a6278dfa05..bf6ffb898a38a806ea0dd98daca7b3801923b62f:/src/views/run-process-panel/inputs/boolean-input.tsx diff --git a/src/views/run-process-panel/inputs/boolean-input.tsx b/src/views/run-process-panel/inputs/boolean-input.tsx index 2d0d8c66..c8ef8850 100644 --- a/src/views/run-process-panel/inputs/boolean-input.tsx +++ b/src/views/run-process-panel/inputs/boolean-input.tsx @@ -2,11 +2,12 @@ // // SPDX-License-Identifier: AGPL-3.0 -import * as React from 'react'; -import { BooleanCommandInputParameter, getInputLabel, isRequiredInput } from '~/models/workflow'; -import { Field, WrappedFieldProps } from 'redux-form'; -import { TextField } from '~/components/text-field/text-field'; -import { FormGroup, FormLabel, FormHelperText, Switch } from '@material-ui/core'; +import React from 'react'; +import { memoize } from 'lodash/fp'; +import { BooleanCommandInputParameter } from 'models/workflow'; +import { Field } from 'redux-form'; +import { Switch } from '@material-ui/core'; +import { GenericInputProps, GenericInput } from './generic-input'; export interface BooleanInputProps { input: BooleanCommandInputParameter; @@ -14,16 +15,25 @@ export interface BooleanInputProps { export const BooleanInput = ({ input }: BooleanInputProps) => !prevValue} + normalize={normalize} />; -const BooleanInputComponent = (props: WrappedFieldProps & { label?: string }) => - - {props.label} - props.input.onChange(props.input.value)} /> - ; \ No newline at end of file +const normalize = (_: any, prevValue: boolean) => !prevValue; + +const BooleanInputComponent = (props: GenericInputProps) => + ; + +const Input = ({ input, commandInput }: GenericInputProps) => + ; + +const handleChange = memoize( + (onChange: (value: string) => void, value: string) => () => onChange(value) +);