duplicatedName flag renamed on isUniqName
authorPawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>
Tue, 17 Jul 2018 09:28:22 +0000 (11:28 +0200)
committerPawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>
Tue, 17 Jul 2018 09:28:22 +0000 (11:28 +0200)
Feature #13781

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

src/utils/dialog-validator.tsx
src/views-components/dialog-create/dialog-project-create.tsx

index 848acec1b1a55e5e723c01e13394e1313ed7ec6f..b264f963d0d72067088e91d1635240130972c5ca 100644 (file)
@@ -10,7 +10,7 @@ type ValidatorProps = {
   onChange: (isValid: boolean | string) => void;
   render: (hasError: boolean) => React.ReactElement<any>;
   isRequired: boolean;
-  duplicatedName?: string;
+  isUniqName?: boolean;
 };
 
 interface ValidatorState {
@@ -41,14 +41,14 @@ class Validator extends React.Component<ValidatorProps & WithStyles<CssRules>> {
   }
 
   render() {
-    const { classes, isRequired, value, duplicatedName } = this.props;
+    const { classes, isRequired, value, isUniqName } = this.props;
     const { isLengthValid } = this.state;
 
     return (
       <span>
         {this.props.render(!isLengthValid && (isRequired || (!isRequired && value.length > 0)))}
         {!isLengthValid ? <span className={classes.formInputError}>This field should have max 255 characters.</span> : null}
-        {duplicatedName ? <span className={classes.formInputError}>Project with this name already exists</span> : null}
+        {isUniqName ? <span className={classes.formInputError}>Project with this name already exists</span> : null}
       </span>
     );
   }
index efaa02e84bc2ba478213db3f85ed0221b98e9dda..0388e05bb81e66176bbc42fd6a2dfdbbf763d956 100644 (file)
@@ -25,7 +25,7 @@ interface DialogState {
   description: string;
   isNameValid: boolean;
   isDescriptionValid: boolean;
-  duplicatedName: string;
+  isUniqName: boolean;
 }
 
 class DialogProjectCreate extends React.Component<ProjectCreateProps & WithStyles<CssRules>> {
@@ -34,19 +34,19 @@ class DialogProjectCreate extends React.Component<ProjectCreateProps & WithStyle
     description: '',
     isNameValid: false,
     isDescriptionValid: true,
-    duplicatedName: ''
+    isUniqName: false
   };
 
   componentWillReceiveProps(nextProps: ProjectCreateProps) {
     const { error } = nextProps;
 
     if (this.props.error !== error) {
-      this.setState({ duplicatedName: error });
+      this.setState({ isUniqName: error });
     }
   }
 
   render() {
-    const { name, description, isNameValid, isDescriptionValid, duplicatedName } = this.state;
+    const { name, description, isNameValid, isDescriptionValid, isUniqName } = this.state;
     const { classes, open, handleClose, pending } = this.props;
 
     return (
@@ -60,7 +60,7 @@ class DialogProjectCreate extends React.Component<ProjectCreateProps & WithStyle
               value={name}
               onChange={e => this.isNameValid(e)}
               isRequired={true}
-              duplicatedName={duplicatedName}
+              isUniqName={isUniqName}
               render={hasError =>
                 <TextField
                   margin="dense"
@@ -68,7 +68,7 @@ class DialogProjectCreate extends React.Component<ProjectCreateProps & WithStyle
                   id="name"
                   onChange={e => this.handleProjectName(e)}
                   label="Project name"
-                  error={hasError || !!duplicatedName}
+                  error={hasError || isUniqName}
                   fullWidth />} />
             <Validator
               value={description}
@@ -110,7 +110,7 @@ class DialogProjectCreate extends React.Component<ProjectCreateProps & WithStyle
   handleProjectName(e: any) {
     this.setState({
       name: e.target.value,
-      duplicatedName: ''
+      isUniqName: ''
     });
   }