From 007a64525b25d7a7a41e7e42e13a244e3482652c Mon Sep 17 00:00:00 2001 From: Eric Newport Date: Fri, 27 Apr 2018 11:34:57 -0400 Subject: [PATCH] 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. --- CHANGELOG.md | 2 ++ src/browser/components/NewTeamModal.jsx | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 781693f3..532d7e8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,8 @@ Release date: TBD [#707](https://github.com/mattermost/desktop/issues/707) - Fixed an issue that prevented typing in the form fields on the add server dialog when launched from the tab bar. [#780](https://github.com/mattermost/desktop/issues/780) +- Fixed an issue that could cause an error message on the add new server dialog to be misleading. +[#438](https://github.com/mattermost/desktop/issues/438) #### Windows - Fixed `file://` protocol not working. But localhost URL will not continue to work. diff --git a/src/browser/components/NewTeamModal.jsx b/src/browser/components/NewTeamModal.jsx index 63003716..c9ad04c4 100644 --- a/src/browser/components/NewTeamModal.jsx +++ b/src/browser/components/NewTeamModal.jsx @@ -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() {