From: Michal Klobukowski Date: Tue, 2 Oct 2018 09:01:17 +0000 (+0200) Subject: Improve validation X-Git-Tag: 1.3.0~72^2~6 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/424f5418a6fd9f49baa1cc79bf0b51f9ab65ac58 Improve validation Feature #13863 Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski --- diff --git a/src/components/text-field/text-field.tsx b/src/components/text-field/text-field.tsx index 076889ea..4d8c012f 100644 --- a/src/components/text-field/text-field.tsx +++ b/src/components/text-field/text-field.tsx @@ -16,7 +16,7 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ }, }); -export const TextField = withStyles(styles)((props: WrappedFieldProps & WithStyles & { label?: string, autoFocus?: boolean }) => +export const TextField = withStyles(styles)((props: WrappedFieldProps & WithStyles & { label?: string, autoFocus?: boolean, required?: boolean }) => ); diff --git a/src/index.tsx b/src/index.tsx index 2f8e73c4..71d10fe2 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -113,10 +113,18 @@ const initListener = (history: History, store: RootStore, services: ServiceRepos initWebSocket(config, services.authService, store); await store.dispatch(loadWorkbench()); addRouteChangeHandlers(history, store); + } }; }; +const createSampleWorkflow = ({workflowService}:ServiceRepository) => { + workflowService.create({ + name: 'Primitive values collector', + description: 'Workflow for collecting primitive values', + definition: "cwlVersion: v1.0\n$graph:\n- class: CommandLineTool\n requirements:\n - listing:\n - entryname: input_collector.log\n entry: |\n \"flag\":\n $(inputs.example_flag)\n \"string\":\n $(inputs.example_string)\n \"int\":\n $(inputs.example_int)\n \"long\":\n $(inputs.example_long)\n \"float\":\n $(inputs.example_float)\n \"double\":\n $(inputs.example_double)\n class: InitialWorkDirRequirement\n inputs:\n - type: double\n id: '#input_collector.cwl/example_double'\n - type: boolean\n id: '#input_collector.cwl/example_flag'\n - type: float\n id: '#input_collector.cwl/example_float'\n - type: int\n id: '#input_collector.cwl/example_int'\n - type: long\n id: '#input_collector.cwl/example_long'\n - type: string\n id: '#input_collector.cwl/example_string'\n outputs:\n - type: File\n outputBinding:\n glob: '*'\n id: '#input_collector.cwl/output'\n baseCommand: [echo]\n id: '#input_collector.cwl'\n- class: Workflow\n doc: Workflw for collecting primitive values\n inputs:\n - type: double\n label: Double value\n doc: This should allow for entering a decimal number (64-bit).\n id: '#main/example_double'\n default: 0.3333333333333333\n - type: boolean\n label: Boolean Flag\n doc: This should render as in checkbox.\n id: '#main/example_flag'\n default: true\n - type: float\n label: Float value\n doc: This should allow for entering a decimal number (32-bit).\n id: '#main/example_float'\n default: 0.15625\n - type: int\n label: Integer Number\n doc: This should allow for entering a number (32-bit signed).\n id: '#main/example_int'\n default: 2147483647\n - type: long\n label: Long Number\n doc: This should allow for entering a number (64-bit signed).\n id: '#main/example_long'\n default: 9223372036854775807\n - type: string\n label: Freetext\n doc: This should allow for entering an arbitrary char sequence.\n id: '#main/example_string'\n default: This is a string\n outputs:\n - type: File\n outputSource: '#main/input_collector/output'\n id: '#main/log_file'\n steps:\n - run: '#input_collector.cwl'\n in:\n - source: '#main/example_double'\n id: '#main/input_collector/example_double'\n - source: '#main/example_flag'\n id: '#main/input_collector/example_flag'\n - source: '#main/example_float'\n id: '#main/input_collector/example_float'\n - source: '#main/example_int'\n id: '#main/input_collector/example_int'\n - source: '#main/example_long'\n id: '#main/input_collector/example_long'\n - source: '#main/example_string'\n id: '#main/input_collector/example_string'\n out: ['#main/input_collector/output']\n id: '#main/input_collector'\n id: '#main'\n", + }); +}; const createSampleProcess = ({ containerRequestService }: ServiceRepository) => { containerRequestService.create({ diff --git a/src/views/run-process-panel/inputs/file-input.tsx b/src/views/run-process-panel/inputs/file-input.tsx index b018584a..7c4402fe 100644 --- a/src/views/run-process-panel/inputs/file-input.tsx +++ b/src/views/run-process-panel/inputs/file-input.tsx @@ -38,5 +38,5 @@ export const FileInput = ({ input }: FileInputProps) => const FileInputComponent = (props: GenericInputProps) => - } + } {...props} />; diff --git a/src/views/run-process-panel/inputs/float-input.tsx b/src/views/run-process-panel/inputs/float-input.tsx index 31a7ca59..aeaf6cdd 100644 --- a/src/views/run-process-panel/inputs/float-input.tsx +++ b/src/views/run-process-panel/inputs/float-input.tsx @@ -51,4 +51,4 @@ class FloatInputComponent extends React.Component { } const Input = (props: GenericInputProps) => - ; + ; diff --git a/src/views/run-process-panel/inputs/generic-input.tsx b/src/views/run-process-panel/inputs/generic-input.tsx index 4ed2654e..a449c657 100644 --- a/src/views/run-process-panel/inputs/generic-input.tsx +++ b/src/views/run-process-panel/inputs/generic-input.tsx @@ -22,9 +22,7 @@ export const GenericInput = ({ component: Component, ...props }: GenericInputCon error={props.meta.touched && !!props.meta.error}> {getInputLabel(props.commandInput)} - - - + { props.meta.touched && props.meta.error diff --git a/src/views/run-process-panel/inputs/int-input.tsx b/src/views/run-process-panel/inputs/int-input.tsx index 1e4c17cb..193de26c 100644 --- a/src/views/run-process-panel/inputs/int-input.tsx +++ b/src/views/run-process-panel/inputs/int-input.tsx @@ -32,5 +32,5 @@ const IntInputComponent = (props: GenericInputProps) => const Input = (props: GenericInputProps) => - ; + ; diff --git a/src/views/run-process-panel/inputs/string-input.tsx b/src/views/run-process-panel/inputs/string-input.tsx index dc7075cf..7f02e1d3 100644 --- a/src/views/run-process-panel/inputs/string-input.tsx +++ b/src/views/run-process-panel/inputs/string-input.tsx @@ -29,4 +29,4 @@ const StringInputComponent = (props: GenericInputProps) => {...props} />; const Input = (props: GenericInputProps) => - ; \ No newline at end of file + ; \ No newline at end of file diff --git a/src/views/run-process-panel/run-process-basic-form.tsx b/src/views/run-process-panel/run-process-basic-form.tsx index ef4a9cc7..2739824e 100644 --- a/src/views/run-process-panel/run-process-basic-form.tsx +++ b/src/views/run-process-panel/run-process-basic-form.tsx @@ -6,6 +6,7 @@ import * as React from 'react'; import { reduxForm, Field } from 'redux-form'; import { Grid } from '@material-ui/core'; import { TextField } from '~/components/text-field/text-field'; +import { PROCESS_NAME_VALIDATION } from '~/validators/validators'; export const RUN_PROCESS_BASIC_FORM = 'runProcessBasicForm'; @@ -18,12 +19,14 @@ export const RunProcessBasicForm = form: RUN_PROCESS_BASIC_FORM })(() =>
- + + label="Enter a new name for run process" + required + validate={PROCESS_NAME_VALIDATION} /> - + {props.inputs.map(input => )} diff --git a/src/views/run-process-panel/run-process-second-step.tsx b/src/views/run-process-panel/run-process-second-step.tsx index 89092c8c..d66576c2 100644 --- a/src/views/run-process-panel/run-process-second-step.tsx +++ b/src/views/run-process-panel/run-process-second-step.tsx @@ -24,8 +24,8 @@ export interface RunProcessSecondStepFormActionProps { const mapStateToProps = (state: RootState): RunProcessSecondStepFormDataProps => ({ inputs: state.runProcessPanel.inputs, - valid: isValid(RUN_PROCESS_BASIC_FORM)(state.form) && - isValid(RUN_PROCESS_INPUTS_FORM)(state.form), + valid: isValid(RUN_PROCESS_BASIC_FORM)(state) && + isValid(RUN_PROCESS_INPUTS_FORM)(state), }); export type RunProcessSecondStepFormProps = RunProcessSecondStepFormDataProps & RunProcessSecondStepFormActionProps;