fix(acl): availableActions

This commit is contained in:
chenos 2022-02-19 17:14:43 +08:00
parent ad38b001c5
commit 407f9d2d85
3 changed files with 13 additions and 9 deletions

View File

@ -6,5 +6,5 @@ export interface AvailableActionOptions {
}
export class AclAvailableAction {
constructor(private name: string, private options: AvailableActionOptions) {}
constructor(public name: string, public options: AvailableActionOptions) {}
}

View File

@ -1,11 +1,15 @@
const availableActionResource = {
name: 'availableActions',
actions: {
async list(ctx, next) {
const acl = ctx.app.acl;
const availableActions = acl.getAvailableActions();
ctx.body = Array.from(availableActions.entries()).map((item) => item[1]);
ctx.body = Array.from(availableActions.entries()).map(([, { name, options }]) => {
return {
...options,
name,
};
});
await next();
},
},

View File

@ -4,28 +4,28 @@ const availableActions: {
[key: string]: AvailableActionOptions;
} = {
create: {
displayName: 't("Create")',
displayName: '{{ t("Create") }}',
type: 'new-data',
},
import: {
displayName: 't("Import")',
displayName: '{{ t("Import") }}',
type: 'new-data',
},
export: {
displayName: 't("Import")',
displayName: '{{ t("Export") }}',
type: 'new-data',
},
view: {
displayName: 't("View")',
displayName: '{{ t("View") }}',
type: 'old-data',
aliases: ['get', 'list'],
},
update: {
displayName: 't("Edit")',
displayName: '{{ t("Edit") }}',
type: 'old-data',
},
destroy: {
displayName: 't("Delete")',
displayName: '{{ t("Delete") }}',
type: 'old-data',
},
};