Endpoint to allow/disallow runs from table
This commit is contained in:
parent
75b5bbf401
commit
4c4f766a6a
|
@ -95,6 +95,37 @@ export async function remove(ctx: Ctx<void, void>) {
|
||||||
ctx.status = 204
|
ctx.status = 204
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function setTablePermission(ctx: Ctx<void, RowActionResponse>) {
|
||||||
|
const table = await getTable(ctx)
|
||||||
|
const tableId = table._id!
|
||||||
|
const { actionId } = ctx.params
|
||||||
|
|
||||||
|
const action = await sdk.rowActions.setTablePermission(tableId, actionId)
|
||||||
|
ctx.body = {
|
||||||
|
tableId,
|
||||||
|
id: action.id,
|
||||||
|
name: action.name,
|
||||||
|
automationId: action.automationId,
|
||||||
|
allowedSources: flattenAllowedSources(tableId, action.permissions),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function unsetTablePermission(ctx: Ctx<void, RowActionResponse>) {
|
||||||
|
const table = await getTable(ctx)
|
||||||
|
const tableId = table._id!
|
||||||
|
const { actionId } = ctx.params
|
||||||
|
|
||||||
|
const action = await sdk.rowActions.unsetTablePermission(tableId, actionId)
|
||||||
|
|
||||||
|
ctx.body = {
|
||||||
|
tableId,
|
||||||
|
id: action.id,
|
||||||
|
name: action.name,
|
||||||
|
automationId: action.automationId,
|
||||||
|
allowedSources: flattenAllowedSources(tableId, action.permissions),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function setViewPermission(ctx: Ctx<void, RowActionResponse>) {
|
export async function setViewPermission(ctx: Ctx<void, RowActionResponse>) {
|
||||||
const table = await getTable(ctx)
|
const table = await getTable(ctx)
|
||||||
const tableId = table._id!
|
const tableId = table._id!
|
||||||
|
|
|
@ -51,6 +51,16 @@ router
|
||||||
authorized(BUILDER),
|
authorized(BUILDER),
|
||||||
rowActionController.remove
|
rowActionController.remove
|
||||||
)
|
)
|
||||||
|
.post(
|
||||||
|
"/api/tables/:tableId/actions/:actionId/permissions",
|
||||||
|
authorized(BUILDER),
|
||||||
|
rowActionController.setTablePermission
|
||||||
|
)
|
||||||
|
.delete(
|
||||||
|
"/api/tables/:tableId/actions/:actionId/permissions",
|
||||||
|
authorized(BUILDER),
|
||||||
|
rowActionController.unsetTablePermission
|
||||||
|
)
|
||||||
.post(
|
.post(
|
||||||
"/api/tables/:tableId/actions/:actionId/permissions/:viewId",
|
"/api/tables/:tableId/actions/:actionId/permissions/:viewId",
|
||||||
authorized(BUILDER),
|
authorized(BUILDER),
|
||||||
|
|
|
@ -163,6 +163,23 @@ async function guardView(tableId: string, viewId: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function setTablePermission(tableId: string, rowActionId: string) {
|
||||||
|
return await updateDoc(tableId, rowActionId, async actionsDoc => {
|
||||||
|
actionsDoc.actions[rowActionId].permissions.table.runAllowed = true
|
||||||
|
return actionsDoc
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function unsetTablePermission(
|
||||||
|
tableId: string,
|
||||||
|
rowActionId: string
|
||||||
|
) {
|
||||||
|
return await updateDoc(tableId, rowActionId, async actionsDoc => {
|
||||||
|
actionsDoc.actions[rowActionId].permissions.table.runAllowed = false
|
||||||
|
return actionsDoc
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export async function setViewPermission(
|
export async function setViewPermission(
|
||||||
tableId: string,
|
tableId: string,
|
||||||
rowActionId: string,
|
rowActionId: string,
|
||||||
|
|
Loading…
Reference in New Issue