Set/unset
This commit is contained in:
parent
5f3dcda73a
commit
2aa71ab419
|
@ -87,3 +87,19 @@ export async function remove(ctx: Ctx<void, void>) {
|
|||
await sdk.rowActions.remove(table._id!, actionId)
|
||||
ctx.status = 204
|
||||
}
|
||||
|
||||
export async function setViewPermission(ctx: Ctx<void, void>) {
|
||||
const table = await getTable(ctx)
|
||||
const { actionId, viewId } = ctx.params
|
||||
|
||||
await sdk.rowActions.setViewPermission(table._id!, actionId, viewId)
|
||||
ctx.status = 204
|
||||
}
|
||||
|
||||
export async function unsetViewPermission(ctx: Ctx<void, void>) {
|
||||
const table = await getTable(ctx)
|
||||
const { actionId, viewId } = ctx.params
|
||||
|
||||
await sdk.rowActions.unsetViewPermission(table._id!, actionId, viewId)
|
||||
ctx.status = 204
|
||||
}
|
||||
|
|
|
@ -50,6 +50,16 @@ router
|
|||
authorizedResource(PermissionType.TABLE, PermissionLevel.READ, "tableId"),
|
||||
rowActionController.remove
|
||||
)
|
||||
.post(
|
||||
"/api/tables/:tableId/actions/:actionId/permissions/:viewId",
|
||||
authorizedResource(PermissionType.TABLE, PermissionLevel.READ, "tableId"),
|
||||
rowActionController.setViewPermission
|
||||
)
|
||||
.delete(
|
||||
"/api/tables/:tableId/actions/:actionId/permissions/:viewId",
|
||||
authorizedResource(PermissionType.TABLE, PermissionLevel.READ, "tableId"),
|
||||
rowActionController.unsetViewPermission
|
||||
)
|
||||
|
||||
// Other endpoints
|
||||
.post(
|
||||
|
|
|
@ -158,6 +158,25 @@ export async function setViewPermission(
|
|||
}
|
||||
}
|
||||
|
||||
export async function unsetViewPermission(
|
||||
tableId: string,
|
||||
rowActionId: string,
|
||||
viewId: string
|
||||
) {
|
||||
const actionsDoc = await get(tableId)
|
||||
|
||||
const rowAction = getRowAction(actionsDoc, rowActionId)
|
||||
delete rowAction.permissions.views[viewId]
|
||||
|
||||
const db = context.getAppDB()
|
||||
await db.put(actionsDoc)
|
||||
|
||||
return {
|
||||
id: rowActionId,
|
||||
...rowAction,
|
||||
}
|
||||
}
|
||||
|
||||
export async function remove(tableId: string, rowActionId: string) {
|
||||
const actionsDoc = await get(tableId)
|
||||
|
||||
|
|
Loading…
Reference in New Issue