@@ -70,7 +70,7 @@ export async function interpretResource(
70
70
} )
71
71
) ;
72
72
73
- const resolveVisible = async ( val : any ) : Promise < boolean > => {
73
+ const resolveAllowed = async ( val : any ) : Promise < boolean > => {
74
74
if ( typeof val === 'boolean' ) return val ;
75
75
if ( typeof val === 'function' ) {
76
76
const r = val ( { adminUser, resource, meta, source, adminforth } ) ;
@@ -79,17 +79,11 @@ export async function interpretResource(
79
79
return true ;
80
80
} ;
81
81
82
- const pageMap = {
82
+ const page : 'list' | 'show' | 'edit' = ( {
83
83
[ ActionCheckSource . ListRequest ] : 'list' ,
84
84
[ ActionCheckSource . ShowRequest ] : 'show' ,
85
85
[ 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' ;
93
87
94
88
const isColumnVisible = async ( col : any ) : Promise < boolean > => {
95
89
const si = col . showIn ;
@@ -99,8 +93,8 @@ export async function interpretResource(
99
93
return si . includes ( 'all' ) || si . includes ( page ) ;
100
94
}
101
95
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 ) ;
104
98
return true ;
105
99
} ;
106
100
0 commit comments