refactor: Policies Architecture (#1016)
* add policy serialize method * Add policies to collection responses * wip * test: remove .only * refactor: Return policies with team and document requests * store policies on the client * refactor: drive admin UI from policies
This commit is contained in:
@ -23,10 +23,12 @@ import Section from './components/Section';
|
||||
import Header from './components/Header';
|
||||
import SidebarLink from './components/SidebarLink';
|
||||
import HeaderBlock from './components/HeaderBlock';
|
||||
import PoliciesStore from 'stores/PoliciesStore';
|
||||
import AuthStore from 'stores/AuthStore';
|
||||
|
||||
type Props = {
|
||||
history: RouterHistory,
|
||||
policies: PoliciesStore,
|
||||
auth: AuthStore,
|
||||
};
|
||||
|
||||
@ -37,8 +39,11 @@ class SettingsSidebar extends React.Component<Props> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { team, user } = this.props.auth;
|
||||
if (!team || !user) return null;
|
||||
const { policies, auth } = this.props;
|
||||
const { team } = auth;
|
||||
if (!team) return null;
|
||||
|
||||
const can = policies.abilties(team.id);
|
||||
|
||||
return (
|
||||
<Sidebar>
|
||||
@ -71,14 +76,14 @@ class SettingsSidebar extends React.Component<Props> {
|
||||
</Section>
|
||||
<Section>
|
||||
<Header>Team</Header>
|
||||
{user.isAdmin && (
|
||||
{can.update && (
|
||||
<SidebarLink
|
||||
to="/settings/details"
|
||||
icon={<TeamIcon />}
|
||||
label="Details"
|
||||
/>
|
||||
)}
|
||||
{user.isAdmin && (
|
||||
{can.update && (
|
||||
<SidebarLink
|
||||
to="/settings/security"
|
||||
icon={<PadlockIcon />}
|
||||
@ -96,14 +101,14 @@ class SettingsSidebar extends React.Component<Props> {
|
||||
icon={<LinkIcon />}
|
||||
label="Share Links"
|
||||
/>
|
||||
{user.isAdmin && (
|
||||
{can.auditLog && (
|
||||
<SidebarLink
|
||||
to="/settings/events"
|
||||
icon={<BulletedListIcon />}
|
||||
label="Audit Log"
|
||||
/>
|
||||
)}
|
||||
{user.isAdmin && (
|
||||
{can.export && (
|
||||
<SidebarLink
|
||||
to="/settings/export"
|
||||
icon={<DocumentIcon />}
|
||||
@ -111,7 +116,7 @@ class SettingsSidebar extends React.Component<Props> {
|
||||
/>
|
||||
)}
|
||||
</Section>
|
||||
{user.isAdmin && (
|
||||
{can.update && (
|
||||
<Section>
|
||||
<Header>Integrations</Header>
|
||||
<SidebarLink
|
||||
@ -133,4 +138,4 @@ class SettingsSidebar extends React.Component<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
export default inject('auth')(SettingsSidebar);
|
||||
export default inject('auth', 'policies')(SettingsSidebar);
|
||||
|
Reference in New Issue
Block a user