From f7f011661484af1e5b4c1b7c088d59992d6d0962 Mon Sep 17 00:00:00 2001 From: Daniil Senkiv Date: Wed, 2 Oct 2019 09:20:41 +0300 Subject: [PATCH 1/2] Web.Client: Confirm: activate user: added hidden email field --- .../Confirm/sub-components/activateUser.js | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Confirm/sub-components/activateUser.js b/web/ASC.Web.Client/src/components/pages/Confirm/sub-components/activateUser.js index 489687e155..a1fba6fe47 100644 --- a/web/ASC.Web.Client/src/components/pages/Confirm/sub-components/activateUser.js +++ b/web/ASC.Web.Client/src/components/pages/Confirm/sub-components/activateUser.js @@ -42,8 +42,14 @@ const ConfirmContainer = styled.div` word-break: break-word; } + .display-none { + display: none; + } + `; +const emailInputName = 'email'; + class Confirm extends React.PureComponent { constructor(props) { @@ -51,9 +57,9 @@ class Confirm extends React.PureComponent { this.state = { email: props.linkData.email, - firstName: props.linkData.firstname, + firstName: props.linkData.firstname, firstNameValid: true, - lastName: props.linkData.lastname, + lastName: props.linkData.lastname, lastNameValid: true, password: '', passwordValid: true, @@ -95,7 +101,7 @@ class Confirm extends React.PureComponent { this.setState({ isLoading: false }); return false; } - + const loginData = { userName: this.state.email, password: this.state.password @@ -225,13 +231,24 @@ class Confirm extends React.PureComponent { onChange={this.onChangeSurname} onKeyDown={this.onKeyPress} /> + + + Date: Wed, 2 Oct 2019 10:12:32 +0300 Subject: [PATCH 2/2] Web: Client: fixed "About" page, added new translations, added toastr with success and error messages --- .../src/components/pages/About/index.js | 4 +- .../pages/Confirm/locales/en/translation.json | 1 + .../pages/Confirm/locales/ru/translation.json | 3 +- .../Confirm/sub-components/changePassword.js | 185 ++++++++---------- web/ASC.Web.Client/src/resourceConfig.json | 3 +- 5 files changed, 86 insertions(+), 110 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/About/index.js b/web/ASC.Web.Client/src/components/pages/About/index.js index eced110b65..b7dcae0720 100644 --- a/web/ASC.Web.Client/src/components/pages/About/index.js +++ b/web/ASC.Web.Client/src/components/pages/About/index.js @@ -30,7 +30,7 @@ const BodyStyle = styled.div` content: ""; height: 2px; margin-top: 9px; - width: 36%; + width: 26%; float: right; } @@ -39,7 +39,7 @@ const BodyStyle = styled.div` content: ""; height: 2px; margin-top: 9px; - width: 36%; + width: 26%; float: left; } } diff --git a/web/ASC.Web.Client/src/components/pages/Confirm/locales/en/translation.json b/web/ASC.Web.Client/src/components/pages/Confirm/locales/en/translation.json index dd4963998e..7db5c0a919 100644 --- a/web/ASC.Web.Client/src/components/pages/Confirm/locales/en/translation.json +++ b/web/ASC.Web.Client/src/components/pages/Confirm/locales/en/translation.json @@ -17,6 +17,7 @@ "PasswordCustomMode": "Password", "ImportContactsOkButton": "OK", "LoadingProcessing": "Loading...", + "ChangePasswordSuccess": "Password has been successfully changed", "CustomWelcomePageTitle": "{{welcomePageTitle}}" diff --git a/web/ASC.Web.Client/src/components/pages/Confirm/locales/ru/translation.json b/web/ASC.Web.Client/src/components/pages/Confirm/locales/ru/translation.json index 1685299a2c..9e64c4502c 100644 --- a/web/ASC.Web.Client/src/components/pages/Confirm/locales/ru/translation.json +++ b/web/ASC.Web.Client/src/components/pages/Confirm/locales/ru/translation.json @@ -13,10 +13,11 @@ "ErrorPasswordNoUpperCase": "заглавные буквы", "ErrorPasswordNoSpecialSymbols": "специальные символы", "EmailAndPasswordCopiedToClipboard": "Email и пароль скопированы", - "PassworResetTitle": "Теперь вы можете создать новый пароль.", "_comment":"SYNTAX ERROR 'Passwor' Reset Title", + "PassworResetTitle": "Теперь вы можете создать новый пароль.", "PasswordCustomMode": "Пароль", "ImportContactsOkButton": "OK", "LoadingProcessing": "Загрузка...", + "ChangePasswordSuccess": "Пароль был успешно изменен", "CustomWelcomePageTitle": "{{welcomePageTitle}}" diff --git a/web/ASC.Web.Client/src/components/pages/Confirm/sub-components/changePassword.js b/web/ASC.Web.Client/src/components/pages/Confirm/sub-components/changePassword.js index eb33b4c2ff..53e07439b2 100644 --- a/web/ASC.Web.Client/src/components/pages/Confirm/sub-components/changePassword.js +++ b/web/ASC.Web.Client/src/components/pages/Confirm/sub-components/changePassword.js @@ -4,15 +4,7 @@ import { withTranslation } from "react-i18next"; import { connect } from "react-redux"; import PropTypes from "prop-types"; import styled from "styled-components"; -import { - Container, - Collapse, - Row, - Col, - Card, - CardTitle, - CardImg -} from "reactstrap"; +import { Container, Row, Col, Card, CardTitle, CardImg } from "reactstrap"; import { Button, PageLayout, @@ -33,9 +25,9 @@ const BodyStyle = styled(Container)` p { margin-bottom: 5px; } -.button-style{ - margin-top: 20px; -} + .button-style { + margin-top: 20px; + } .password-row { margin: 23px 0 0; @@ -65,7 +57,6 @@ class Form extends React.PureComponent { password: "", passwordValid: true, isValidConfirmLink: false, - errorText: "", isLoading: false, passwordEmpty: false, key: linkData.confirmHeader, @@ -83,15 +74,13 @@ class Form extends React.PureComponent { this.setState({ password: event.target.value }); !this.state.passwordValid && this.setState({ passwordValid: true }); event.target.value.trim() && this.setState({ passwordEmpty: false }); - this.state.errorText && this.setState({ errorText: "" }); this.onKeyPress(event); }; onSubmit = e => { - this.setState({ isLoading: true }, function () { + this.setState({ isLoading: true }, function() { const { userId, password, key } = this.state; const { history, changePassword, logout } = this.props; - this.setState({ errorText: "" }); let hasError = false; if (!this.state.passwordValid) { @@ -108,14 +97,12 @@ class Form extends React.PureComponent { changePassword(userId, { password }, key) .then(() => { - console.log("UPDATE PASSWORD"); logout(); + toastr.success(this.props.t("ChangePasswordSuccess")); history.push("/"); }) .catch(e => { - history.push("/"); - console.log("ERROR UPDATE PASSWORD:", e.message); - this.setState({ errorText: e.message }); + toastr.error(this.props.t(`${e.message}`)); this.setState({ isLoading: false }); }); }); @@ -123,14 +110,10 @@ class Form extends React.PureComponent { componentDidMount() { const { getConfirmationInfo, history } = this.props; - getConfirmationInfo(this.state.key) - .then(() => { - console.log("GET PASSWORD SETTINGS SUCCESS"); - }) - .catch(e => { - console.log("ERROR GET PASSWORD SETTINGS", e); - history.push(`/login/error=${e}`); - }); + getConfirmationInfo(this.state.key).catch(e => { + toastr.error(this.props.t(`${e.message}`)); + history.push("/"); + }); window.addEventListener("keydown", this.onKeyPress); window.addEventListener("keyup", this.onKeyPress); @@ -141,95 +124,84 @@ class Form extends React.PureComponent { window.removeEventListener("keyup", this.onKeyPress); } - onCopyToClipboard = () => - toastr.success(this.props.t("EmailAndPasswordCopiedToClipboard")); - validatePassword = value => this.setState({ passwordValid: value }); render() { const { settings, isConfirmLoaded, t } = this.props; - const { isLoading, password, passwordEmpty, errorText } = this.state; + const { isLoading, password, passwordEmpty } = this.state; const mdOptions = { size: 6, offset: 3 }; return !isConfirmLoaded ? ( ) : ( - - - - - - - {t("CustomWelcomePageTitle", { welcomePageTitle })} - - - {t("PassworResetTitle")} + + + + + + + {t("CustomWelcomePageTitle", { welcomePageTitle })} + + + {t("PassworResetTitle")} - -