Fetch page layout by objectMetadataId when feature flag is enabled#17644
Fetch page layout by objectMetadataId when feature flag is enabled#17644
Conversation
Co-authored-by: Devessier <29370468+Devessier@users.noreply.github.com>
Co-authored-by: Devessier <29370468+Devessier@users.noreply.github.com>
Co-authored-by: Devessier <29370468+Devessier@users.noreply.github.com>
|
@copilot you missed one important point: the pageLayoutId won't be guessable as it used to be here. The behavior we want: For dashboards
For record page layoutsFor record page layouts, you must determine the page layout to render by fetching in the If |
- Created FIND_PAGE_LAYOUTS query to fetch layouts by objectMetadataId - Modified useRecordPageLayoutId to query backend for RECORD_PAGE layouts when feature flag is enabled - Reverted PageLayoutInitializationQueryEffect changes (logic now in useRecordPageLayoutId) - Falls back to mock layouts when feature flag is disabled or no backend data found Co-authored-by: Devessier <29370468+Devessier@users.noreply.github.com>
I've implemented the requested behavior. The changes now correctly:
Key changes in commit f15e605:
The pageLayoutId is no longer hardcoded/guessed - it's dynamically fetched from the backend based on the object's metadata ID. |
…ageLayouts - Skip query when objectMetadataItem is not yet loaded - Rename query from FindPageLayouts to GetPageLayouts to match resolver name Co-authored-by: Devessier <29370468+Devessier@users.noreply.github.com>
Co-authored-by: Devessier <29370468+Devessier@users.noreply.github.com>
- Moved query from dashboards module to page-layout module for better code organization - Updated import path in useRecordPageLayoutId Co-authored-by: Devessier <29370468+Devessier@users.noreply.github.com>
- Return null while page layouts are loading to prevent showing wrong layout - Add pageLayoutsLoading to dependency array for proper memoization Co-authored-by: Devessier <29370468+Devessier@users.noreply.github.com>
- Use optional chaining for objectMetadataItem.id in variables - Make skip condition more explicit with separate checks Co-authored-by: Devessier <29370468+Devessier@users.noreply.github.com>
|
I don't really see the point to use this instead of the IDE. Looks slower to iterate and to control IMO |
506f390 to
4513e0b
Compare
|
🚀 Preview Environment Ready! Your preview environment is available at: http://bore.pub:36085 This environment will automatically shut down when the PR is closed or after 5 hours. |
When
IS_RECORD_PAGE_LAYOUT_EDITING_ENABLEDis enabled, page layouts for records should be fetched from the backend by querying withobjectMetadataIdand filtering bytype=RECORD_PAGE, rather than using hardcoded layout IDs.Changes
Created
FIND_PAGE_LAYOUTSGraphQL query:packages/twenty-front/src/modules/page-layout/graphql/queries/findPageLayouts.tsgetPageLayouts(objectMetadataId: String)to fetch page layouts for a specific objectModified
useRecordPageLayoutIdhook:objectMetadataIdto find theRECORD_PAGElayout dynamicallyReverted
PageLayoutInitializationQueryEffect:Behavior
For record page layouts (feature flag enabled):
getPageLayouts(objectMetadataId: <objectMetadataId>)type=RECORD_PAGEnullwhile loadingFor record page layouts (feature flag disabled):
For dashboards:
The pageLayoutId is no longer hardcoded/guessable when the feature flag is active - it's dynamically fetched from the backend based on the object's metadata ID.
Original prompt
Start implementation
[Chronological Review: The conversation began with the user requesting to fetch configuration from the backend for record page layouts when a specific feature flag is active. The user indicated that the current implementation uses mocks and that the configuration is now seeded in the database. The user then specified additional requirements regarding handling cases where the backend returns no data and ensuring records have a populated pageLayoutId. The conversation has focused on planning the implementation of these requirements.][Intent Mapping:
IS_RECORD_PAGE_LAYOUT_EDITING_ENABLEDfeature flag is active." - User wants to change the source of record page layouts from mocks to backend data based on a feature flag.[Technical Inventory:
IS_RECORD_PAGE_LAYOUT_EDITING_ENABLED- Used to toggle between mock data and backend data.pageLayout,pageLayoutTab,pageLayoutWidgets- Where the configuration is seeded.PageLayoutInitializationQueryEffect.tsx.][Code Archaeology:
PageLayoutInitializationQueryEffect.tsxgetDefaultLayoutByIdis defined to retrieve layouts by ID, but further implementation is needed to fetch from the backend.[Progress Assessment:
[Context Validation: All critical information for continuation is captured, including the need to implement backend fetching, fallback logic, and ensuring records are linked to the correct page layout.]
[Recent Commands Analysis:
1. Conversation Overview: - Primary Objectives: 1. "I want you to fetch the configuration from the backend when the `IS_RECORD_PAGE_LAYOUT_EDITING_ENABLED` feature flag is active." 2. "Handle the case where backend returns no data." 3. "Ensure records have pageLayoutId populated." - Session Context: The conversation has focused on transitioning from mock data to backend data for record page layouts, with specific requirements for handling data retrieval and ensuring proper linking of records to layouts. - User Intent Evolution: The user initially sought to implement backend fetching and has since specified additional requirements for error handling and data integrity.- Technical Foundation:
- Feature Flag:
- Database Tables:
- TypeScript: The implementation is in TypeScript, specifically in
- Codebase Status:
- File Name:
- Purpose: Initializes the page layout based on layout ID.
- Current State: User is modifying this file to implement new requirements.
- Key Code Segments: Function
- Dependencies: Interacts with backend for layout configurations.
- Problem Resolution:
- Issues Encountered: Need to handle cases where the backend returns no data and ensure records are linked to layouts.
- Solutions Implemented: User has outlined requirements for fallback logic and data linking.
- Debugging Context: No specific debugging has been reported yet; focus is on planning.
- Lessons Learned: Importance of robust error handling and data integrity in fetching...
IS_RECORD_PAGE_LAYOUT_EDITING_ENABLED- Toggles between mock and backend data.pageLayout,pageLayoutTab,pageLayoutWidgets- Configuration storage.PageLayoutInitializationQueryEffect.tsx.PageLayoutInitializationQueryEffect.tsxgetDefaultLayoutByIdretrieves layouts by ID.Created from VS Code.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.