-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split combined error message component and cleaned up browse page sli…
…ghtly
- Loading branch information
1 parent
012b801
commit 3131ecb
Showing
12 changed files
with
72 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
web/src/components/forms/components/combined-error-message.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { FC } from 'react'; | ||
|
||
type CombinedErrorMessageProps = { | ||
errors: FieldErrors<any>; | ||
formType: string; | ||
}; | ||
|
||
export const CombinedErrorMessage = (props: CombinedErrorMessageProps) => { | ||
const { errors, formType } = props; | ||
|
||
if (formType === 'schema') { | ||
const nameError = errors.name?.message; | ||
let msg = null; | ||
|
||
if (nameError == 'empty') { | ||
msg = 'Schema Name must not be empty.'; | ||
} else if (nameError == 'invalid') { | ||
msg = "Schema Name must contain only alphanumeric characters, '.', '-', or '_'."; | ||
} | ||
|
||
if (nameError) { | ||
return <p className="text-danger text-xs pt-1 mb-0">{msg}</p>; | ||
} | ||
return null; | ||
} else if (formType === 'project') { | ||
const nameError = errors.project_name?.message; | ||
const tagError = errors.tag?.message; | ||
let msg = null; | ||
|
||
if (nameError == 'empty' && !tagError) { | ||
msg = 'Project Name must not be empty.'; | ||
} else if (nameError == 'invalid' && !tagError) { | ||
msg = "Project Name must contain only alphanumeric characters, '-', or '_'."; | ||
} else if (nameError == 'empty' && tagError == 'invalid') { | ||
msg = "Project Name must not be empty and Tag must contain only alphanumeric characters, '-', or '_'."; | ||
} else if (nameError == 'invalid' && tagError == 'invalid') { | ||
msg = "Project Name and Tag must contain only alphanumeric characters, '-', or '_'."; | ||
} else if (!nameError && tagError == 'invalid') { | ||
msg = "Project Tag must contain only alphanumeric characters, '-', or '_'."; | ||
} | ||
|
||
if (nameError || tagError) { | ||
return <p className="text-danger text-xs pt-1 mb-0">{msg}</p>; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.