@adminforth/foreign-inline-list
Advanced tools
Comparing version 1.0.20 to 1.0.21
@@ -11,2 +11,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import { AdminForthPlugin, AdminForthResourcePages } from "adminforth"; | ||
import { interpretResource, ActionCheckSource } from "adminforth"; | ||
export default class ForeignInlineListPlugin extends AdminForthPlugin { | ||
@@ -25,3 +26,3 @@ constructor(options) { | ||
path: `/plugin/${this.pluginInstanceId}/get_resource`, | ||
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body }) { | ||
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser }) { | ||
const resource = this.adminforth.config.resources.find((res) => this.options.foreignResourceId === res.resourceId); | ||
@@ -33,7 +34,10 @@ if (!resource) { | ||
const resourceCopy = JSON.parse(JSON.stringify(Object.assign(Object.assign({}, resource), { plugins: undefined }))); | ||
const { allowedActions } = yield interpretResource(adminUser, resource, {}, ActionCheckSource.DisplayButtons); | ||
if (this.options.modifyTableResourceConfig) { | ||
this.options.modifyTableResourceConfig(resourceCopy); | ||
} | ||
return { resource: resourceCopy }; | ||
}), | ||
return { | ||
resource: Object.assign(Object.assign({}, resourceCopy), { options: Object.assign(Object.assign({}, resourceCopy.options), { allowedActions }) }) | ||
}; | ||
}) | ||
}); | ||
@@ -40,0 +44,0 @@ } |
18
index.ts
@@ -11,4 +11,4 @@ | ||
import { PluginOptions } from "./types.js"; | ||
import { interpretResource, ActionCheckSource } from "adminforth"; | ||
export default class ForeignInlineListPlugin extends AdminForthPlugin { | ||
@@ -33,3 +33,3 @@ foreignResource: AdminForthResource; | ||
path: `/plugin/${this.pluginInstanceId}/get_resource`, | ||
handler: async ({ body }) => { | ||
handler: async ({ body, adminUser }) => { | ||
const resource = this.adminforth.config.resources.find((res) => this.options.foreignResourceId === res.resourceId); | ||
@@ -41,2 +41,4 @@ if (!resource) { | ||
const resourceCopy = JSON.parse(JSON.stringify({ ...resource, plugins: undefined })); | ||
const { allowedActions } = await interpretResource(adminUser, resource, {}, ActionCheckSource.DisplayButtons); | ||
@@ -46,4 +48,12 @@ if (this.options.modifyTableResourceConfig) { | ||
} | ||
return { resource: resourceCopy }; | ||
}, | ||
return { | ||
resource: { | ||
...resourceCopy, | ||
options: { | ||
...resourceCopy.options, | ||
allowedActions, | ||
}, | ||
} | ||
}; | ||
} | ||
}); | ||
@@ -50,0 +60,0 @@ |
{ | ||
"name": "@adminforth/foreign-inline-list", | ||
"version": "1.0.20", | ||
"version": "1.0.21", | ||
"description": "AdminForth plugin for adding list of children items to the parent item show page", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
44627
422