[ARVADOS-WORKBENCH2] created: 1.2.0-698-gb066e77

Git user git at public.curoverse.com
Sun Oct 21 15:23:59 EDT 2018


        at  b066e77c51858c0534c8fdedf6d45a141be85fb9 (commit)


commit b066e77c51858c0534c8fdedf6d45a141be85fb9
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Sun Oct 21 21:23:47 2018 +0200

    Update process float input to use shared FloatInput
    
    Feature #13862
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/views/run-process-panel/inputs/float-input.tsx b/src/views/run-process-panel/inputs/float-input.tsx
index aeaf6cd..9558fd8 100644
--- a/src/views/run-process-panel/inputs/float-input.tsx
+++ b/src/views/run-process-panel/inputs/float-input.tsx
@@ -6,9 +6,8 @@ import * as React from 'react';
 import { FloatCommandInputParameter, isRequiredInput } from '~/models/workflow';
 import { Field } from 'redux-form';
 import { isNumber } from '~/validators/is-number';
-import { GenericInput } from '~/views/run-process-panel/inputs/generic-input';
-import { Input as MaterialInput } from '@material-ui/core';
-import { GenericInputProps } from './generic-input';
+import { GenericInputProps, GenericInput } from './generic-input';
+import { FloatInput as FloatInputComponent } from '~/components/float-input/float-input';
 export interface FloatInputProps {
     input: FloatCommandInputParameter;
 }
@@ -16,7 +15,7 @@ export const FloatInput = ({ input }: FloatInputProps) =>
     <Field
         name={input.id}
         commandInput={input}
-        component={FloatInputComponent}
+        component={Input}
         parse={parseFloat}
         format={value => isNaN(value) ? '' : JSON.stringify(value)}
         validate={[
@@ -24,31 +23,11 @@ export const FloatInput = ({ input }: FloatInputProps) =>
                 ? isNumber
                 : () => undefined,]} />;
 
-class FloatInputComponent extends React.Component<GenericInputProps> {
-    state = {
-        endsWithDecimalSeparator: false,
-    };
-
-    handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
-        const [base, fraction] = event.target.value.split('.');
-        this.setState({ endsWithDecimalSeparator: fraction === '' });
-        this.props.input.onChange(event);
-    }
+const Input = (props: GenericInputProps) =>
+    <GenericInput
+        component={InputComponent}
+        {...props} />;
 
-    render() {
-        const props = {
-            ...this.props,
-            input: {
-                ...this.props.input,
-                value: this.props.input.value + (this.state.endsWithDecimalSeparator ? '.' : ''),
-                onChange: this.handleChange,
-            },
-        };
-        return <GenericInput
-            component={Input}
-            {...props} />;
-    }
-}
+const InputComponent = ({ input, meta }: GenericInputProps) =>
+    <FloatInputComponent fullWidth {...input} error={meta.touched && !!meta.error} />;
 
-const Input = (props: GenericInputProps) =>
-    <MaterialInput fullWidth {...props.input} error={props.meta.touched && !!props.meta.error} />;

commit 02109725d788c1092c0b4023cee41ea901ed1a58
Merge: b407fff 4ae10b1
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Sun Oct 21 20:56:01 2018 +0200

    Merge branch 'master' of git.curoverse.com:arvados-workbench2 into 13862-number-array-input
    
    refs #2
    13862
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>


commit b407fff9a10136ff62e5b3e5bbaa74c8656aaf9d
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Sun Oct 21 20:55:46 2018 +0200

    Extract float-input component
    
    Feature #13862
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/components/float-input/float-input.tsx b/src/components/float-input/float-input.tsx
new file mode 100644
index 0000000..b032319
--- /dev/null
+++ b/src/components/float-input/float-input.tsx
@@ -0,0 +1,29 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { Input } from '@material-ui/core';
+import { InputProps } from '@material-ui/core/Input';
+
+export class FloatInput extends React.Component<InputProps> {
+    state = {
+        endsWithDecimalSeparator: false,
+    };
+
+    handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
+        const { onChange = () => { return; } } = this.props;
+        const [, fraction] = event.target.value.split('.');
+        this.setState({ endsWithDecimalSeparator: fraction === '' });
+        onChange(event);
+    }
+
+    render() {
+        const props = {
+            ...this.props,
+            value: this.props.value + (this.state.endsWithDecimalSeparator ? '.' : ''),
+            onChange: this.handleChange,
+        };
+        return <Input {...props} />;
+    }
+}

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list