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:
parent
469907ef59
commit
7065cd312b
@ -74,12 +74,12 @@ function isSameActionUrl(action, actionUrl, currentUrl, pathname, search) {
|
||||
if (action.type === 'modal') {
|
||||
return actionUrl === currentUrl
|
||||
}
|
||||
return (
|
||||
stripPageActionParams(
|
||||
actionUrl.split('?')[0],
|
||||
actionUrl.includes('?') ? actionUrl.split('?')[1] : ''
|
||||
) === stripPageActionParams(pathname, search)
|
||||
)
|
||||
// Compare the action URL to the current location with its action param
|
||||
// stripped. Default page actions (e.g. Info) match and stay hidden when
|
||||
// already on that page. Actions that set their own action param (edit,
|
||||
// cancelEdit, finishEdit, etc.) do not match and remain available —
|
||||
// visibility is controlled by action.visible (e.g. _isEditing).
|
||||
return actionUrl === stripPageActionParams(pathname, search)
|
||||
}
|
||||
|
||||
// Recursively map actions to AntD Dropdown items
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user