Integrate NavigationMenuItem with feature flag support#17268
Integrate NavigationMenuItem with feature flag support#17268etiennejouan merged 187 commits intomainfrom
Conversation
- Introduced `FlatNavigationMenuItem` type to represent navigation menu items. - Created `FlatNavigationMenuItemMaps` type for mapping entities. - Added `FLAT_NAVIGATION_MENU_ITEM_EDITABLE_PROPERTIES` constant to define editable properties for flat navigation menu items.
- Created a new migration to add the `navigationMenuItem` table in the core schema. - Defined columns, primary key, and foreign key constraints. - Added necessary indexes for improved query performance.
- Introduced `navigationMenuItem` to `ALL_FLAT_ENTITY_PROPERTIES_TO_COMPARE_AND_STRINGIFY` for comparison and stringification. - Added `navigationMenuItem` relations to `ALL_METADATA_RELATIONS`. - Updated validation requirements for `navigationMenuItem` in `ALL_METADATA_REQUIRED_METADATA_FOR_VALIDATION`. - Defined actions for `navigationMenuItem` in `AllFlatEntityTypesByMetadataName`. - Created new action types for navigation menu item migrations.
- Introduced `FlatNavigationMenuItemModule` to manage navigation menu items. - Created `WorkspaceFlatNavigationMenuItemMapCacheService` for caching logic related to flat navigation menu items. - Added utility function `fromNavigationMenuItemEntityToFlatNavigationMenuItem` for transforming entities. - Updated workspace cache keys to include `flatNavigationMenuItemMaps` for improved cache management.
- Introduced `NavigationMenuItemException` for handling navigation menu item errors with user-friendly messages. - Created `WorkspaceMigrationNavigationMenuItemActionsBuilderService` for managing navigation menu item actions during migration. - Added `FlatNavigationMenuItemValidatorService` to validate creation, deletion, and updates of navigation menu items. - Implemented action handlers for creating, updating, and deleting navigation menu items in the migration runner. - Updated the workspace migration builder module to include navigation menu item services and validators.
…pport - Integrated `WorkspaceMigrationNavigationMenuItemActionsBuilderService` into the orchestrator for handling navigation menu item actions during migration. - Implemented validation and building logic for navigation menu items, including error handling and action reporting. - Updated the orchestrator to merge navigation menu item results into the overall migration report.
- Introduced `NavigationMenuItemModule` to encapsulate navigation menu item functionality. - Created service and resolver for managing navigation menu items, including creation, update, and deletion operations. - Added input and DTO types for navigation menu item operations. - Implemented utility functions for transforming navigation menu item data and handling exceptions. - Integrated navigation menu item support into the existing metadata engine structure.
- Updated `optimisticallyApplyCreateActionOnAllFlatEntityMaps`, `optimisticallyApplyDeleteActionOnAllFlatEntityMaps`, and `optimisticallyApplyUpdateActionOnAllFlatEntityMaps` utilities to include support for `navigationMenuItem`. - Enhanced the handling of navigation menu items during optimistic actions in the workspace migration process.
- Introduced `NavigationMenuItem` type to the GraphQL schema, defining its fields and types for better integration with navigation menu functionalities. - This addition supports the ongoing development of navigation menu item features and enhances the overall schema structure.
- Introduced mutations for creating, deleting, and updating navigation menu items, enhancing the GraphQL API for navigation functionalities. - Added corresponding query support to retrieve navigation menu items, improving data accessibility and management within the application. - Defined input types for navigation menu item operations to streamline data handling and validation.
- Included `NavigationMenuItemEntity` in the `ALL_METADATA_ENTITY_BY_METADATA_NAME` constant to support navigation menu functionalities. - This addition enhances the metadata structure for better integration with navigation features.
…em files - Updated TypeScript imports to use type-only imports for better clarity. - Enhanced formatting in various utility and service files related to navigation menu items for improved readability. - Adjusted method signatures to align with consistent formatting practices across the codebase. - Refactored migration file for `NavigationMenuItemEntity` to maintain consistent query formatting. These changes aim to enhance code maintainability and readability across the navigation menu item functionalities.
…ity file - Renamed the index for target record object metadata in both the migration file and the entity definition to improve clarity and consistency. - This change enhances the maintainability of the database schema and aligns with naming conventions.
- Introduced comprehensive integration tests for creating, updating, and deleting navigation menu items, covering both successful and failing scenarios. - Added utility functions for creating and deleting navigation menu items to streamline test setup. - Enhanced test coverage to ensure robust validation of input parameters and error handling for navigation menu item operations. - These additions improve the overall reliability and maintainability of the navigation menu item functionalities.
…rage - Modified the `favoriteFolderId` property in `UpdateNavigationMenuItemInput` to accept `null` as a valid value, improving flexibility in navigation menu item updates. - Updated integration tests to verify the behavior of setting `favoriteFolderId` to `null`, ensuring comprehensive coverage of this scenario. - Adjusted import statements for consistency and clarity across utility files related to navigation menu item operations.
- Adjusted the formatting of the `input` object in the failing navigation menu item update integration test for improved readability. - Reformatted the export statement in the update navigation menu item query factory utility file to enhance clarity and maintain consistent code style.
…lity - Adjusted the formatting of the error message in the `createNavigationMenuItem` utility for better readability and consistency with coding standards.
- Adjusted the import statements in the `failing-navigation-menu-item-update.integration-spec.ts` file for better organization and clarity. - Moved the `findManyObjectMetadata` import to maintain consistency with other utility imports and improve readability.
…stency - Adjusted the import statements in the `delete-navigation-menu-item.util.ts` file to improve organization and maintain consistency with other utility files. - This change enhances code readability and aligns with recent formatting updates across navigation menu item functionalities.
…hql.ts - Moved the Apollo import statement to improve organization. - Introduced a new type definition for QueryNavigationMenuItemArgs to enhance GraphQL query capabilities. - Minor formatting adjustments for consistency with existing code.
- Added a new snapshot for the `getMetadataRelatedMetadataNames` utility to include the `navigationMenuItem`. - Updated the snapshot for `sortMetadataNamesChildrenFirst` to reflect the addition of `navigationMenuItem` in the sorted output. - Minor adjustment to the snapshot comment for clarity.
- Changed validation decorators for `position` in both `create-navigation-menu-item.input.ts` and `update-navigation-menu-item.input.ts` from `@IsNumber()` to `@IsInt()` and added `@Min(0)` to ensure non-negative integer values. - Added new snapshot tests for failing scenarios in navigation menu item creation, deletion, and update to enhance validation coverage and error handling.
- Added checks to ensure that the `position` property for navigation menu items is a non-negative integer during both creation and update processes. - Updated error handling to return specific validation messages for invalid position inputs. - Adjusted snapshot tests to reflect changes in validation error responses for negative position scenarios.
- Modified the error message in the snapshot for the failing navigation menu item deletion test to accurately reflect the variable name in the GraphQL error response. - This change ensures consistency in error reporting and improves the clarity of test outputs.
…Ds in navigation menu item utility - Updated the utility function to normalize checks for `forWorkspaceMemberId` and `favoriteFolderId` by using null coalescing, improving the robustness of the existing item filtering logic. - This change enhances the accuracy of item comparisons when creating navigation menu items.
- Introduced `NavigationMenuItemDeletionJob` to handle deletion of navigation menu items associated with deleted records. - Added `NavigationMenuItemDeletionListener` to listen for database delete events and trigger the deletion job. - Implemented `NavigationMenuItemDeletionService` to manage the deletion logic and validation. - Updated `jobs.module.ts` to include the new deletion job and listener. - Enhanced `navigation-menu-item.module.ts` with necessary imports and providers for the new functionality.
- Enhanced `DeleteSingleRecordAction` to remove associated navigation menu items when a record is deleted. - Introduced `useRemoveNavigationMenuItemByTargetRecordId` hook to manage the removal of navigation menu items from the state and Apollo cache. - Updated `useDeleteManyRecords`, `useDestroyManyRecords`, and `useIncrementalDeleteManyRecords` hooks to handle navigation menu item removal for multiple records. - Added feature flag check to conditionally execute navigation menu item removal logic.
- Refactored `useCreateNavigationMenuItem` to handle view-specific logic for creating navigation menu items. - Added checks for the existence of object metadata items and improved error handling. - Integrated navigation menu item creation into `ViewPickerOptionDropdown`, allowing users to create menu items directly from the view picker. - Introduced feature flag to conditionally enable navigation menu item functionality based on user settings.
- Introduced `STANDARD_NAVIGATION_MENU_ITEMS` constant to define navigation menu items with their identifiers and positions. - Added utility functions for building and creating flat metadata for navigation menu items. - Updated existing constants to include `navigationMenuItem` in `TWENTY_STANDARD_ALL_METADATA_NAME`. - Refactored `computeTwentyStandardApplicationAllFlatEntityMaps` to integrate navigation menu item maps into the overall flat entity maps structure.
There was a problem hiding this comment.
1 issue found across 6 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/services/twenty-standard-application.service.ts">
<violation number="1">
P2: This now always seeds Favorites even when the navigation menu item feature flag is enabled, so workspaces with the flag won’t get NavigationMenuItems created. Restore the feature-flagged branch to create navigation menu items when enabled.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| @@ -3,10 +3,12 @@ import { Injectable } from '@nestjs/common'; | |||
| import { isDefined } from 'twenty-shared/utils'; | |||
There was a problem hiding this comment.
P2: This now always seeds Favorites even when the navigation menu item feature flag is enabled, so workspaces with the flag won’t get NavigationMenuItems created. Restore the feature-flagged branch to create navigation menu items when enabled.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/services/twenty-standard-application.service.ts, line 225:
<comment>This now always seeds Favorites even when the navigation menu item feature flag is enabled, so workspaces with the flag won’t get NavigationMenuItems created. Restore the feature-flagged branch to create navigation menu items when enabled.</comment>
<file context>
@@ -223,16 +222,9 @@ export class TwentyStandardApplicationService {
- workspaceId,
- });
- }
+ await this.createManyFavorite({
+ flatViews,
+ workspaceId,
</file context>
...nty-server/src/engine/metadata-modules/navigation-menu-item/navigation-menu-item.resolver.ts
Show resolved
Hide resolved
- Removed dependency on objectMetadataItemsState and CoreObjectNameSingular for filtering views. - Streamlined the views mapping process by directly converting core views without additional filtering logic.
… metadata creation - Changed the import of `isDefined` from 'class-validator' to 'twenty-shared/utils' to streamline utility usage across the project.
- Reordered the output in the snapshot to reflect the correct sorting of metadata names, ensuring "viewFilter" appears after "navigationMenuItem" as intended.
- Added "view" to the expected output in the snapshot for the getMetadataRelatedMetadataNames utility, ensuring it reflects the latest changes in related metadata names.
- Updated the MainNavigationDrawerScrollableItems component to use React's lazy loading for CurrentWorkspaceMemberNavigationMenuItemFoldersDispatcher and WorkspaceNavigationMenuItemsDispatcher, improving performance by reducing initial load time. Wrapped components in Suspense for better loading management.
etiennejouan
left a comment
There was a problem hiding this comment.
Great ! Good for me. I've tested it works great !
One last thing to check :
- why company record nav menu item does not display with tim@apple.dev user on Apple wk
Concerning navigation menu item deletion, it should be dropped when related record is deleted or destroy (seen with bonapara), you're right ! you can ignore my comment related to record deletion
...les/action-menu/actions/record-actions/single-record/components/DeleteSingleRecordAction.tsx
Show resolved
Hide resolved
...-front/src/modules/navigation-menu-item/hooks/useRemoveNavigationMenuItemByTargetRecordId.ts
Show resolved
Hide resolved
packages/twenty-front/src/modules/object-record/hooks/useDeleteManyRecords.ts
Show resolved
Hide resolved
| private readonly messageQueueService: MessageQueueService, | ||
| ) {} | ||
|
|
||
| @OnDatabaseBatchEvent('*', DatabaseEventAction.DELETED) |
There was a problem hiding this comment.
Same, it may need to ask product insight but I would drop navigation menu item on DatabaseEventAction.DESTROY
There was a problem hiding this comment.
Can be nice for api user, you to decide. But in addition, not destroy instead of delete
...gine/metadata-modules/navigation-menu-item/services/navigation-menu-item-deletion.service.ts
Show resolved
Hide resolved
- Renamed the function to remove navigation menu items by target record IDs for clarity and updated the implementation to support deleting multiple items at once. This change enhances the flexibility of the delete action in the navigation menu.
- Introduced a new utility function `getMinimalSelectForRecordIdentifier` to optimize the selection of fields when retrieving navigation menu items. - Updated the `NavigationMenuItemService` to utilize this utility for more efficient database queries, ensuring only necessary fields are selected. - Added formatting for the retrieved records to maintain consistency in data structure.
…tion menu items - Integrated functionality to delete navigation menu items alongside favorites when the corresponding feature flag is enabled. - Added hooks for fetching navigation menu items and checking feature availability. - Improved the click handler to conditionally delete navigation menu items based on their existence and the feature flag status.
- Replaced the use of `includes` with a `Set` for `deletedRecordIds` to improve performance when filtering navigation menu items for deletion. This change enhances the efficiency of the deletion process by reducing the time complexity of lookups.
etiennejouan
left a comment
There was a problem hiding this comment.
LGTM ! Nice job and nice catch on the permission issue! 👏
|
Hey @etiennejouan! After you've done the QA of your Pull Request, you can mark it as done here. Thank you! |
1 similar comment
|
Hey @etiennejouan! After you've done the QA of your Pull Request, you can mark it as done here. Thank you! |
LogDetails |
Implements a new syncable `navigationMenuItem` entity in the core schema to replace the workspace `favorite` entity. ## Next Steps - Frontend integration ([separate PR](twentyhq#17268)) - Data migration (separate PR)
Implement Navigation Menu Items Frontend
Implements the frontend for navigation menu items, the new system replacing favorites.
Changes
Migration Note
The favorites and navigation menu item modules currently exist in parallel. The favorites code will be removed once all data has been migrated to navigation menu items.
Note
Replaces Favorites with feature-flagged
NavigationMenuItemacross frontend and backend, while keeping Favorites as fallback until migration completes.navigation-menu-itemcomponents (folders, orphan items, drag provider/droppable, icons, skeleton), dispatcher components to switch from Favorites, and updated “Add to favorites” action to createNavigationMenuItemwhenIS_NAVIGATION_MENU_ITEM_ENABLEDvalidateAndExtractFolderIdand droppable id utils moved toui/layout/draggable-list; favorites DnD updated to use shared utilsRecordIdentifierandtargetRecordIdentifieronNavigationMenuItemNavigationMenuItem,RecordIdentifier), resolvertargetRecordIdentifierfield, service logic to fetch record identifiers with permission-aware access and image signing,getRecordImageIdentifierutil, entity relation toview, and migration adding FK onviewIdIS_NAVIGATION_MENU_ITEM_ENABLEDto enums, dev seeder enables it; standard app seeds workspace navigation menu items instead of favorites when flag onWritten by Cursor Bugbot for commit c99746f. This will update automatically on new commits. Configure here.