Refactor folder navigation menu item URL matching logic
- Simplified the logic for determining if a folder navigation menu item matches the current URL by consolidating the retrieval of object metadata. - Removed redundant checks and streamlined the flow for better readability and maintainability.
This commit is contained in:
+12
-21
@@ -39,33 +39,24 @@ export const doesFolderNavigationMenuItemMatchUrlForSelection = ({
|
||||
computedLink,
|
||||
);
|
||||
|
||||
const objectMetadataForRecordShowMatch =
|
||||
!matchesByLink &&
|
||||
folderChildNavigationMenuItem.type === NavigationMenuItemType.OBJECT
|
||||
? getObjectMetadataForNavigationMenuItem(
|
||||
folderChildNavigationMenuItem,
|
||||
objectMetadataItems,
|
||||
views,
|
||||
)
|
||||
: undefined;
|
||||
|
||||
const matchesByRecordShow =
|
||||
isDefined(objectMetadataForRecordShowMatch) &&
|
||||
matchesRecordShowPathForObject(
|
||||
currentPath,
|
||||
objectMetadataForRecordShowMatch.nameSingular,
|
||||
);
|
||||
|
||||
if (!matchesByLink && !matchesByRecordShow) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const objectMetadataForFolderChild = getObjectMetadataForNavigationMenuItem(
|
||||
folderChildNavigationMenuItem,
|
||||
objectMetadataItems,
|
||||
views,
|
||||
);
|
||||
|
||||
const matchesByRecordShow =
|
||||
!matchesByLink &&
|
||||
isDefined(objectMetadataForFolderChild) &&
|
||||
matchesRecordShowPathForObject(
|
||||
currentPath,
|
||||
objectMetadataForFolderChild.nameSingular,
|
||||
);
|
||||
|
||||
if (!matchesByLink && !matchesByRecordShow) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isDefined(objectMetadataForFolderChild)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user