From 15e75ca7b34fc428073bdc6b8c58ac00b8017200 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 23 Jun 2018 17:12:00 +0100 Subject: [PATCH 1/4] generate local errors for blank fields during login Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/login/Login.js | 8 ++++ src/components/views/login/PasswordLogin.js | 51 +++++++++++++++++---- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/src/components/structures/login/Login.js b/src/components/structures/login/Login.js index bc04434bb2..43264e7003 100644 --- a/src/components/structures/login/Login.js +++ b/src/components/structures/login/Login.js @@ -93,6 +93,13 @@ module.exports = React.createClass({ this._unmounted = true; }, + onPasswordLoginError: function(errorText) { + this.setState({ + errorText, + loginIncorrect: Boolean(errorText), + }); + }, + onPasswordLogin: function(username, phoneCountry, phoneNumber, password) { this.setState({ busy: true, @@ -357,6 +364,7 @@ module.exports = React.createClass({ return ( Date: Sat, 23 Jun 2018 17:13:40 +0100 Subject: [PATCH 2/4] clear error on login type change Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/login/PasswordLogin.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/views/login/PasswordLogin.js b/src/components/views/login/PasswordLogin.js index c30cb9d72a..16bd339825 100644 --- a/src/components/views/login/PasswordLogin.js +++ b/src/components/views/login/PasswordLogin.js @@ -123,6 +123,7 @@ class PasswordLogin extends React.Component { } onLoginTypeChange(loginType) { + this.props.onError(null); // send a null error to clear any error messages this.setState({ loginType: loginType, username: "", // Reset because email and username use the same state From 61def4a973359b5ffce2d2f92e6006000c2f70f1 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 23 Jun 2018 17:26:16 +0100 Subject: [PATCH 3/4] highlight top field if blank otherwise the password field. remove unused refs Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/login/PasswordLogin.js | 27 +++++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/components/views/login/PasswordLogin.js b/src/components/views/login/PasswordLogin.js index 16bd339825..a0e5ab0ddb 100644 --- a/src/components/views/login/PasswordLogin.js +++ b/src/components/views/login/PasswordLogin.js @@ -57,15 +57,17 @@ class PasswordLogin extends React.Component { this.onPhoneCountryChanged = this.onPhoneCountryChanged.bind(this); this.onPhoneNumberChanged = this.onPhoneNumberChanged.bind(this); this.onPasswordChanged = this.onPasswordChanged.bind(this); + this.isLoginEmpty = this.isLoginEmpty.bind(this); } componentWillMount() { this._passwordField = null; + this._loginField = null; } componentWillReceiveProps(nextProps) { if (!this.props.loginIncorrect && nextProps.loginIncorrect) { - field_input_incorrect(this._passwordField); + field_input_incorrect(this.isLoginEmpty() ? this._loginField : this._passwordField); } } @@ -157,8 +159,10 @@ class PasswordLogin extends React.Component { switch (loginType) { case PasswordLogin.LOGIN_FIELD_EMAIL: classes.mx_Login_email = true; + classes.error = this.props.loginIncorrect && !this.state.username; return {this._loginField = e;}} key="email_input" type="text" name="username" // make it a little easier for browser's remember-password @@ -170,8 +174,10 @@ class PasswordLogin extends React.Component { />; case PasswordLogin.LOGIN_FIELD_MXID: classes.mx_Login_username = true; + classes.error = this.props.loginIncorrect && !this.state.username; return {this._loginField = e;}} key="username_input" type="text" name="username" // make it a little easier for browser's remember-password @@ -184,14 +190,14 @@ class PasswordLogin extends React.Component { autoFocus disabled={disabled} />; - case PasswordLogin.LOGIN_FIELD_PHONE: + case PasswordLogin.LOGIN_FIELD_PHONE: { const CountryDropdown = sdk.getComponent('views.login.CountryDropdown'); classes.mx_Login_phoneNumberField = true; classes.mx_Login_field_has_prefix = true; + classes.error = this.props.loginIncorrect && !this.state.phoneNumber; return
{this._loginField = e;}} key="phone_input" type="text" name="phoneNumber" @@ -211,6 +217,17 @@ class PasswordLogin extends React.Component { disabled={disabled} />
; + } + } + } + + isLoginEmpty() { + switch (this.state.loginType) { + case PasswordLogin.LOGIN_FIELD_EMAIL: + case PasswordLogin.LOGIN_FIELD_MXID: + return !this.state.username; + case PasswordLogin.LOGIN_FIELD_PHONE: + return !this.state.phoneCountry || !this.state.phoneNumber; } } @@ -238,7 +255,7 @@ class PasswordLogin extends React.Component { const pwFieldClass = classNames({ mx_Login_field: true, mx_Login_field_disabled: matrixIdText === '', - error: this.props.loginIncorrect, + error: this.props.loginIncorrect && !this.isLoginEmpty(), // only error password if error isn't top field }); const Dropdown = sdk.getComponent('elements.Dropdown'); From 8251de4e35af64b3fcb41b62d031e47fdb59d605 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 23 Jun 2018 17:26:44 +0100 Subject: [PATCH 4/4] run gen-i18n and prune-i18n Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/i18n/strings/el.json | 1 - src/i18n/strings/en_EN.json | 64 ++++++++++++++++++++----------------- src/i18n/strings/gl.json | 1 - src/i18n/strings/it.json | 1 - 4 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/i18n/strings/el.json b/src/i18n/strings/el.json index f6264ce8b0..c4514f629b 100644 --- a/src/i18n/strings/el.json +++ b/src/i18n/strings/el.json @@ -810,7 +810,6 @@ "%(widgetName)s widget removed by %(senderName)s": "Το widget %(widgetName)s αφαιρέθηκε από τον/την %(senderName)s", "%(names)s and %(count)s others are typing|other": "Ο/Η %(names)s και άλλοι/ες %(count)s πληκτρολογούν", "%(names)s and %(count)s others are typing|one": "Ο/Η %(names)s και άλλος ένας πληκτρολογούν", - "Message Replies": "Απαντήσεις", "Message Pinning": "Καρφίτσωμα Μηνυμάτων", "Hide avatar changes": "Απόκρυψη αλλαγών εικονιδίων χρηστών", "Hide display name changes": "Απόκρυψη αλλαγών εμφανιζόμενων ονομάτων", diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index da47140c96..21dfc87ad2 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -42,6 +42,10 @@ "The file '%(fileName)s' failed to upload": "The file '%(fileName)s' failed to upload", "The file '%(fileName)s' exceeds this home server's size limit for uploads": "The file '%(fileName)s' exceeds this home server's size limit for uploads", "Upload Failed": "Upload Failed", + "Failure to create room": "Failure to create room", + "Server may be unavailable, overloaded, or you hit a bug.": "Server may be unavailable, overloaded, or you hit a bug.", + "Send anyway": "Send anyway", + "Send": "Send", "Sun": "Sun", "Mon": "Mon", "Tue": "Tue", @@ -81,6 +85,7 @@ "Failed to invite users to community": "Failed to invite users to community", "Failed to invite users to %(groupId)s": "Failed to invite users to %(groupId)s", "Failed to add the following rooms to %(groupId)s:": "Failed to add the following rooms to %(groupId)s:", + "Unnamed Room": "Unnamed Room", "Riot does not have permission to send you notifications - please check your browser settings": "Riot does not have permission to send you notifications - please check your browser settings", "Riot was not given permission to send notifications - please try again": "Riot was not given permission to send notifications - please try again", "Unable to enable Notifications": "Unable to enable Notifications", @@ -194,11 +199,6 @@ "%(names)s and %(count)s others are typing|other": "%(names)s and %(count)s others are typing", "%(names)s and %(count)s others are typing|one": "%(names)s and one other is typing", "%(names)s and %(lastPerson)s are typing": "%(names)s and %(lastPerson)s are typing", - "Failure to create room": "Failure to create room", - "Server may be unavailable, overloaded, or you hit a bug.": "Server may be unavailable, overloaded, or you hit a bug.", - "Send anyway": "Send anyway", - "Send": "Send", - "Unnamed Room": "Unnamed Room", "Your browser does not support the required cryptography extensions": "Your browser does not support the required cryptography extensions", "Not a valid Riot keyfile": "Not a valid Riot keyfile", "Authentication check failed: incorrect password?": "Authentication check failed: incorrect password?", @@ -311,6 +311,29 @@ "Off": "Off", "On": "On", "Noisy": "Noisy", + "Invalid alias format": "Invalid alias format", + "'%(alias)s' is not a valid format for an alias": "'%(alias)s' is not a valid format for an alias", + "Invalid address format": "Invalid address format", + "'%(alias)s' is not a valid format for an address": "'%(alias)s' is not a valid format for an address", + "not specified": "not specified", + "not set": "not set", + "Remote addresses for this room:": "Remote addresses for this room:", + "Addresses": "Addresses", + "The main address for this room is": "The main address for this room is", + "Local addresses for this room:": "Local addresses for this room:", + "This room has no local addresses": "This room has no local addresses", + "New address (e.g. #foo:%(localDomain)s)": "New address (e.g. #foo:%(localDomain)s)", + "Invalid community ID": "Invalid community ID", + "'%(groupId)s' is not a valid community ID": "'%(groupId)s' is not a valid community ID", + "Flair": "Flair", + "Showing flair for these communities:": "Showing flair for these communities:", + "This room is not showing flair for any communities": "This room is not showing flair for any communities", + "New community ID (e.g. +foo:%(localDomain)s)": "New community ID (e.g. +foo:%(localDomain)s)", + "You have enabled URL previews by default.": "You have enabled URL previews by default.", + "You have disabled URL previews by default.": "You have disabled URL previews by default.", + "URL previews are enabled by default for participants in this room.": "URL previews are enabled by default for participants in this room.", + "URL previews are disabled by default for participants in this room.": "URL previews are disabled by default for participants in this room.", + "URL Previews": "URL Previews", "Cannot add any more widgets": "Cannot add any more widgets", "The maximum permitted number of widgets have already been added to this room.": "The maximum permitted number of widgets have already been added to this room.", "Add a widget": "Add a widget", @@ -410,11 +433,11 @@ "numbullet": "numbullet", "Markdown is disabled": "Markdown is disabled", "Markdown is enabled": "Markdown is enabled", - "Unpin Message": "Unpin Message", - "Jump to message": "Jump to message", "No pinned messages.": "No pinned messages.", "Loading...": "Loading...", "Pinned Messages": "Pinned Messages", + "Unpin Message": "Unpin Message", + "Jump to message": "Jump to message", "%(duration)ss": "%(duration)ss", "%(duration)sm": "%(duration)sm", "%(duration)sh": "%(duration)sh", @@ -547,29 +570,6 @@ "Scroll to unread messages": "Scroll to unread messages", "Jump to first unread message.": "Jump to first unread message.", "Close": "Close", - "Invalid alias format": "Invalid alias format", - "'%(alias)s' is not a valid format for an alias": "'%(alias)s' is not a valid format for an alias", - "Invalid address format": "Invalid address format", - "'%(alias)s' is not a valid format for an address": "'%(alias)s' is not a valid format for an address", - "not specified": "not specified", - "not set": "not set", - "Remote addresses for this room:": "Remote addresses for this room:", - "Addresses": "Addresses", - "The main address for this room is": "The main address for this room is", - "Local addresses for this room:": "Local addresses for this room:", - "This room has no local addresses": "This room has no local addresses", - "New address (e.g. #foo:%(localDomain)s)": "New address (e.g. #foo:%(localDomain)s)", - "Invalid community ID": "Invalid community ID", - "'%(groupId)s' is not a valid community ID": "'%(groupId)s' is not a valid community ID", - "Flair": "Flair", - "Showing flair for these communities:": "Showing flair for these communities:", - "This room is not showing flair for any communities": "This room is not showing flair for any communities", - "New community ID (e.g. +foo:%(localDomain)s)": "New community ID (e.g. +foo:%(localDomain)s)", - "You have enabled URL previews by default.": "You have enabled URL previews by default.", - "You have disabled URL previews by default.": "You have disabled URL previews by default.", - "URL previews are enabled by default for participants in this room.": "URL previews are enabled by default for participants in this room.", - "URL previews are disabled by default for participants in this room.": "URL previews are disabled by default for participants in this room.", - "URL Previews": "URL Previews", "Sunday": "Sunday", "Monday": "Monday", "Tuesday": "Tuesday", @@ -614,6 +614,10 @@ "Code": "Code", "Start authentication": "Start authentication", "powered by Matrix": "powered by Matrix", + "The email field must not be blank.": "The email field must not be blank.", + "The user name field must not be blank.": "The user name field must not be blank.", + "The phone number field must not be blank.": "The phone number field must not be blank.", + "The password field must not be blank.": "The password field must not be blank.", "Username on %(hs)s": "Username on %(hs)s", "User name": "User name", "Mobile phone number": "Mobile phone number", diff --git a/src/i18n/strings/gl.json b/src/i18n/strings/gl.json index 1080e66a26..57d8301df6 100644 --- a/src/i18n/strings/gl.json +++ b/src/i18n/strings/gl.json @@ -168,7 +168,6 @@ "Authentication check failed: incorrect password?": "Fallou a comprobación de autenticación: contrasinal incorrecto?", "Failed to join room": "Non se puido unir a sala", "Message Pinning": "Fixando mensaxe", - "Tag Panel": "Panel de etiquetas", "Disable Emoji suggestions while typing": "Desactivar a suxestión de Emoji mentres escribe", "Use compact timeline layout": "Utilizar a disposición compacta da liña temporal", "Hide removed messages": "Ocultar mensaxes eliminadas", diff --git a/src/i18n/strings/it.json b/src/i18n/strings/it.json index d3f93acec5..0957bc156d 100644 --- a/src/i18n/strings/it.json +++ b/src/i18n/strings/it.json @@ -1175,7 +1175,6 @@ "To continue using the %(homeserverDomain)s homeserver you must review and agree to our terms and conditions.": "Per continuare a usare l'homeserver %(homeserverDomain)s devi leggere e accettare i nostri termini e condizioni.", "Review terms and conditions": "Leggi i termini e condizioni", "Muted Users": "Utenti silenziati", - "Message Replies": "Risposte", "Message Pinning": "Messaggi appuntati", "Mirror local video feed": "Feed video dai ripetitori locali", "Replying": "Rispondere",