X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/6de571a660401585bc96dd92fd2563e9b64c58c6..2f83fcd45b4b23db2bb5bb4afbe1e863ebd77ec6:/services/workbench2/src/views/run-process-panel/inputs/string-input.tsx

diff --git a/services/workbench2/src/views/run-process-panel/inputs/string-input.tsx b/services/workbench2/src/views/run-process-panel/inputs/string-input.tsx
new file mode 100644
index 0000000000..543100db1f
--- /dev/null
+++ b/services/workbench2/src/views/run-process-panel/inputs/string-input.tsx
@@ -0,0 +1,40 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import React from 'react';
+import { memoize } from 'lodash/fp';
+import { isRequiredInput, StringCommandInputParameter } from 'models/workflow';
+import { Field } from 'redux-form';
+import { require } from 'validators/require';
+import { GenericInputProps, GenericInput } from 'views/run-process-panel/inputs/generic-input';
+import { Input as MaterialInput } from '@material-ui/core';
+
+export interface StringInputProps {
+    input: StringCommandInputParameter;
+}
+export const StringInput = ({ input }: StringInputProps) =>
+    <Field
+        name={input.id}
+        commandInput={input}
+        component={StringInputComponent}
+        validate={getValidation(input)} />;
+
+const getValidation = memoize(
+    (input: StringCommandInputParameter) => ([
+        isRequiredInput(input)
+            ? require
+            : () => undefined,
+    ]));
+
+const StringInputComponent = (props: GenericInputProps) =>
+    <GenericInput
+        component={Input}
+        {...props} />;
+
+const Input = (props: GenericInputProps) =>
+    <MaterialInput
+        fullWidth
+        error={props.meta.touched && !!props.meta.error}
+        disabled={props.commandInput.disabled}
+        {...props.input} />;
\ No newline at end of file
