Improve error messages on add new server dialog

Closes #438

Note: this solution is different than what @jasonblais suggested.
@jasonblais suggested not highlighting the field that hasn't been
filled out yet, but I think it's a better UX to continue to highlight
them all as it currently does, but to clarify the error messages. Also
notably, as far as I can tell, the react-bootstrap [forms
API](https://react-bootstrap.github.io/components/forms/) does not
appear to support selectively highlighting some fields in the form but
not others anyway.
This commit is contained in:
Eric Newport
2018-04-27 11:34:57 -04:00
parent 9c83d4009c
commit 007a64525b
2 changed files with 13 additions and 1 deletions

View File

@@ -68,7 +68,17 @@ export default class NewTeamModal extends React.Component {
}
getError() {
return this.getTeamNameValidationError() || this.getTeamUrlValidationError();
const nameError = this.getTeamNameValidationError();
const urlError = this.getTeamUrlValidationError();
if (nameError && urlError) {
return 'Name and URL are required.';
} else if (nameError) {
return nameError;
} else if (urlError) {
return urlError;
}
return null;
}
validateForm() {