You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.2 KiB
87 lines
2.2 KiB
4 years ago
|
import classnames from 'classnames';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import React, { PureComponent } from 'react';
|
||
|
import CheckBox from '../../ui/check-box';
|
||
5 years ago
|
|
||
5 years ago
|
export default class ConnectedAccountsPermissions extends PureComponent {
|
||
5 years ago
|
static contextTypes = {
|
||
|
t: PropTypes.func.isRequired,
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
|
static defaultProps = {
|
||
|
permissions: [],
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
|
static propTypes = {
|
||
4 years ago
|
permissions: PropTypes.arrayOf(
|
||
|
PropTypes.shape({
|
||
|
key: PropTypes.string.isRequired,
|
||
|
}),
|
||
|
),
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
|
state = {
|
||
|
expanded: false,
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
|
toggleExpanded = () => {
|
||
|
this.setState((prevState) => ({
|
||
|
expanded: !prevState.expanded,
|
||
4 years ago
|
}));
|
||
|
};
|
||
5 years ago
|
|
||
4 years ago
|
render() {
|
||
4 years ago
|
const { permissions } = this.props;
|
||
|
const { t } = this.context;
|
||
|
const { expanded } = this.state;
|
||
5 years ago
|
|
||
|
if (permissions.length === 0) {
|
||
4 years ago
|
return null;
|
||
5 years ago
|
}
|
||
|
|
||
|
return (
|
||
|
<div className="connected-accounts-permissions">
|
||
4 years ago
|
<p
|
||
|
className="connected-accounts-permissions__header"
|
||
|
onClick={this.toggleExpanded}
|
||
|
>
|
||
5 years ago
|
<strong>{t('permissions')}</strong>
|
||
|
<button
|
||
|
className={classnames('fas', {
|
||
|
'fa-angle-down': !expanded,
|
||
|
'fa-angle-up': expanded,
|
||
|
})}
|
||
|
title={t('showPermissions')}
|
||
|
/>
|
||
|
</p>
|
||
5 years ago
|
<div
|
||
4 years ago
|
className={classnames(
|
||
|
'connected-accounts-permissions__list-container',
|
||
|
{
|
||
|
'connected-accounts-permissions__list-container--expanded': expanded,
|
||
|
},
|
||
|
)}
|
||
5 years ago
|
>
|
||
|
<p>{t('authorizedPermissions')}:</p>
|
||
|
<ul className="connected-accounts-permissions__list">
|
||
5 years ago
|
{permissions.map(({ key: permissionName }) => (
|
||
4 years ago
|
<li
|
||
|
key={permissionName}
|
||
|
className="connected-accounts-permissions__list-item"
|
||
|
>
|
||
|
<CheckBox
|
||
|
checked
|
||
|
disabled
|
||
|
id={permissionName}
|
||
|
className="connected-accounts-permissions__checkbox"
|
||
|
/>
|
||
4 years ago
|
<label htmlFor={permissionName}>{t(permissionName)}</label>
|
||
5 years ago
|
</li>
|
||
|
))}
|
||
|
</ul>
|
||
|
</div>
|
||
5 years ago
|
</div>
|
||
4 years ago
|
);
|
||
5 years ago
|
}
|
||
|
}
|