Refactor isSameActionUrl function in ObjectActions component for clarity

- Updated the isSameActionUrl function to improve readability and maintainability.
- Enhanced comments to clarify the logic behind action URL comparison and visibility control for actions based on the current page state.
This commit is contained in:
Tom Butcher 2026-08-09 23:20:35 +01:00
parent 469907ef59
commit 7065cd312b

View File

@ -74,12 +74,12 @@ function isSameActionUrl(action, actionUrl, currentUrl, pathname, search) {
if (action.type === 'modal') { if (action.type === 'modal') {
return actionUrl === currentUrl return actionUrl === currentUrl
} }
return ( // Compare the action URL to the current location with its action param
stripPageActionParams( // stripped. Default page actions (e.g. Info) match and stay hidden when
actionUrl.split('?')[0], // already on that page. Actions that set their own action param (edit,
actionUrl.includes('?') ? actionUrl.split('?')[1] : '' // cancelEdit, finishEdit, etc.) do not match and remain available
) === stripPageActionParams(pathname, search) // visibility is controlled by action.visible (e.g. _isEditing).
) return actionUrl === stripPageActionParams(pathname, search)
} }
// Recursively map actions to AntD Dropdown items // Recursively map actions to AntD Dropdown items