Skip to content

Create a feature flag for dashboards v2#15601

Merged
bosiraphael merged 7 commits intomainfrom
create-feature-flag-for-dashboards-v2
Nov 4, 2025
Merged

Create a feature flag for dashboards v2#15601
bosiraphael merged 7 commits intomainfrom
create-feature-flag-for-dashboards-v2

Conversation

@bosiraphael
Copy link
Copy Markdown
Contributor

Prevent users from creating v2 chart types via the api.
Only created unit tests and not integration tests (since it's not that important, and the v2 will be released soon), but tested via the api playground.

Copy link
Copy Markdown
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.

Greptile Overview

Greptile Summary

Introduces a feature flag IS_DASHBOARD_V2_ENABLED to control access to new chart types (PIE, LINE, GAUGE) in the dashboard system.

Key changes:

  • Added backend validation that prevents creating/updating widgets with v2 chart types when the feature flag is disabled
  • Frontend disables v2 chart type selection when feature flag is not enabled
  • Refactored validateAndTransformWidgetConfiguration function signature to accept object parameter with isDashboardV2Enabled flag
  • Integrated FeatureFlagService into PageLayoutWidgetService to check feature flag during widget creation and updates
  • Comprehensive unit tests added for feature flag validation scenarios
  • Removed unused isWidgetConfigurationValid utility and its tests
  • Dev seeder sets the feature flag to true by default for development environments

Implementation quality:

  • Clean separation of concerns with validation logic centralized
  • Consistent v2 chart type definitions across frontend and backend (PIE, LINE, GAUGE)
  • Backend properly validates against unauthorized API usage even if frontend is bypassed
  • Good test coverage including edge cases for feature flag behavior

Confidence Score: 5/5

  • This PR is safe to merge with no issues found
  • The implementation is thorough and well-tested. The feature flag is properly integrated at both frontend and backend layers with appropriate validation. The refactoring from positional parameters to object parameters improves code clarity. All tests have been updated and new tests added for the feature flag scenarios. The changes follow the codebase patterns and maintain backward compatibility.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/twenty-server/src/engine/core-modules/page-layout/utils/validate-and-transform-widget-configuration.util.ts 5/5 Refactored to accept feature flag parameter, validates v2 chart types (PIE, LINE, GAUGE) require feature flag
packages/twenty-server/src/engine/core-modules/page-layout/services/page-layout-widget.service.ts 5/5 Integrated FeatureFlagService, checks feature flag before validating widget configurations in create and update methods
packages/twenty-front/src/modules/command-menu/pages/page-layout/components/ChartTypeSelectionSection.tsx 5/5 Uses feature flag hook to disable v2 chart types in UI when flag is disabled
packages/twenty-server/src/engine/core-modules/page-layout/utils/tests/validate-and-transform-widget-configuration.util.spec.ts 5/5 Updated all test cases to pass isDashboardV2Enabled parameter, added comprehensive feature flag tests

Sequence Diagram

sequenceDiagram
    participant User
    participant Frontend
    participant API
    participant Service
    participant FeatureFlag
    participant Validation

    User->>Frontend: Create/Update Widget with v2 chart type
    Frontend->>Frontend: Check IS_DASHBOARD_V2_ENABLED
    alt Feature disabled
        Frontend->>User: Disable v2 chart options (PIE, LINE, GAUGE)
    else Feature enabled
        Frontend->>API: POST/PUT widget with v2 chart configuration
        API->>Service: PageLayoutWidgetService.create/update()
        Service->>FeatureFlag: isFeatureEnabled(IS_DASHBOARD_V2_ENABLED)
        FeatureFlag-->>Service: boolean
        Service->>Validation: validateAndTransformWidgetConfiguration({type, config, isDashboardV2Enabled})
        alt V2 chart && feature disabled
            Validation-->>Service: throw Error
            Service-->>API: PageLayoutWidgetException
            API-->>Frontend: 400 Error
        else Valid configuration
            Validation-->>Service: validatedConfig
            Service->>Service: Insert/Update widget
            Service-->>API: PageLayoutWidgetEntity
            API-->>Frontend: Success
        end
    end
Loading

14 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Copy Markdown
Member

@Weiko Weiko left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 4, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:1144

This environment will automatically shut down when the PR is closed or after 5 hours.

@bosiraphael bosiraphael merged commit 05a28a8 into main Nov 4, 2025
65 checks passed
@bosiraphael bosiraphael deleted the create-feature-flag-for-dashboards-v2 branch November 4, 2025 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants