Skip to content

[FRONT COMPONENTS] Serialize relation between widget and front component#18228

Merged
charlesBochet merged 1 commit intomainfrom
r--serialize-relation-between-widget-and-front-component
Feb 25, 2026
Merged

[FRONT COMPONENTS] Serialize relation between widget and front component#18228
charlesBochet merged 1 commit intomainfrom
r--serialize-relation-between-widget-and-front-component

Conversation

@bosiraphael
Copy link
Contributor

This allows us to define page layout widgets of type front component in an app with the front component universal identifier.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 15 files

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 25, 2026

Greptile Summary

Adds serialization support for the relationship between page layout widgets and front components using universal identifiers, allowing apps to define widgets of type FRONT_COMPONENT with proper relation handling.

Key Changes:

  • Changed frontComponentId type from string to SerializedRelation in shared types and DTOs
  • Implemented bidirectional conversion between frontComponentId and frontComponentUniversalIdentifier for FRONT_COMPONENT widget configuration
  • Added FrontComponentEntity to TypeORM modules and cache services for universal identifier mapping
  • Integrated flatFrontComponentMaps throughout widget creation, update, and duplication flows
  • Added proper error handling when front component universal identifiers are not found

Implementation:
The PR follows the existing pattern used for other serialized relations (like field metadata and views) by:

  1. Fetching front components and building ID-to-universal-identifier maps in cache services
  2. Converting IDs to universal identifiers during serialization (from-page-layout-widget-configuration-to-universal-configuration.util.ts)
  3. Converting universal identifiers back to IDs during deserialization (from-universal-configuration-to-flat-page-layout-widget-configuration.util.ts)
  4. Passing flatFrontComponentMaps through all relevant service layers

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation consistently follows established patterns for serialized relations, includes proper error handling, and touches only the necessary files for this feature. The changes are well-structured, type-safe, and maintain consistency with existing codebase conventions.
  • No files require special attention

Important Files Changed

Filename Overview
packages/twenty-server/src/engine/metadata-modules/flat-page-layout-widget/services/workspace-flat-page-layout-widget-map-cache.service.ts Injected FrontComponentEntity repository, fetched front components, and mapped IDs to universal identifiers for serialization
packages/twenty-server/src/engine/metadata-modules/flat-page-layout-widget/utils/from-page-layout-widget-configuration-to-universal-configuration.util.ts Implemented serialization logic for FRONT_COMPONENT widget type, converting frontComponentId to frontComponentUniversalIdentifier
packages/twenty-server/src/engine/metadata-modules/page-layout-widget/dtos/front-component-configuration.dto.ts Changed frontComponentId type from string to SerializedRelation for proper type branding
packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/action-handlers/page-layout-widget/services/utils/from-universal-configuration-to-flat-page-layout-widget-configuration.util.ts Implemented deserialization logic for FRONT_COMPONENT widget type, converting frontComponentUniversalIdentifier back to frontComponentId
packages/twenty-shared/src/types/page-layout/page-layout-widget-configuration.type.ts Changed frontComponentId type from string to SerializedRelation in shared type definition

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Page Layout Widget Configuration] -->|Contains| B[frontComponentId: SerializedRelation]
    B -->|Serialization| C[fromPageLayoutWidgetConfigurationToUniversalConfiguration]
    C -->|Converts| D[frontComponentUniversalIdentifier]
    D -->|Stored in| E[FlatPageLayoutWidget]
    E -->|Migration/Deserialization| F[fromUniversalConfigurationToFlatPageLayoutWidgetConfiguration]
    F -->|Converts back| B
    
    G[FrontComponentEntity] -->|Fetched by| H[WorkspaceFlatPageLayoutWidgetMapCacheService]
    H -->|Creates| I[frontComponentUniversalIdentifierById Map]
    I -->|Used by| C
    I -->|Used by| F
    
    J[Widget Create/Update Operations] -->|Fetch| K[flatFrontComponentMaps]
    K -->|Provides| I
    K -->|Passed to| C
    K -->|Passed to| F
Loading

Last reviewed commit: 782e625

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

15 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@charlesBochet charlesBochet merged commit 435e21d into main Feb 25, 2026
50 of 90 checks passed
@charlesBochet charlesBochet deleted the r--serialize-relation-between-widget-and-front-component branch February 25, 2026 14:01
@twenty-eng-sync
Copy link

Hey @bosiraphael! After you've done the QA of your Pull Request, you can mark it as done here. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants