Skip to content

Commit 808bb81

Browse files
committed
fix: rebuild
1 parent 32490de commit 808bb81

File tree

1 file changed

+1
-75
lines changed

1 file changed

+1
-75
lines changed

index.ts

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { interpretResource, ActionCheckSource } from "adminforth";
1111

1212
export default class ForeignInlineListPlugin extends AdminForthPlugin {
1313
foreignResource: AdminForthResource;
14+
copyOfForeignResource: AdminForthResource;
1415
options: PluginOptions;
1516
adminforth: IAdminForth;
1617

@@ -26,81 +27,6 @@ export default class ForeignInlineListPlugin extends AdminForthPlugin {
2627
}
2728

2829
setupEndpoints(server: IHttpServer) {
29-
process.env.HEAVY_DEBUG && console.log(`🪲 ForeignInlineListPlugin.setupEndpoints, registering: '/plugin/${this.pluginInstanceId}/get_resource'`);
30-
server.endpoint({
31-
method: 'POST',
32-
path: `/plugin/${this.pluginInstanceId}/get_resource`,
33-
handler: async ({ body, adminUser }) => {
34-
const resource = this.adminforth.config.resources.find((res) => this.options.foreignResourceId === res.resourceId);
35-
if (!resource) {
36-
return { error: `Resource ${this.options.foreignResourceId} not found` };
37-
}
38-
// exclude "plugins" key
39-
const resourceCopy = clone({ ...resource, plugins: undefined });
40-
41-
if (this.options.modifyTableResourceConfig) {
42-
this.options.modifyTableResourceConfig(resourceCopy);
43-
}
44-
45-
const { allowedActions } = await interpretResource(adminUser, resourceCopy, {}, ActionCheckSource.DisplayButtons, this.adminforth);
46-
47-
return {
48-
resource: {
49-
...resourceCopy,
50-
options: {
51-
...resourceCopy.options,
52-
allowedActions,
53-
},
54-
}
55-
};
56-
}
57-
});
58-
server.endpoint({
59-
method: 'POST',
60-
path: `/plugin/${this.pluginInstanceId}/start_bulk_action`,
61-
handler: async ({ body, adminUser, tr }) => {
62-
const { resourceId, actionId, recordIds } = body;
63-
const resource = this.adminforth.config.resources.find((res) => res.resourceId == resourceId);
64-
if (!resource) {
65-
return { error: await tr(`Resource {resourceId} not found`, 'errors', { resourceId }) };
66-
}
67-
68-
const resourceCopy = JSON.parse(JSON.stringify({ ...resource, plugins: undefined }));
69-
70-
71-
if (this.options.modifyTableResourceConfig) {
72-
this.options.modifyTableResourceConfig(resourceCopy);
73-
}
74-
75-
const { allowedActions } = await interpretResource(
76-
adminUser,
77-
resourceCopy,
78-
{ requestBody: body },
79-
ActionCheckSource.BulkActionRequest,
80-
this.adminforth
81-
);
82-
83-
const action = resourceCopy.options.bulkActions.find((act) => act.id == actionId);
84-
if (!action) {
85-
return { error: await tr(`Action {actionId} not found`, 'errors', { actionId }) };
86-
}
87-
88-
if (action.allowed) {
89-
const execAllowed = await action.allowed({ adminUser, resourceCopy, selectedIds: recordIds, allowedActions });
90-
if (!execAllowed) {
91-
return { error: await tr(`Action "{actionId}" not allowed`, 'errors', { actionId: action.label }) };
92-
}
93-
}
94-
const response = await action.action({selectedIds: recordIds, adminUser, resourceCopy, tr});
95-
96-
return {
97-
actionId,
98-
recordIds,
99-
resourceId,
100-
...response
101-
}
102-
}
103-
})
10430
server.endpoint({
10531
method: 'POST',
10632
path: `/plugin/${this.pluginInstanceId}/get_default_filters`,

0 commit comments

Comments
 (0)