1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { memoize } from 'lodash/fp';
7 import { BooleanCommandInputParameter } from 'models/workflow';
8 import { Field } from 'redux-form';
9 import { Switch } from '@material-ui/core';
10 import { GenericInputProps, GenericInput } from './generic-input';
12 export interface BooleanInputProps {
13 input: BooleanCommandInputParameter;
15 export const BooleanInput = ({ input }: BooleanInputProps) =>
19 component={BooleanInputComponent}
23 const normalize = (_: any, prevValue: boolean) => !prevValue;
25 const BooleanInputComponent = (props: GenericInputProps) =>
30 const Input = ({ input, commandInput }: GenericInputProps) =>
34 onChange={handleChange(input.onChange, input.value)}
35 disabled={commandInput.disabled} />;
37 const handleChange = memoize(
38 (onChange: (value: string) => void, value: string) => () => onChange(value)