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