Внедрена зависимость от router для компонента RulesPage

Добавлен тайтл для страницы правил
Проброшена ссылка на пункт правил для предупреждения о нике на странице профиля
This commit is contained in:
ErickSkrauch 2016-06-01 12:12:41 +03:00
parent d9309662f2
commit 9c7073a422
7 changed files with 60 additions and 16 deletions

View File

@ -3,7 +3,8 @@
"personalData": "Personal data",
"accountDescription": "Ely.by account allows you to get access to many Minecraft resources. Please, take care of your account safety. Use secure password and change it regularly.",
"preferencesDescription": "Here you can change the key preferences of your account. Please note that all actions must be confirmed by entering a password.",
"mojangPriorityWarning": "A Mojang account with the same nickname was found. According to project rules, account owner has the right to demand the restoration of control over nickname.",
"mojangPriorityWarning": "A Mojang account with the same nickname was found. According to {rules}, account owner has the right to demand the restoration of control over nickname.",
"projectRules": "project rules",
"oldHashingAlgoWarning": "Your was hashed with an old hashing algorithm.<br />Please, change password.",
"changedAt": "Changed {at}",
"disabled": "Disabled",

View File

@ -1,6 +1,7 @@
import React, { Component } from 'react';
import { FormattedMessage as Message, FormattedRelative as Relative, FormattedHTMLMessage as HTMLMessage } from 'react-intl';
import { Link } from 'react-router';
import Helmet from 'react-helmet';
import { userShape } from 'components/user/User';
@ -12,6 +13,8 @@ import styles from './profile.scss';
import profileForm from './profileForm.scss';
import messages from './Profile.intl.json';
import RulesPage from 'pages/rules/RulesPage';
export default class Profile extends Component {
static displayName = 'Profile';
static propTypes = {
@ -55,7 +58,16 @@ export default class Profile extends Component {
label={<Message {...messages.nickname} />}
value={user.username}
warningMessage={user.hasMojangUsernameCollision ? (
<Message {...messages.mojangPriorityWarning} />
<Message {...messages.mojangPriorityWarning} values={{
rules: (
<Link to={{
pathname: '/rules',
hash: `#${RulesPage.getRuleHash(1, 4)}`
}}>
<Message {...messages.projectRules} />
</Link>
)
}} />
) : ''}
/>

View File

@ -95,6 +95,16 @@ $formColumnWidth: 416px;
color: $red;
font-size: 11px;
line-height: 1.2;
a {
color: $red;
border-bottom: 1px dashed transparent;
transition: .25s;
&:hover {
border-bottom-color: lighter($red);
}
}
}
.uuid {

View File

@ -104,7 +104,7 @@
"components.profile.changeUsername.changeUsernameWarning": "Be careful: if you playing on the server with nickname binding, then after changing nickname you may lose all your progress.",
"components.profile.changedAt": "Changed {at}",
"components.profile.disabled": "Disabled",
"components.profile.mojangPriorityWarning": "A Mojang account with the same nickname was found. According to project rules, account owner has the right to demand the restoration of control over nickname.",
"components.profile.mojangPriorityWarning": "A Mojang account with the same nickname was found. According to {rules}, account owner has the right to demand the restoration of control over nickname.",
"components.profile.nickname": "Nickname",
"components.profile.oldHashingAlgoWarning": "Your was hashed with an old hashing algorithm.<br />Please, change password.",
"components.profile.password": "Password",
@ -112,6 +112,7 @@
"components.profile.passwordRequestForm.title": "Confirm your action",
"components.profile.personalData": "Personal data",
"components.profile.preferencesDescription": "Here you can change the key preferences of your account. Please note that all actions must be confirmed by entering a password.",
"components.profile.projectRules": "project rules",
"components.profile.twoFactorAuth": "Two factor auth",
"components.userbar.logout": "Logout",
"components.userbar.register": "Join",
@ -134,6 +135,7 @@
"pages.rules.mainProvision3": "Ely.by is side project, that has nothing to do with Mojang and Microsoft companies. We don't provide support to Minecraft premium accounts, and we have nothing to do with servers that use or don't use our services.",
"pages.rules.mainProvision4": "The registration of the users account at server is free. Account creation Ely.by is only possible at that page {link}.",
"pages.rules.mainProvisions": "Main provisions",
"pages.rules.title": "Site rules",
"services.accountAlreadyActivated": "This account is already activated",
"services.accountNotActivated": "The account is not activated",
"services.doYouWantRequestKey": "Do you want to request a new key?",

View File

@ -104,7 +104,7 @@
"components.profile.changeUsername.changeUsernameWarning": "Будьте внимательны: если вы играли на сервере с привязкой по нику, то после смены ника вы можете утратить весь свой прогресс.",
"components.profile.changedAt": "Изменен {at}",
"components.profile.disabled": "Не включена",
"components.profile.mojangPriorityWarning": "Найден аккаунт Mojang с таким же ником и, по правилам проекта, его владелец вправе потребовать восстановления контроля над ником.",
"components.profile.mojangPriorityWarning": "Найден аккаунт Mojang с таким же ником и, по {rules}, его владелец вправе потребовать восстановления контроля над ником.",
"components.profile.nickname": "Ник",
"components.profile.oldHashingAlgoWarning": "Для пароля применяется старый алгоритм хэширования<br />Пожалуйста, смените пароль.",
"components.profile.password": "Пароль",
@ -112,6 +112,7 @@
"components.profile.passwordRequestForm.title": "Confirm your action",
"components.profile.personalData": "Персональные данные",
"components.profile.preferencesDescription": "Здесь вы можете сменить ключевые параметры вашего аккаунта. Обратите внимание, что для всех действий необходимо подтверждение при помощи ввода пароля.",
"components.profile.projectRules": "правилам проекта",
"components.profile.twoFactorAuth": "Двухфакторная аутентификация",
"components.userbar.logout": "Выход",
"components.userbar.register": "Регистрация",
@ -134,6 +135,7 @@
"pages.rules.mainProvision3": "Ely.by является сторонней разработкой, не имеющей никакого отношения к компаниям Mojang и Microsoft. Мы не оказываем поддержки по премиум аккаунтам Minecraft, а также никак не связаны с игровыми серверами, использующими или не использующими наши сервисы.",
"pages.rules.mainProvision4": "Регистрация пользовательского аккаунта на сервисе бесплатна. Создание аккаунта Ely.by возможно только на странице {link}.",
"pages.rules.mainProvisions": "Основные положения",
"pages.rules.title": "Правила сайта",
"services.accountAlreadyActivated": "Этот аккаунт уже активирован",
"services.accountNotActivated": "Аккаунт не активирован",
"services.doYouWantRequestKey": "Не хотите отправить новый код?",

View File

@ -1,4 +1,6 @@
{
"title" : "Site rules",
"mainProvisions": "Main provisions",
"mainProvision1": "{name} service was created for the organization of safety access to Ely.by's users accounts, his partners and any side project that wish to use one of the our's services",
"mainProvision2": "We (here and in the next points) - Ely.by project developers team that make creating qualitative services for Minecraft community.",

View File

@ -1,7 +1,8 @@
import React, { Component, PropTypes } from 'react';
import { Link, browserHistory } from 'react-router';
import { Link } from 'react-router';
import { FormattedMessage as Message } from 'react-intl';
import Helmet from 'react-helmet';
import { FooterMenu } from 'components/footerMenu';
@ -64,6 +65,13 @@ export default class RulesPage extends Component {
})
};
static contextTypes = {
router: PropTypes.shape({
createLocation: PropTypes.func.required,
replace: PropTypes.func.required
}).isRequired
};
render() {
let {hash} = this.props.location;
if (hash) {
@ -72,14 +80,20 @@ export default class RulesPage extends Component {
return (
<div>
<Message {...messages.title}>
{(pageTitle) => (
<Helmet title={pageTitle} />
)}
</Message>
<div className={styles.rules}>
{rules.map((block, sectionIndex) => (
<div className={styles.rulesSection} key={sectionIndex}>
<h2
className={classNames(styles.rulesSectionTitle, {
[styles.target]: this.getTitleHash(sectionIndex) === hash
[styles.target]: RulesPage.getTitleHash(sectionIndex) === hash
})}
id={this.getTitleHash(sectionIndex)}
id={RulesPage.getTitleHash(sectionIndex)}
>
{block.title}
</h2>
@ -94,11 +108,11 @@ export default class RulesPage extends Component {
{block.items.map((item, ruleIndex) => (
<li
className={classNames(styles.rulesItem, {
[styles.target]: this.getRuleHash(sectionIndex, ruleIndex) === hash
[styles.target]: RulesPage.getRuleHash(sectionIndex, ruleIndex) === hash
})}
key={ruleIndex}
id={this.getRuleHash(sectionIndex, ruleIndex)}
onClick={this.onRuleClick}
id={RulesPage.getRuleHash(sectionIndex, ruleIndex)}
onClick={this.onRuleClick.bind(this)}
>
{item}
</li>
@ -116,17 +130,18 @@ export default class RulesPage extends Component {
}
onRuleClick(event) {
const id = event.currentTarget.id;
const newLocation = browserHistory.createLocation({...location, hash: `#${id}`});
browserHistory.replace(newLocation);
const {id} = event.currentTarget;
const {router} = this.context;
const newLocation = router.createLocation({...location, hash: `#${id}`});
router.replace(newLocation);
}
getTitleHash(sectionIndex) {
static getTitleHash(sectionIndex) {
return `rule-${sectionIndex + 1}`;
}
getRuleHash(sectionIndex, ruleIndex) {
return `rule-${sectionIndex + 1}-${ruleIndex + 1}`;
static getRuleHash(sectionIndex, ruleIndex) {
return `${RulesPage.getTitleHash(sectionIndex)}-${ruleIndex + 1}`;
}
}