mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	fix: update validateProjectId
This commit is contained in:
		
							parent
							
								
									8c7acdc43d
								
							
						
					
					
						commit
						52fddb2069
					
				| @ -26,7 +26,6 @@ const CreateProject = () => { | ||||
|         clearErrors, | ||||
|         validateIdUniqueness, | ||||
|         validateName, | ||||
|         validateProjectId, | ||||
|         errors, | ||||
|     } = useProjectForm(); | ||||
| 
 | ||||
| @ -36,10 +35,9 @@ const CreateProject = () => { | ||||
|         e.preventDefault(); | ||||
|         clearErrors(); | ||||
|         const validName = validateName(); | ||||
|         const validProjectId = validateProjectId(); | ||||
|         const validId = await validateIdUniqueness(); | ||||
| 
 | ||||
|         if (validName && validId && validProjectId) { | ||||
|         if (validName && validId) { | ||||
|             const payload = getProjectPayload(); | ||||
|             try { | ||||
|                 await createProject(payload); | ||||
| @ -67,7 +65,7 @@ const CreateProject = () => { | ||||
|     }; | ||||
| 
 | ||||
|     const handleCancel = () => { | ||||
|         history.push('/projects'); | ||||
|         history.goBack(); | ||||
|     }; | ||||
| 
 | ||||
|     return ( | ||||
| @ -92,10 +90,7 @@ const CreateProject = () => { | ||||
|                 clearErrors={clearErrors} | ||||
|                 validateIdUniqueness={validateIdUniqueness} | ||||
|             > | ||||
|                 <PermissionButton | ||||
|                     permission={CREATE_PROJECT} | ||||
|                     type="submit" | ||||
|                 > | ||||
|                 <PermissionButton permission={CREATE_PROJECT} type="submit"> | ||||
|                     Create project | ||||
|                 </PermissionButton> | ||||
|             </ProjectForm> | ||||
|  | ||||
| @ -39,6 +39,10 @@ const useProjectForm = ( | ||||
|     const NAME_EXISTS_ERROR = 'Error: A project with this id already exists.'; | ||||
| 
 | ||||
|     const validateIdUniqueness = async () => { | ||||
|         if (projectId.length === 0) { | ||||
|             setErrors(prev => ({ ...prev, id: 'Id can not be empty.' })); | ||||
|             return false; | ||||
|         } | ||||
|         try { | ||||
|             await validateId(getProjectPayload()); | ||||
|             return true; | ||||
|  | ||||
| @ -75,11 +75,9 @@ const CreateTagType = () => { | ||||
|                 setTagDesc={setTagDesc} | ||||
|                 mode="Create" | ||||
|                 clearErrors={clearErrors} | ||||
|                 validateNameUniqueness={validateNameUniqueness} | ||||
|             > | ||||
|                 <PermissionButton | ||||
|                     permission={UPDATE_TAG_TYPE} | ||||
|                     type="submit" | ||||
|                 > | ||||
|                 <PermissionButton permission={UPDATE_TAG_TYPE} type="submit"> | ||||
|                     Create type | ||||
|                 </PermissionButton> | ||||
|             </TagTypeForm> | ||||
|  | ||||
| @ -16,6 +16,7 @@ interface ITagTypeForm { | ||||
|     errors: { [key: string]: string }; | ||||
|     mode: string; | ||||
|     clearErrors: () => void; | ||||
|     validateNameUniqueness?: () => void; | ||||
| } | ||||
| 
 | ||||
| const TagTypeForm: React.FC<ITagTypeForm> = ({ | ||||
| @ -28,6 +29,7 @@ const TagTypeForm: React.FC<ITagTypeForm> = ({ | ||||
|     setTagDesc, | ||||
|     errors, | ||||
|     mode, | ||||
|     validateNameUniqueness, | ||||
|     clearErrors, | ||||
| }) => { | ||||
|     const styles = useStyles(); | ||||
| @ -49,11 +51,10 @@ const TagTypeForm: React.FC<ITagTypeForm> = ({ | ||||
|                     errorText={errors.name} | ||||
|                     onFocus={() => clearErrors()} | ||||
|                     disabled={mode === EDIT} | ||||
|                     onBlur={validateNameUniqueness} | ||||
|                 /> | ||||
| 
 | ||||
|                 <p className={styles.inputDescription}> | ||||
|                     What is this role for? | ||||
|                 </p> | ||||
|                 <p className={styles.inputDescription}>What is this tag for?</p> | ||||
|                 <TextField | ||||
|                     className={styles.input} | ||||
|                     label="Tag description" | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user