accounts-frontend/src/components/profile/Profile.jsx

122 lines
4.8 KiB
React
Raw Normal View History

import React, { Component } from 'react';
2016-03-20 14:00:58 +05:30
import { FormattedMessage as Message, FormattedRelative as Relative, FormattedHTMLMessage as HTMLMessage } from 'react-intl';
import Helmet from 'react-helmet';
import { userShape } from 'components/user/User';
2016-05-20 01:11:43 +05:30
import { LangMenu } from 'components/langMenu';
import langMenuMessages from 'components/langMenu/langMenu.intl.json';
import ProfileField from './ProfileField';
import styles from './profile.scss';
import profileForm from './profileForm.scss';
import messages from './Profile.intl.json';
export default class Profile extends Component {
static displayName = 'Profile';
static propTypes = {
user: userShape
};
render() {
const { user } = this.props;
return (
<div>
2016-03-20 14:00:58 +05:30
<Message {...messages.accountPreferencesTitle}>
{(pageTitle) => (
<h2 className={styles.indexTitle}>
2016-03-20 14:00:58 +05:30
<Helmet title={pageTitle} />
{pageTitle}
</h2>
)}
</Message>
<div className={styles.indexContent}>
<div className={styles.descriptionColumn}>
<div className={styles.indexDescription}>
<Message {...messages.accountDescription} />
</div>
</div>
<div className={styles.formColumn}>
<div className={profileForm.form}>
<div className={styles.item}>
<h3 className={profileForm.title}>
<Message {...messages.personalData} />
</h3>
<p className={profileForm.description}>
<Message {...messages.preferencesDescription} />
</p>
</div>
<ProfileField
2016-05-02 18:43:18 +05:30
link="/profile/change-username"
label={<Message {...messages.nickname} />}
value={user.username}
warningMessage={user.hasMojangUsernameCollision ? (
<Message {...messages.mojangPriorityWarning} />
) : ''}
/>
<ProfileField
link="/profile/change-email"
label={'Email'}
value={user.email}
/>
<ProfileField
link="/profile/change-password"
2016-05-02 18:43:18 +05:30
label={<Message {...messages.password} />}
value={<Message {...messages.changedAt} values={{
at: (<Relative value={user.passwordChangedAt * 1000} updateInterval={1000} />)
}} />}
warningMessage={user.shouldChangePassword ? (
<HTMLMessage {...messages.oldHashingAlgoWarning} />
) : ''}
/>
2016-05-20 01:11:43 +05:30
<ProfileField
label={<Message {...langMenuMessages.siteLanguage} />}
2016-05-22 18:01:43 +05:30
value={<LangMenu showCurrentLang />}
2016-05-20 01:11:43 +05:30
/>
<ProfileField
label={<Message {...messages.twoFactorAuth} />}
value={<Message {...messages.disabled} />}
/>
<ProfileField
label={'UUID'}
value={
<span
className={styles.uuid}
ref={this.setUUID.bind(this)}
onMouseOver={this.handleUUIDMouseOver.bind(this)}
>
{user.uuid}
</span>
}
/>
</div>
</div>
</div>
</div>
);
}
handleUUIDMouseOver() {
try {
const selection = window.getSelection();
const range = document.createRange();
range.selectNodeContents(this.UUID);
selection.removeAllRanges();
selection.addRange(range);
} catch (err) {}
}
setUUID(el) {
this.UUID = el;
}
}