Skip to content

Commit c7cb3be

Browse files
committed
Revert "refactor: rename resolveAllowed to resolveVisible and update page handling logic"
This reverts commit 2526a03.
1 parent 2526a03 commit c7cb3be

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

adminforth/modules/restApi.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export async function interpretResource(
7070
})
7171
);
7272

73-
const resolveVisible = async (val: any): Promise<boolean> => {
73+
const resolveAllowed = async (val: any): Promise<boolean> => {
7474
if (typeof val === 'boolean') return val;
7575
if (typeof val === 'function') {
7676
const r = val({ adminUser, resource, meta, source, adminforth });
@@ -79,17 +79,11 @@ export async function interpretResource(
7979
return true;
8080
};
8181

82-
const pageMap = {
82+
const page: 'list' | 'show' | 'edit' = ({
8383
[ActionCheckSource.ListRequest]: 'list',
8484
[ActionCheckSource.ShowRequest]: 'show',
8585
[ActionCheckSource.EditLoadRequest]: 'edit',
86-
} as const;
87-
88-
const page = pageMap[source as keyof typeof pageMap] as ('list'|'show'|'edit') | undefined;
89-
90-
if (!page) {
91-
return { allowedActions, visibleColumns: {} };
92-
}
86+
} as const)[source] ?? 'show';
9387

9488
const isColumnVisible = async (col: any): Promise<boolean> => {
9589
const si = col.showIn;
@@ -99,8 +93,8 @@ export async function interpretResource(
9993
return si.includes('all') || si.includes(page);
10094
}
10195

102-
if (si[page] !== undefined) return await resolveVisible(si[page]);
103-
if (si.all !== undefined) return await resolveVisible(si.all);
96+
if (si[page] !== undefined) return await resolveAllowed(si[page]);
97+
if (si.all !== undefined) return await resolveAllowed(si.all);
10498
return true;
10599
};
106100

0 commit comments

Comments
 (0)