X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/7a2f0082071947bfec27ed4f2a16250e1d611d21..91d197b6b7066c3f37b3dbd54b2b3416e6f21bec:/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 5da54742..c8ef8850 100644
--- a/src/views/run-process-panel/inputs/boolean-input.tsx
+++ b/src/views/run-process-panel/inputs/boolean-input.tsx
@@ -2,8 +2,9 @@
//
// SPDX-License-Identifier: AGPL-3.0
-import * as React from 'react';
-import { BooleanCommandInputParameter } from '~/models/workflow';
+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';
@@ -16,17 +17,23 @@ export const BooleanInput = ({ input }: BooleanInputProps) =>
name={input.id}
commandInput={input}
component={BooleanInputComponent}
- normalize={(value, prevValue) => !prevValue}
+ normalize={normalize}
/>;
+const normalize = (_: any, prevValue: boolean) => !prevValue;
+
const BooleanInputComponent = (props: GenericInputProps) =>
;
-const Input = (props: GenericInputProps) =>
+const Input = ({ input, commandInput }: GenericInputProps) =>
props.input.onChange(props.input.value)}
- disabled={props.commandInput.disabled} />;
\ No newline at end of file
+ checked={input.value}
+ onChange={handleChange(input.onChange, input.value)}
+ disabled={commandInput.disabled} />;
+
+const handleChange = memoize(
+ (onChange: (value: string) => void, value: string) => () => onChange(value)
+);