mirror of
https://github.com/twentyhq/twenty
synced 2026-04-21 13:37:22 +00:00
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:
parent
8e53ba0f4a
commit
c7bc3542e4
1 changed files with 12 additions and 21 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue