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:
Tom Moor
2019-08-21 21:41:37 -07:00
committed by GitHub
parent cf18b952a4
commit e2b28dfeb7
20 changed files with 194 additions and 19 deletions

View File

@@ -11,6 +11,7 @@ import presentTeam from './team';
import presentIntegration from './integration';
import presentNotificationSetting from './notificationSetting';
import presentSlackAttachment from './slackAttachment';
import presentPolicies from './policy';
export {
presentUser,
@@ -25,4 +26,5 @@ export {
presentIntegration,
presentNotificationSetting,
presentSlackAttachment,
presentPolicies,
};

View File

@@ -0,0 +1,13 @@
// @flow
import { User } from '../models';
type Policy = { id: string, abilities: { [key: string]: boolean } };
export default function present(user: User, objects: Object[]): Policy[] {
const { serialize } = require('../policies');
return objects.map(object => ({
id: object.id,
abilities: serialize(user, object),
}));
}