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:
@ -25,12 +25,14 @@ import Bubble from './components/Bubble';
|
||||
|
||||
import AuthStore from 'stores/AuthStore';
|
||||
import DocumentsStore from 'stores/DocumentsStore';
|
||||
import PoliciesStore from 'stores/PoliciesStore';
|
||||
import UiStore from 'stores/UiStore';
|
||||
import { observable } from 'mobx';
|
||||
|
||||
type Props = {
|
||||
auth: AuthStore,
|
||||
documents: DocumentsStore,
|
||||
policies: PoliciesStore,
|
||||
ui: UiStore,
|
||||
};
|
||||
|
||||
@ -55,11 +57,12 @@ class MainSidebar extends React.Component<Props> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { auth, documents } = this.props;
|
||||
const { auth, documents, policies } = this.props;
|
||||
const { user, team } = auth;
|
||||
if (!user || !team) return null;
|
||||
|
||||
const draftDocumentsCount = documents.drafts.length;
|
||||
const can = policies.abilties(team.id);
|
||||
|
||||
return (
|
||||
<Sidebar>
|
||||
@ -125,7 +128,7 @@ class MainSidebar extends React.Component<Props> {
|
||||
documents.active ? documents.active.isArchived : undefined
|
||||
}
|
||||
/>
|
||||
{user.isAdmin && (
|
||||
{can.invite && (
|
||||
<SidebarLink
|
||||
onClick={this.handleInviteModalOpen}
|
||||
icon={<PlusIcon />}
|
||||
@ -151,4 +154,4 @@ const Drafts = styled(Flex)`
|
||||
height: 24px;
|
||||
`;
|
||||
|
||||
export default inject('documents', 'auth', 'ui')(MainSidebar);
|
||||
export default inject('documents', 'policies', 'auth', 'ui')(MainSidebar);
|
||||
|
Reference in New Issue
Block a user