Add danger property to action items in ObjectActions component and refine action filtering logic

This commit is contained in:
Tom Butcher 2025-07-14 23:08:33 +01:00
parent 5aa7355b0f
commit a0ab5be6f2

View File

@ -14,6 +14,7 @@ function mapActionsToMenuItems(actions, currentUrlWithActions, id) {
const item = { const item = {
key: action.key || action.name, key: action.key || action.name,
label: action.label, label: action.label,
danger: action?.danger || false,
icon: action.icon ? React.createElement(action.icon) : undefined, icon: action.icon ? React.createElement(action.icon) : undefined,
disabled: actionUrl && actionUrl === currentUrlWithActions disabled: actionUrl && actionUrl === currentUrlWithActions
} }
@ -53,11 +54,10 @@ const ObjectActions = ({
location.search location.search
) )
console.log('curr url', currentUrlWithoutActions)
// Filter out actions whose url matches currentUrl
const filteredActions = actions.filter( const filteredActions = actions.filter(
(action) => !(action.url(id) && action.url(id) === currentUrlWithoutActions) (action) =>
typeof action.url !== 'function' ||
action.url(id) !== currentUrlWithoutActions
) )
const currentUrlWithActions = location.pathname + location.search const currentUrlWithActions = location.pathname + location.search