fix: skip developer mode and internal collection permissions

This commit is contained in:
chenos 2021-01-26 15:18:07 +08:00
parent 22ce4c60e7
commit 4fb1ff6c33

View File

@ -69,7 +69,7 @@ const transforms = {
prop.type = 'string' prop.type = 'string'
} }
if (field.get('component.tooltip')) { if (field.get('component.tooltip')) {
prop.description = `{{html('${encodeURIComponent(field.get('component.tooltip'))}')}}`; // prop.description = `{{html('${encodeURIComponent(field.get('component.tooltip'))}')}}`;
} }
if (field.get('name') === 'dataSource') { if (field.get('name') === 'dataSource') {
@ -190,6 +190,11 @@ const transforms = {
export default async (ctx, next) => { export default async (ctx, next) => {
const { resourceName, resourceKey, values = {} } = ctx.action.params; const { resourceName, resourceKey, values = {} } = ctx.action.params;
const [View, Collection, Field, Action] = ctx.db.getModels(['views', 'collections', 'fields', 'actions']) as ModelCtor<Model>[]; const [View, Collection, Field, Action] = ctx.db.getModels(['views', 'collections', 'fields', 'actions']) as ModelCtor<Model>[];
const collection = await Collection.findOne({
where: {
name: resourceName,
},
});
let view = await View.findOne(View.parseApiJson({ let view = await View.findOne(View.parseApiJson({
filter: { filter: {
collection_name: resourceName, collection_name: resourceName,
@ -201,7 +206,10 @@ export default async (ctx, next) => {
})); }));
let throughName; let throughName;
const { resourceKey: resourceKey2, associatedName, resourceFieldName, associatedKey } = values; const { resourceKey: resourceKey2, associatedName, resourceFieldName, associatedKey } = values;
const permissions = await ctx.ac.can(resourceName).permissions(); // TODO: 暂时不处理 developerMode 和 internal 的情况
const permissions = (ctx.ac.isRoot() || collection.developerMode || collection.internal)
? await ctx.ac.getRootPermissions()
: await ctx.ac.can(resourceName).permissions();
ctx.listFields = []; ctx.listFields = [];
ctx.createFields = []; ctx.createFields = [];
ctx.updateFields = []; ctx.updateFields = [];
@ -239,11 +247,7 @@ export default async (ctx, next) => {
// 如果不存在 view新建一个 // 如果不存在 view新建一个
view = new View({type: resourceKey, template: 'FilterForm'}); view = new View({type: resourceKey, template: 'FilterForm'});
} }
const collection = await Collection.findOne({
where: {
name: resourceName,
},
});
// const where: any = { // const where: any = {
// developerMode: ctx.state.developerMode, // developerMode: ctx.state.developerMode,
// } // }