Web.Client: applied getting companyName(greetingTitle) to all Confirm sub-components, removed customNames file

This commit is contained in:
Daniil Senkiv 2019-11-06 14:17:13 +03:00
parent a877f9d0dd
commit 656d82010b
8 changed files with 49 additions and 42 deletions

View File

@ -22,8 +22,5 @@
"DeleteProfileConfirmation": "Attention! You are about to delete your account.",
"DeleteProfileConfirmationInfo": "By clicking the \"Delete my account\" button you agree with our Privacy policy.",
"DeleteProfileSuccessMessage": "Your account has been successfully deleted.",
"DeleteProfileSuccessMessageInfo": "See our Privacy policy to learn more about deleting your account and data accociated with it.",
"CustomWelcomePageTitle": "{{welcomePageTitle}}"
"DeleteProfileSuccessMessageInfo": "See our Privacy policy to learn more about deleting your account and data accociated with it."
}

View File

@ -17,8 +17,5 @@
"PasswordCustomMode": "Пароль",
"ImportContactsOkButton": "OK",
"LoadingProcessing": "Загрузка...",
"ChangePasswordSuccess": "Пароль был успешно изменен",
"CustomWelcomePageTitle": "{{welcomePageTitle}}"
"ChangePasswordSuccess": "Пароль был успешно изменен"
}

View File

@ -5,7 +5,6 @@ import { Button, TextInput, PageLayout, Text, PasswordInput, toastr, Loader } fr
import styled from 'styled-components';
import { Collapse } from 'reactstrap';
import { connect } from 'react-redux';
import { welcomePageTitle } from './../../../../helpers/customNames';
import { EmployeeActivationStatus } from './../../../../helpers/constants';
import { getConfirmationInfo, activateConfirmUser } from '../../../../store/auth/actions';
import PropTypes from 'prop-types';
@ -180,7 +179,7 @@ class Confirm extends React.PureComponent {
render() {
console.log('ActivateUser render');
const { settings, isConfirmLoaded, t } = this.props;
const { settings, isConfirmLoaded, t, greetingTitle } = this.props;
return (
!isConfirmLoaded
? (
@ -196,7 +195,7 @@ class Confirm extends React.PureComponent {
<a href='/login'>
<img src="images/dark_general.png" alt="Logo" />
</a>
<Text.Body as='p' fontSize={24} color='#116d9d'>{t('CustomWelcomePageTitle', { welcomePageTitle })}</Text.Body>
<Text.Body as='p' fontSize={24} color='#116d9d'>{greetingTitle}</Text.Body>
</div>
</div>
@ -321,7 +320,8 @@ const ActivateUserForm = (props) => (<PageLayout sectionBodyContent={<Confirm {.
function mapStateToProps(state) {
return {
isConfirmLoaded: state.auth.isConfirmLoaded,
settings: state.auth.settings.passwordSettings
settings: state.auth.settings.passwordSettings,
greetingTitle: state.auth.settings.companyName
};
}

View File

@ -13,12 +13,12 @@ import {
Loader,
toastr
} from "asc-web-components";
import { welcomePageTitle } from "../../../../helpers/customNames";
import {
changePassword,
getConfirmationInfo,
logout
} from "../../../../../src/store/auth/actions";
import { getGreetingTitle } from '../../../../store/settings/actions';
const BodyStyle = styled(Container)`
margin-top: 70px;
@ -108,12 +108,13 @@ class Form extends React.PureComponent {
};
componentDidMount() {
const { getConfirmationInfo, history } = this.props;
const { getConfirmationInfo, history, getGreetingTitle } = this.props;
getConfirmationInfo(this.state.key)
.catch(error => {
toastr.error(this.props.t(`${error}`));
history.push("/");
});
getGreetingTitle();
window.addEventListener("keydown", this.onKeyPress);
window.addEventListener("keyup", this.onKeyPress);
@ -127,7 +128,7 @@ class Form extends React.PureComponent {
validatePassword = value => this.setState({ passwordValid: value });
render() {
const { settings, isConfirmLoaded, t } = this.props;
const { settings, isConfirmLoaded, t, greetingTitle } = this.props;
const { isLoading, password, passwordEmpty } = this.state;
const mdOptions = { size: 6, offset: 3 };
@ -145,7 +146,7 @@ class Form extends React.PureComponent {
top
/>
<CardTitle className="card-title">
{t("CustomWelcomePageTitle", { welcomePageTitle })}
{greetingTitle}
</CardTitle>
</Card>
<Text.Body fontSize={14}>{t("PassworResetTitle")}</Text.Body>
@ -217,11 +218,12 @@ function mapStateToProps(state) {
isValidConfirmLink: state.auth.isValidConfirmLink,
isConfirmLoaded: state.auth.isConfirmLoaded,
settings: state.auth.settings.passwordSettings,
isAuthenticated: state.auth.isAuthenticated
isAuthenticated: state.auth.isAuthenticated,
greetingTitle: state.settings.greetingSettings,
};
}
export default connect(
mapStateToProps,
{ changePassword, getConfirmationInfo, logout }
{ changePassword, getConfirmationInfo, logout, getGreetingTitle }
)(withRouter(withTranslation()(ChangePasswordForm)));

View File

@ -5,7 +5,6 @@ import { withTranslation } from 'react-i18next';
import styled from "styled-components";
import { Button, TextInput, PageLayout, Text } from "asc-web-components";
//import { useTranslation } from "react-i18next";
import { welcomePageTitle } from "../../../../helpers/customNames";
//import { login } from '../../../../../src/store/auth/actions';
const BodyStyle = styled.div`
@ -39,7 +38,7 @@ const BodyStyle = styled.div`
`;
const PhoneForm = props => {
const { t, currentPhone } = props;
const { t, currentPhone, greetingTitle } = props;
const [phone, setPhone] = useState(currentPhone);
// eslint-disable-next-line no-unused-vars
@ -68,7 +67,7 @@ const PhoneForm = props => {
<div className="edit-header">
<img className="header-logo" src="images/dark_general.png" alt="Logo" />
<div className="header-title">
{t("CustomWelcomePageTitle", { welcomePageTitle })}
{greetingTitle}
</div>
</div>
<Text.Body className="edit-text" isBold fontSize={14}>{subTitleTranslation}</Text.Body>
@ -118,7 +117,8 @@ const ChangePhoneForm = props => {
function mapStateToProps(state) {
return {
isLoaded: state.auth.isLoaded,
currentPhone: state.auth.user.mobilePhone
currentPhone: state.auth.user.mobilePhone,
greetingTitle: state.auth.settings.companyName
};
}

View File

@ -5,7 +5,6 @@ import { Button, TextInput, PageLayout, Text, PasswordInput, toastr, Loader } fr
import styled from 'styled-components';
import { Collapse } from 'reactstrap';
import { connect } from 'react-redux';
import { welcomePageTitle } from './../../../../helpers/customNames';
import { getConfirmationInfo, createConfirmUser, logout, login } from '../../../../store/auth/actions';
import PropTypes from 'prop-types';
@ -127,9 +126,9 @@ class Confirm extends React.PureComponent {
const registerData = Object.assign(personalData, { isVisitor: isVisitor })
createConfirmUser(registerData, loginData, this.state.key)
.then(() => {
toastr.success("User has been created successfully");
return history.push('/');
.then(() => {
toastr.success("User has been created successfully");
return history.push('/');
})
.catch((error) => {
console.error("confirm error", error);
@ -154,11 +153,6 @@ class Confirm extends React.PureComponent {
const { getConfirmationInfo, history } = this.props;
getConfirmationInfo(this.state.key, this.state.linkType)
.then(
function () {
console.log("get settings success");
}
)
.catch(e => {
console.error("get settings error", e);
history.push(`/login/error=${e}`);
@ -201,7 +195,7 @@ class Confirm extends React.PureComponent {
render() {
console.log('createUser render');
const { settings, isConfirmLoaded, t } = this.props;
const { settings, isConfirmLoaded, t, greetingTitle } = this.props;
return (
!isConfirmLoaded
? (
@ -217,7 +211,7 @@ class Confirm extends React.PureComponent {
<a href='/login'>
<img src="images/dark_general.png" alt="Logo" />
</a>
<Text.Body as='p' fontSize={24} color='#116d9d'>{t('CustomWelcomePageTitle', { welcomePageTitle })}</Text.Body>
<Text.Body as='p' fontSize={24} color='#116d9d'>{greetingTitle}</Text.Body>
</div>
</div>
@ -348,7 +342,8 @@ function mapStateToProps(state) {
return {
isConfirmLoaded: state.auth.isConfirmLoaded,
isAuthenticated: state.auth.isAuthenticated,
settings: state.auth.settings.passwordSettings
settings: state.auth.settings.passwordSettings,
greetingTitle: state.auth.settings.companyName
};
}

View File

@ -3,11 +3,11 @@ import { connect } from "react-redux";
import { withRouter } from "react-router";
import { Button, PageLayout, Text } from 'asc-web-components';
import styled from 'styled-components';
import { welcomePageTitle } from './../../../../helpers/customNames';
import PropTypes from 'prop-types';
import { withTranslation } from 'react-i18next';
import { deleteSelf } from './../../../../store/services/api';
import { logout } from '../../../../store/auth/actions';
import { getGreetingTitle } from '../../../../store/settings/actions';
const ProfileRemoveContainer = styled.div`
display: flex;
@ -30,14 +30,25 @@ const ProfileRemoveContainer = styled.div`
class ProfileRemove extends React.PureComponent {
constructor() {
super();
constructor(props) {
super(props);
const { greetingTitle } = props;
this.state = {
isProfileDeleted: false
isProfileDeleted: false,
greetingTitle
};
}
componentDidMount() {
const { greetingTitle } = this.state;
const { getGreetingTitle } = this.props;
if (!greetingTitle) {
getGreetingTitle()
.then(() => this.setState({ greetingTitle: this.props.greetingTitleSettings }));
}
}
onDeleteProfile = () => {
this.setState({ isLoading: true }, function () {
const { linkData, logout } = this.props;
@ -62,7 +73,7 @@ class ProfileRemove extends React.PureComponent {
render() {
console.log('profileRemove render');
const { t } = this.props;
const { isProfileDeleted } = this.state;
const { isProfileDeleted, greetingTitle } = this.state;
return (
<ProfileRemoveContainer>
<div className='start-basis'>
@ -71,7 +82,7 @@ class ProfileRemove extends React.PureComponent {
<a href='/login'>
<img src="images/dark_general.png" alt="Logo" />
</a>
<Text.Body as='p' fontSize={24} color='#116d9d'>{t('CustomWelcomePageTitle', { welcomePageTitle })}</Text.Body>
<Text.Body as='p' fontSize={24} color='#116d9d'>{greetingTitle}</Text.Body>
</div>
{!isProfileDeleted
@ -107,5 +118,11 @@ ProfileRemove.propTypes = {
};
const ProfileRemoveForm = (props) => (<PageLayout sectionBodyContent={<ProfileRemove {...props} />} />);
function mapStateToProps(state) {
return {
greetingTitle: state.auth.settings.companyName,
greetingTitleSettings: state.settings.greetingSettings
};
}
export default connect(null, { logout })(withRouter(withTranslation()(ProfileRemoveForm)));
export default connect(mapStateToProps, { logout, getGreetingTitle })(withRouter(withTranslation()(ProfileRemoveForm)));

View File

@ -1 +0,0 @@
export const welcomePageTitle = 'Cloud Office Applications';