Use flag for views
This commit is contained in:
parent
a646b86131
commit
cda7782c6d
|
@ -1,6 +1,7 @@
|
||||||
import {
|
import {
|
||||||
CalculationType,
|
CalculationType,
|
||||||
canGroupBy,
|
canGroupBy,
|
||||||
|
FeatureFlag,
|
||||||
FieldType,
|
FieldType,
|
||||||
isNumeric,
|
isNumeric,
|
||||||
PermissionLevel,
|
PermissionLevel,
|
||||||
|
@ -13,7 +14,7 @@ import {
|
||||||
ViewV2ColumnEnriched,
|
ViewV2ColumnEnriched,
|
||||||
ViewV2Enriched,
|
ViewV2Enriched,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { context, docIds, HTTPError } from "@budibase/backend-core"
|
import { context, docIds, features, HTTPError } from "@budibase/backend-core"
|
||||||
import {
|
import {
|
||||||
helpers,
|
helpers,
|
||||||
PROTECTED_EXTERNAL_COLUMNS,
|
PROTECTED_EXTERNAL_COLUMNS,
|
||||||
|
@ -244,12 +245,17 @@ export async function create(
|
||||||
|
|
||||||
const view = await pickApi(tableId).create(tableId, viewRequest)
|
const view = await pickApi(tableId).create(tableId, viewRequest)
|
||||||
|
|
||||||
// Set permissions to be the same as the table
|
const setExplicitPermission = await features.flags.isEnabled(
|
||||||
const tablePerms = await sdk.permissions.getResourcePerms(tableId)
|
FeatureFlag.TABLES_DEFAULT_ADMIN
|
||||||
await sdk.permissions.setPermissions(view.id, {
|
)
|
||||||
writeRole: tablePerms[PermissionLevel.WRITE].role,
|
if (setExplicitPermission) {
|
||||||
readRole: tablePerms[PermissionLevel.READ].role,
|
// Set permissions to be the same as the table
|
||||||
})
|
const tablePerms = await sdk.permissions.getResourcePerms(tableId)
|
||||||
|
await sdk.permissions.setPermissions(view.id, {
|
||||||
|
writeRole: tablePerms[PermissionLevel.WRITE].role,
|
||||||
|
readRole: tablePerms[PermissionLevel.READ].role,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue