Skip to main content

AdminForthBulkAction

Extends

Properties

action()

action: (__namedParameters) => Promise<object>

Callback which will be called on backend when user clicks on action button. It should return Promise which will be resolved when action is done.

Parameters

ParameterType
__namedParametersobject
__namedParameters.adminUserAdminUser
__namedParameters.resourceAdminForthResource
__namedParameters.selectedIdsany[]

Returns

Promise<object>

error?

optional error: string

ok

ok: boolean

successMessage?

optional successMessage: string


allowed()?

optional allowed: (__namedParameters) => Promise<boolean>

Allowed callback called to check whether action is allowed for user.

  1. It called first time when user goes to list view. If callback returns false, action button will be hidden on list view.
  2. This same callback called second time when user clicks an action button. If callback returns false, action will not be executed. In second time selectedIds will be passed to callback (because checkbox for items are selected), so you can use this to make additional checks ( for example to check if user has permission for certain records ).

Example:

allowed: async ({ resource, adminUser, selectedIds }) => {
if (adminUser.dbUser.role !== 'superadmin') {
return false;
}
return true;
}

Parameters

ParameterTypeDescription
__namedParametersobject-
__namedParameters.adminUserAdminUserAdmin user object
__namedParameters.allowedActionsAllowedActionsResolved

Allowed standard actions for current user resolved by calling allowedActions callbacks if they are passed. You can use this variable to rely on standard actions permissions. E.g. if you have custom actions "Mark as read", you might want to allow it only for users who have "edit" action allowed:

Example:

options: {

bulkActions: [

{

label: 'Mark as read',

action: async ({ resource, recordIds }) => {

await markAsRead(recordIds);

},

allowed: ({ allowedActions }) => allowedActions.edit,

}

],

allowedActions: {

edit: ({ resource, adminUser, recordIds }) => {

return adminUser.dbUser.role === 'superadmin';

}

}

}

__namedParameters.resourceAdminForthResource-
__namedParameters.selectedIds?any[]recordIds will be passed only once user tries to perform bulk action by clicking on button

Returns

Promise<boolean>


confirm?

optional confirm: string

Confirmation message which will be displayed to user before action is executed.

Inherited from

AdminForthBulkActionCommon . confirm


icon?

optional icon: string

Icon for action button which will be displayed in the list view

Inherited from

AdminForthBulkActionCommon . icon


id?

optional id: string

Inherited from

AdminForthBulkActionCommon . id


label

label: string

Label for action button which will be displayed in the list view

Inherited from

AdminForthBulkActionCommon . label


state

state: string

Inherited from

AdminForthBulkActionCommon . state


successMessage?

optional successMessage: string

Success message which will be displayed to user after action is executed.

Inherited from

AdminForthBulkActionCommon . successMessage