Check views
This commit is contained in:
parent
0ece6a4d2d
commit
b461025639
|
@ -514,8 +514,12 @@ describe("/rowsActions", () => {
|
|||
2
|
||||
)
|
||||
|
||||
const viewId1 = generator.guid()
|
||||
const viewId2 = generator.guid()
|
||||
const { id: viewId1 } = await config.api.viewV2.create(
|
||||
setup.structures.viewV2.createRequest(tableId)
|
||||
)
|
||||
const { id: viewId2 } = await config.api.viewV2.create(
|
||||
setup.structures.viewV2.createRequest(tableId)
|
||||
)
|
||||
|
||||
await config.api.rowAction.setViewPermission(
|
||||
tableId,
|
||||
|
@ -584,8 +588,12 @@ describe("/rowsActions", () => {
|
|||
|
||||
const [actionId] = _.sampleSize(Object.keys(persisted.actions), 1)
|
||||
|
||||
const viewId1 = generator.guid()
|
||||
const viewId2 = generator.guid()
|
||||
const { id: viewId1 } = await config.api.viewV2.create(
|
||||
setup.structures.viewV2.createRequest(tableId)
|
||||
)
|
||||
const { id: viewId2 } = await config.api.viewV2.create(
|
||||
setup.structures.viewV2.createRequest(tableId)
|
||||
)
|
||||
|
||||
await config.api.rowAction.setViewPermission(tableId, viewId1, actionId, {
|
||||
status: 200,
|
||||
|
|
|
@ -141,11 +141,19 @@ export async function update(
|
|||
})
|
||||
}
|
||||
|
||||
async function guardView(tableId: string, viewId: string) {
|
||||
const view = await sdk.views.get(viewId)
|
||||
if (!view || view.tableId !== tableId) {
|
||||
throw new HTTPError(`View '${viewId}' not found in '${tableId}'`, 400)
|
||||
}
|
||||
}
|
||||
|
||||
export async function setViewPermission(
|
||||
tableId: string,
|
||||
rowActionId: string,
|
||||
viewId: string
|
||||
) {
|
||||
await guardView(tableId, viewId)
|
||||
return await updateDoc(tableId, rowActionId, async actionsDoc => {
|
||||
actionsDoc.actions[rowActionId].permissions.views[viewId] = {
|
||||
runAllowed: true,
|
||||
|
@ -159,6 +167,7 @@ export async function unsetViewPermission(
|
|||
rowActionId: string,
|
||||
viewId: string
|
||||
) {
|
||||
await guardView(tableId, viewId)
|
||||
return await updateDoc(tableId, rowActionId, async actionsDoc => {
|
||||
delete actionsDoc.actions[rowActionId].permissions.views[viewId]
|
||||
return actionsDoc
|
||||
|
|
|
@ -30,6 +30,7 @@ import {
|
|||
BBReferenceFieldSubType,
|
||||
JsonFieldSubType,
|
||||
AutoFieldSubType,
|
||||
CreateViewRequest,
|
||||
} from "@budibase/types"
|
||||
import { LoopInput } from "../../definitions/automations"
|
||||
import { merge } from "lodash"
|
||||
|
@ -145,6 +146,17 @@ export function view(tableId: string) {
|
|||
}
|
||||
}
|
||||
|
||||
function viewV2CreateRequest(tableId: string): CreateViewRequest {
|
||||
return {
|
||||
tableId,
|
||||
name: generator.guid(),
|
||||
}
|
||||
}
|
||||
|
||||
export const viewV2 = {
|
||||
createRequest: viewV2CreateRequest,
|
||||
}
|
||||
|
||||
export function automationStep(
|
||||
actionDefinition = BUILTIN_ACTION_DEFINITIONS.CREATE_ROW
|
||||
): AutomationStep {
|
||||
|
|
Loading…
Reference in New Issue