@@ -49,6 +49,7 @@ export async function interpretResource(
4949 [ ActionCheckSource . CreateRequest ] : [ 'create' ] ,
5050 [ ActionCheckSource . DisplayButtons ] : [ 'show' , 'edit' , 'delete' , 'create' , 'filter' ] ,
5151 [ ActionCheckSource . BulkActionRequest ] : [ 'show' , 'edit' , 'delete' , 'create' , 'filter' ] ,
52+ [ ActionCheckSource . CustomActionRequest ] : [ 'show' , 'edit' , 'delete' , 'create' , 'filter' ] ,
5253 } [ source ] ;
5354
5455 await Promise . all (
@@ -1058,13 +1059,33 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
10581059 if ( ! resource ) {
10591060 return { error : await tr ( `Resource {resourceId} not found` , 'errors' , { resourceId } ) } ;
10601061 }
1061- console . log ( "resource" , actionId ) ;
1062+ const { allowedActions } = await interpretResource (
1063+ adminUser ,
1064+ resource ,
1065+ { requestBody : body } ,
1066+ ActionCheckSource . CustomActionRequest ,
1067+ this . adminforth
1068+ ) ;
10621069 const action = resource . options . actions . find ( ( act ) => act . id == actionId ) ;
10631070 if ( ! action ) {
10641071 return { error : await tr ( `Action {actionId} not found` , 'errors' , { actionId } ) } ;
10651072 }
1066-
1067- const response = await action . action ( { recordId, adminUser, resource, tr } ) ;
1073+ if ( action . allowed ) {
1074+ const execAllowed = await action . allowed ( { adminUser, standardAllowedActions : allowedActions } ) ;
1075+ if ( ! execAllowed ) {
1076+ return { error : await tr ( `Action "{actionId}" not allowed` , 'errors' , { actionId : action . name } ) } ;
1077+ }
1078+ }
1079+
1080+ if ( action . url ) {
1081+ return {
1082+ actionId,
1083+ recordId,
1084+ resourceId,
1085+ redirectUrl : action . url
1086+ }
1087+ }
1088+ const response = await action . action ( { recordId, adminUser, resource, tr, adminforth : this . adminforth } ) ;
10681089
10691090 return {
10701091 actionId,
0 commit comments