CR changes
authorPawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>
Tue, 24 Jul 2018 09:22:32 +0000 (11:22 +0200)
committerPawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>
Tue, 24 Jul 2018 09:22:32 +0000 (11:22 +0200)
Feature #13781

Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>

package.json
src/validators/create-project/create-project-validator.tsx
src/validators/max-length.tsx
src/validators/require.tsx
src/views-components/dialog-create/dialog-project-create.tsx

index 06fa893f97abe1dbcd18523df1deebf0d2660a3e..fa4bd309df7ad1b6c873128d70192e0c9b97fc88 100644 (file)
@@ -6,7 +6,7 @@
     "@material-ui/core": "1.4.0",
     "@material-ui/icons": "1.1.0",
     "@types/lodash": "4.14.112",
-    "@types/redux-form": "^7.4.1",
+    "@types/redux-form": "7.4.1",
     "axios": "0.18.0",
     "classnames": "2.2.6",
     "lodash": "4.17.10",
     "@types/react-router-dom": "4.2.7",
     "@types/react-router-redux": "5.0.15",
     "@types/redux-devtools": "3.0.44",
-    "@types/redux-form": "^7.4.1",
+    "@types/redux-form": "7.4.1",
     "axios-mock-adapter": "1.15.0",
     "enzyme": "3.3.0",
     "enzyme-adapter-react-16": "1.1.1",
     "jest-localstorage-mock": "2.2.0",
     "redux-devtools": "3.4.1",
-    "redux-form": "^7.4.2",
+    "redux-form": "7.4.2",
     "typescript": "2.9.2"
   },
   "moduleNameMapper": {
index 5765f727cde3460c1f72368b9371f0597dd5556c..928efdd2205e439c82fbd936e0e476e13f046139 100644 (file)
@@ -2,8 +2,8 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import require from '../require';
-import maxLength from '../max-length';
+import { require } from '../require';
+import { maxLength } from '../max-length';
 
-export const NAME = [require, maxLength(255)];
-export const DESCRIPTION = [maxLength(255)];
+export const PROJECT_NAME_VALIDATION = [require, maxLength(255)];
+export const PROJECT_DESCRIPTION_VALIDATION = [maxLength(255)];
index 9b6d248b98ad092fecec84d52746cd183b27901c..922e3e52706093929f04a44641e3276187cdbf78 100644 (file)
@@ -11,14 +11,12 @@ interface MaxLengthProps {
 }
 
 // TODO types for maxLength
-const maxLength: any = (maxLengthValue = DEFAULT_MAX_VALUE, errorMessage = ERROR_MESSAGE) => {
+export const maxLength: any = (maxLengthValue = DEFAULT_MAX_VALUE, errorMessage = ERROR_MESSAGE) => {
     return (value: string) => {
         if (value) {
-            return  value && value && value.length <= maxLengthValue ? undefined : `${errorMessage || ERROR_MESSAGE} ${maxLengthValue}`;
+            return  value && value.length <= maxLengthValue ? undefined : `${errorMessage || ERROR_MESSAGE} ${maxLengthValue}`;
         }
 
         return undefined;
     };
 };
-
-export default maxLength;
index 8ac3401c44860d7b6a34e62f16f42f0f335a98ef..f636850d5a9f0a13acfe909a3346cd3da2f3882b 100644 (file)
@@ -4,13 +4,11 @@
 
 export const ERROR_MESSAGE = 'This field is required.';
 
-interface RequireProps {
+interface RequiredProps {
     value: string;
 }
 
 // TODO types for require
-const require: any = (value: string, errorMessage = ERROR_MESSAGE) => {
-    return value && value.toString().length > 0 ? undefined : ERROR_MESSAGE;
+export const require: any = (value: string) => {
+    return value && value.length > 0 ? undefined : ERROR_MESSAGE;
 };
-
-export default require;
index e11c67af75ecfca9ea49a08a7c9d7d558d617e81..592efc1a388a65f63a3471a2edfaa8a8eb674929 100644 (file)
@@ -12,7 +12,7 @@ import DialogContent from '@material-ui/core/DialogContent';
 import DialogTitle from '@material-ui/core/DialogTitle';
 import { Button, StyleRulesCallback, WithStyles, withStyles, CircularProgress } from '@material-ui/core';
 
-import { NAME, DESCRIPTION } from '../../validators/create-project/create-project-validator';
+import { PROJECT_NAME_VALIDATION, PROJECT_DESCRIPTION_VALIDATION } from '../../validators/create-project/create-project-validator';
 
 type CssRules = "button" | "lastButton" | "formContainer" | "textField" | "dialog" | "dialogTitle" | "createProgress" | "dialogActions";
 
@@ -85,13 +85,13 @@ export const DialogProjectCreate = compose(
                                 <Field name="name"
                                        component={this.renderTextField}
                                        floatinglabeltext="Project Name"
-                                       validate={NAME}
+                                       validate={PROJECT_NAME_VALIDATION}
                                        className={classes.textField}
                                        label="Project Name"/>
                                 <Field name="description"
                                        component={this.renderTextField}
                                        floatinglabeltext="Description - optional"
-                                       validate={DESCRIPTION}
+                                       validate={PROJECT_DESCRIPTION_VALIDATION}
                                        className={classes.textField}
                                        label="Description - optional"/>
                             </DialogContent>