fix: tab permissions does not work

This commit is contained in:
chenos 2021-01-27 16:46:31 +08:00
parent 598584447f
commit 8ec40d32e2

View File

@ -8,6 +8,9 @@ export default async (ctx, next) => {
name: resourceName, name: resourceName,
}, },
})); }));
const permissions = (await ctx.ac.isRoot() || collection.developerMode || collection.internal)
? await ctx.ac.getRootPermissions()
: await ctx.ac.can(resourceName).permissions();
const defaultView = await collection.getViews({ const defaultView = await collection.getViews({
where: { where: {
default: true, default: true,
@ -18,8 +21,10 @@ export default async (ctx, next) => {
collection.setDataValue('defaultViewName', defaultView.get('name')); collection.setDataValue('defaultViewName', defaultView.get('name'));
const options = Tab.parseApiJson({ const options = Tab.parseApiJson({
filter: ctx.state.developerMode ? { filter: ctx.state.developerMode ? {
'id.in': permissions.tabs,
enabled: true, enabled: true,
} : { } : {
'id.in': permissions.tabs,
enabled: true, enabled: true,
developerMode: {'$isFalsy': true}, developerMode: {'$isFalsy': true},
}, },