2016-03-17 11:31:11 +05:30
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
|
2017-06-13 01:02:59 +05:30
|
|
|
|
import { FormattedMessage as Message, FormattedRelative as Relative } from 'react-intl';
|
2017-05-26 00:41:57 +05:30
|
|
|
|
import { Link } from 'react-router-dom';
|
2016-03-17 11:31:11 +05:30
|
|
|
|
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';
|
2016-03-17 11:31:11 +05:30
|
|
|
|
|
|
|
|
|
import ProfileField from './ProfileField';
|
|
|
|
|
import styles from './profile.scss';
|
2016-04-17 15:05:04 +05:30
|
|
|
|
import profileForm from './profileForm.scss';
|
2016-05-14 14:11:32 +05:30
|
|
|
|
import messages from './Profile.intl.json';
|
2016-03-17 11:31:11 +05:30
|
|
|
|
|
2016-06-01 14:42:41 +05:30
|
|
|
|
import RulesPage from 'pages/rules/RulesPage';
|
|
|
|
|
|
2017-05-26 00:41:57 +05:30
|
|
|
|
class Profile extends Component {
|
2016-03-17 11:31:11 +05:30
|
|
|
|
static displayName = 'Profile';
|
|
|
|
|
static propTypes = {
|
|
|
|
|
user: userShape
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
const { user } = this.props;
|
|
|
|
|
|
|
|
|
|
return (
|
2016-04-17 15:05:04 +05:30
|
|
|
|
<div>
|
2016-03-20 14:00:58 +05:30
|
|
|
|
<Message {...messages.accountPreferencesTitle}>
|
|
|
|
|
{(pageTitle) => (
|
2016-04-17 15:05:04 +05:30
|
|
|
|
<h2 className={styles.indexTitle}>
|
2016-03-20 14:00:58 +05:30
|
|
|
|
<Helmet title={pageTitle} />
|
|
|
|
|
{pageTitle}
|
|
|
|
|
</h2>
|
|
|
|
|
)}
|
|
|
|
|
</Message>
|
2016-03-17 11:31:11 +05:30
|
|
|
|
|
2016-04-17 15:05:04 +05:30
|
|
|
|
<div className={styles.indexContent}>
|
|
|
|
|
<div className={styles.descriptionColumn}>
|
|
|
|
|
<div className={styles.indexDescription}>
|
|
|
|
|
<Message {...messages.accountDescription} />
|
|
|
|
|
</div>
|
2016-03-17 11:31:11 +05:30
|
|
|
|
</div>
|
|
|
|
|
|
2016-04-17 15:05:04 +05:30
|
|
|
|
<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>
|
2016-03-17 11:31:11 +05:30
|
|
|
|
|
2016-04-17 15:05:04 +05:30
|
|
|
|
<ProfileField
|
2016-05-02 18:43:18 +05:30
|
|
|
|
link="/profile/change-username"
|
2016-04-17 15:05:04 +05:30
|
|
|
|
label={<Message {...messages.nickname} />}
|
|
|
|
|
value={user.username}
|
2016-04-24 00:14:10 +05:30
|
|
|
|
warningMessage={user.hasMojangUsernameCollision ? (
|
2016-06-01 14:42:41 +05:30
|
|
|
|
<Message {...messages.mojangPriorityWarning} values={{
|
|
|
|
|
rules: (
|
|
|
|
|
<Link to={{
|
|
|
|
|
pathname: '/rules',
|
|
|
|
|
hash: `#${RulesPage.getRuleHash(1, 4)}`
|
|
|
|
|
}}>
|
|
|
|
|
<Message {...messages.projectRules} />
|
|
|
|
|
</Link>
|
|
|
|
|
)
|
|
|
|
|
}} />
|
2016-04-24 00:14:10 +05:30
|
|
|
|
) : ''}
|
2016-04-17 15:05:04 +05:30
|
|
|
|
/>
|
2016-03-17 11:31:11 +05:30
|
|
|
|
|
2016-04-17 15:05:04 +05:30
|
|
|
|
<ProfileField
|
2016-05-02 23:02:03 +05:30
|
|
|
|
link="/profile/change-email"
|
2016-05-23 00:47:34 +05:30
|
|
|
|
label={'E‑mail'}
|
2016-04-17 15:05:04 +05:30
|
|
|
|
value={user.email}
|
|
|
|
|
/>
|
2016-03-17 11:31:11 +05:30
|
|
|
|
|
2016-04-17 15:05:04 +05:30
|
|
|
|
<ProfileField
|
|
|
|
|
link="/profile/change-password"
|
2016-05-02 18:43:18 +05:30
|
|
|
|
label={<Message {...messages.password} />}
|
2016-04-17 15:05:04 +05:30
|
|
|
|
value={<Message {...messages.changedAt} values={{
|
2016-05-02 23:12:40 +05:30
|
|
|
|
at: (<Relative value={user.passwordChangedAt * 1000} updateInterval={1000} />)
|
2016-04-17 15:05:04 +05:30
|
|
|
|
}} />}
|
|
|
|
|
/>
|
2016-03-17 11:31:11 +05:30
|
|
|
|
|
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
|
|
|
|
/>
|
|
|
|
|
|
2016-04-17 15:05:04 +05:30
|
|
|
|
<ProfileField
|
2017-11-01 23:12:19 +05:30
|
|
|
|
link={null && '/profile/mfa'}
|
2016-04-17 15:05:04 +05:30
|
|
|
|
label={<Message {...messages.twoFactorAuth} />}
|
2017-08-20 21:15:21 +05:30
|
|
|
|
value={user.isOtpEnabled ? (
|
|
|
|
|
<Message {...messages.enabled} />
|
|
|
|
|
) : (
|
|
|
|
|
<Message {...messages.disabled} />
|
|
|
|
|
)}
|
2016-04-17 15:05:04 +05:30
|
|
|
|
/>
|
2016-03-17 11:31:11 +05:30
|
|
|
|
|
2016-04-17 15:05:04 +05:30
|
|
|
|
<ProfileField
|
|
|
|
|
label={'UUID'}
|
2016-05-26 20:51:52 +05:30
|
|
|
|
value={
|
|
|
|
|
<span
|
|
|
|
|
className={styles.uuid}
|
|
|
|
|
ref={this.setUUID.bind(this)}
|
|
|
|
|
onMouseOver={this.handleUUIDMouseOver.bind(this)}
|
|
|
|
|
>
|
|
|
|
|
{user.uuid}
|
|
|
|
|
</span>
|
|
|
|
|
}
|
2016-04-17 15:05:04 +05:30
|
|
|
|
/>
|
|
|
|
|
</div>
|
2016-03-17 11:31:11 +05:30
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2016-05-26 20:51:52 +05:30
|
|
|
|
|
|
|
|
|
handleUUIDMouseOver() {
|
|
|
|
|
try {
|
|
|
|
|
const selection = window.getSelection();
|
|
|
|
|
const range = document.createRange();
|
|
|
|
|
range.selectNodeContents(this.UUID);
|
|
|
|
|
selection.removeAllRanges();
|
|
|
|
|
selection.addRange(range);
|
2017-01-02 19:07:02 +05:30
|
|
|
|
} catch (err) {
|
|
|
|
|
// the browser does not support an API
|
|
|
|
|
}
|
2016-05-26 20:51:52 +05:30
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setUUID(el) {
|
|
|
|
|
this.UUID = el;
|
|
|
|
|
}
|
2016-03-17 11:31:11 +05:30
|
|
|
|
}
|
2017-05-26 00:41:57 +05:30
|
|
|
|
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
|
|
|
|
export default connect((state) => ({
|
|
|
|
|
user: state.user
|
|
|
|
|
}))(Profile);
|