From 407f9d2d85d4ed172fe2e80ebc73a9bd14cf537e Mon Sep 17 00:00:00 2001 From: chenos Date: Sat, 19 Feb 2022 17:14:43 +0800 Subject: [PATCH] fix(acl): availableActions --- packages/acl/src/acl-available-action.ts | 2 +- packages/plugin-acl/src/actions/available-actions.ts | 8 ++++++-- packages/server/src/acl/available-action.ts | 12 ++++++------ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/acl/src/acl-available-action.ts b/packages/acl/src/acl-available-action.ts index 2bcd0b52f1..2bb4667a3c 100644 --- a/packages/acl/src/acl-available-action.ts +++ b/packages/acl/src/acl-available-action.ts @@ -6,5 +6,5 @@ export interface AvailableActionOptions { } export class AclAvailableAction { - constructor(private name: string, private options: AvailableActionOptions) {} + constructor(public name: string, public options: AvailableActionOptions) {} } diff --git a/packages/plugin-acl/src/actions/available-actions.ts b/packages/plugin-acl/src/actions/available-actions.ts index 97120ab30b..4eb17f9229 100644 --- a/packages/plugin-acl/src/actions/available-actions.ts +++ b/packages/plugin-acl/src/actions/available-actions.ts @@ -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(); }, }, diff --git a/packages/server/src/acl/available-action.ts b/packages/server/src/acl/available-action.ts index 41c5cf84ec..5db264bf71 100644 --- a/packages/server/src/acl/available-action.ts +++ b/packages/server/src/acl/available-action.ts @@ -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', }, };