From 4851f51d8bdb95d8476a5dada955026123a26a5d Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 16 Mar 2020 08:30:15 -0700 Subject: [PATCH] docs: Add documentation for groups API endpoints (#1211) * docs: Add documentation for groups API endpoints fix: Remove useless permission query param * restore permission filter on collections.group_memberships * tweak language --- server/api/groups.js | 17 +--- server/pages/developers/Api.js | 164 ++++++++++++++++++++++++++++++--- 2 files changed, 155 insertions(+), 26 deletions(-) diff --git a/server/api/groups.js b/server/api/groups.js index a64e2141b..82944a6b2 100644 --- a/server/api/groups.js +++ b/server/api/groups.js @@ -148,20 +148,14 @@ router.post('groups.delete', auth(), async ctx => { }); router.post('groups.memberships', auth(), pagination(), async ctx => { - const { id, query, permission } = ctx.body; + const { id, query } = ctx.body; ctx.assertUuid(id, 'id is required'); const user = ctx.state.user; const group = await Group.findByPk(id); - authorize(user, 'read', group); - let where = { - groupId: id, - }; - let userWhere; - if (query) { userWhere = { name: { @@ -170,15 +164,8 @@ router.post('groups.memberships', auth(), pagination(), async ctx => { }; } - if (permission) { - where = { - ...where, - permission, - }; - } - const memberships = await GroupUser.findAll({ - where, + where: { groupId: id }, order: [['createdAt', 'DESC']], offset: ctx.state.pagination.offset, limit: ctx.state.pagination.limit, diff --git a/server/pages/developers/Api.js b/server/pages/developers/Api.js index 1cb463652..a75fcfd0c 100644 --- a/server/pages/developers/Api.js +++ b/server/pages/developers/Api.js @@ -45,7 +45,7 @@ export default function Api() { the token. - + @@ -74,7 +74,7 @@ export default function Api() { /> @@ -144,7 +144,7 @@ export default function Api() { Returns detailed information on a document collection. - + @@ -169,7 +169,7 @@ export default function Api() { folders inside the zip file. - + @@ -232,14 +232,49 @@ export default function Api() { + + + This method allows you to give all members in a group access to a + collection. + + + + + + + + + + This method allows you to revoke all members in a group access to + a collection. Note that members of the group may still retain + access through other groups or individual memberships. + + + + + + + - This method allows you to list a collections memberships. This is - both a collections maintainers, and user permissions for read and - write if the collection is private + This method allows you to list a collections individual + memberships. This is both a collections maintainers, and user + permissions for read and write if the collection is private @@ -251,6 +286,25 @@ export default function Api() { + + + This method allows you to list a collections group memberships. + This is the list of groups that have been given access to the + collection. + + + + + + + + Delete a collection and all of its documents. This action can’t be @@ -629,6 +683,97 @@ export default function Api() { + + + This method allows you to create a new group to organize people in + the team. + + + + + + + + + This method allows you to update an existing group. At this time + the only field that can be edited is the name. + + + + + + + + + + Deleting a group will cause all of its members to lose access to + any collections the group has been given access to. This action + can’t be undone so please be careful. + + + + + + + + Returns detailed information on a group. + + + + + + + + List all groups the current user has access to. + + + + + + + List members in a group, the query parameter allows filtering by + user name. + + + + + + + + + + This method allows you to add a user to a group. + + + + + + + + + + This method allows you to remove a user from a group. + + + + + + + List all your currently shared document links. @@ -783,10 +928,7 @@ const Arguments = (props: ArgumentsProps) => ( - {props.pagination && ( - // $FlowIssue - - )} + {props.pagination && } {props.children}