2016-02-13 20:58:47 +05:30
|
|
|
import React, { PropTypes } from 'react';
|
2016-01-16 17:36:22 +05:30
|
|
|
|
|
|
|
import { FormattedMessage as Message } from 'react-intl';
|
2016-01-16 18:05:12 +05:30
|
|
|
import Helmet from 'react-helmet';
|
2016-01-16 17:36:22 +05:30
|
|
|
|
|
|
|
import buttons from 'components/ui/buttons.scss';
|
|
|
|
import icons from 'components/ui/icons.scss';
|
2016-02-13 20:58:47 +05:30
|
|
|
import { PanelBodyHeader } from 'components/ui/Panel';
|
2016-01-16 17:36:22 +05:30
|
|
|
|
2016-02-13 20:58:47 +05:30
|
|
|
import BaseAuthBody from './BaseAuthBody';
|
2016-01-19 11:47:21 +05:30
|
|
|
import styles from './permissions.scss';
|
|
|
|
import messages from './Permissions.messages';
|
2016-01-16 17:36:22 +05:30
|
|
|
|
2016-02-13 20:58:47 +05:30
|
|
|
class Body extends BaseAuthBody {
|
2016-03-13 14:06:31 +05:30
|
|
|
static displayName = 'PermissionsBody';
|
2016-02-13 20:58:47 +05:30
|
|
|
|
|
|
|
render() {
|
2016-03-13 14:06:31 +05:30
|
|
|
const {user} = this.context;
|
|
|
|
const scopes = this.context.auth.scopes;
|
2016-02-27 16:23:58 +05:30
|
|
|
|
2016-02-13 20:58:47 +05:30
|
|
|
return (
|
2016-01-31 18:29:38 +05:30
|
|
|
<div>
|
2016-02-13 20:58:47 +05:30
|
|
|
{this.renderErrors()}
|
|
|
|
|
2016-01-31 18:29:38 +05:30
|
|
|
<PanelBodyHeader>
|
|
|
|
<div className={styles.authInfo}>
|
|
|
|
<div className={styles.authInfoAvatar}>
|
2016-02-27 16:23:58 +05:30
|
|
|
{user.avatar
|
|
|
|
? <img src={user.avatar} />
|
|
|
|
: <span className={icons.user} />
|
|
|
|
}
|
2016-01-31 18:29:38 +05:30
|
|
|
</div>
|
|
|
|
<div className={styles.authInfoTitle}>
|
|
|
|
<Message {...messages.youAuthorizedAs} />
|
|
|
|
</div>
|
|
|
|
<div className={styles.authInfoEmail}>
|
2016-02-27 16:23:58 +05:30
|
|
|
{user.email}
|
2016-01-31 18:29:38 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</PanelBodyHeader>
|
|
|
|
<div className={styles.permissionsContainer}>
|
|
|
|
<div className={styles.permissionsTitle}>
|
2016-02-06 15:32:23 +05:30
|
|
|
<Message {...messages.theAppNeedsAccess1} /><br />
|
|
|
|
<Message {...messages.theAppNeedsAccess2} />
|
2016-01-31 18:29:38 +05:30
|
|
|
</div>
|
|
|
|
<ul className={styles.permissionsList}>
|
2016-03-02 02:06:14 +05:30
|
|
|
{scopes.map((scope, key) => (
|
|
|
|
<li key={key}>{<Message {...messages[`scope_${scope}`]} />}</li>
|
2016-02-29 23:46:33 +05:30
|
|
|
))}
|
2016-01-31 18:29:38 +05:30
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
2016-02-13 20:58:47 +05:30
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function Permissions() {
|
2016-03-13 14:06:31 +05:30
|
|
|
const componentsMap = {
|
2016-02-13 20:58:47 +05:30
|
|
|
Title: () => ( // TODO: separate component for PageTitle
|
|
|
|
<Message {...messages.permissionsTitle}>
|
|
|
|
{(msg) => <span>{msg}<Helmet title={msg} /></span>}
|
|
|
|
</Message>
|
2016-01-31 18:29:38 +05:30
|
|
|
),
|
2016-02-13 20:58:47 +05:30
|
|
|
Body,
|
2016-01-31 18:29:38 +05:30
|
|
|
Footer: () => (
|
2016-02-13 20:58:47 +05:30
|
|
|
<button className={buttons.orange} autoFocus>
|
2016-01-31 18:29:38 +05:30
|
|
|
<Message {...messages.approve} />
|
|
|
|
</button>
|
|
|
|
),
|
2016-03-13 14:06:31 +05:30
|
|
|
Links: (props, context) => (
|
2016-02-29 23:46:33 +05:30
|
|
|
<a href="#" onClick={(event) => {
|
|
|
|
event.preventDefault();
|
|
|
|
|
2016-03-13 14:06:31 +05:30
|
|
|
context.reject();
|
2016-02-29 23:46:33 +05:30
|
|
|
}}>
|
2016-01-31 18:29:38 +05:30
|
|
|
<Message {...messages.decline} />
|
|
|
|
</a>
|
|
|
|
)
|
|
|
|
};
|
2016-03-13 14:06:31 +05:30
|
|
|
|
|
|
|
componentsMap.Links.contextTypes = {
|
|
|
|
reject: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
return componentsMap;
|
2016-01-31 18:29:38 +05:30
|
|
|
}
|