Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
"description": "Dashboard plugin for AdminForth",
"devDependencies": {
"@types/node": "latest",
"adminforth": "^3.8.2",
"adminforth": "^3.18.0",
"semantic-release": "^24.2.1",
"semantic-release-slack-bot": "^4.0.2",
"typescript": "^5.7.3",
"vue-tsc": "^3.3.2"
},
"peerDependencies": {
"adminforth": "^3.8.2"
"adminforth": "^3.18.0"
},
"release": {
"plugins": [
Expand Down
26 changes: 5 additions & 21 deletions services/widgetDataService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ActionCheckSource, interpretResource, Sorts } from 'adminforth';
import { ActionCheckSource, interpretResource, isBackendOnly, isShown, Sorts, stripBackendOnly } from 'adminforth';
import type {
AdminUser,
IAdminForth,
Expand Down Expand Up @@ -167,27 +167,15 @@ class ResourceDataAccess {
const context = {
adminUser: this.adminUser,
resource,
meta: {},
meta: { requestBody: query, pk: undefined },
source: ActionCheckSource.ListRequest,
adminforth: this.adminforth,
};
const columns = new Map(resource.columns.map((column) => [column.name, column]));

// OperationalResource.list() deliberately returns the connector response as-is.
// Apply the same response masking as AdminForth's list REST endpoint before hooks run.
for (const row of rows) {
for (const key of Object.keys(row)) {
const column = columns.get(key);
const backendOnly = column
? typeof column.backendOnly === 'function'
? await column.backendOnly(context)
: Boolean(column.backendOnly)
: true;

if (!column || backendOnly) {
delete row[key];
}
}
await stripBackendOnly(row, context);
}

const afterDatasourceResponse = resource.hooks?.list?.afterDatasourceResponse;
Expand Down Expand Up @@ -388,12 +376,8 @@ async function assertWidgetQueryHasNoBackendOnlyFields(
source: ActionCheckSource.ListRequest,
adminforth,
};
const backendOnly = typeof column.backendOnly === 'function'
? await column.backendOnly(context)
: column.backendOnly;
const shownInList = typeof column.showIn?.list === 'function'
? await column.showIn.list(context)
: column.showIn?.list !== false;
const backendOnly = await isBackendOnly(column, context);
const shownInList = await isShown(column, 'list', context);

if (backendOnly || !shownInList) {
const restriction = backendOnly ? 'backendOnly' : 'hidden in list view';
Expand Down