When defining a guard at the moment it is only possible to pass a string. I would like to pass a function so that I can show a specific guard message for each record.
Suggested Solution
In the build-action-click-handler.ts:
if (actionHasDisabledComponent(action)) {
if (action.guard) {
const modalData: ModalData = {
modalProps: {
variant: 'danger',
label: 'confirm',
title: typeof action.guard === 'string' ? action.guard : await action.guard(params),
},
type: 'confirm',
resourceId: params.resourceId,
confirmAction: callApi,
}
// If confirmation is required, action trigger should be handled in modal
openModal(modalData)
return
}
// If no confirmation is required, call API
callApi()
return
}
In the action.interface.ts:
export type GuardFunction = (params: DifferentActionParams) => string | Promise<string>
In the action.interface.d.ts:
guard?: string | GuardFunction
Alternatives
I do not have alternatives
Additional Context
The Function type can maybe be changed to a own interface
Description
When defining a guard at the moment it is only possible to pass a string. I would like to pass a function so that I can show a specific guard message for each record.
Suggested Solution
In the build-action-click-handler.ts:
In the action.interface.ts:
export type GuardFunction = (params: DifferentActionParams) => string | Promise<string>
In the action.interface.d.ts:guard?: string | GuardFunction
Alternatives
I do not have alternatives
Additional Context
The Function type can maybe be changed to a own interface