Clean up unused injected variables in dashboards app

The following discussion from !199893 (merged) should be addressed:

  • @jiaan started a discussion:

    Suggestion (non-blocking): I found one other instance in dashboards_list.vue that also doesn't seem to be used. WDYT about completely removing the provide/inject and the related analytics_dashboard_pointer_project in ruby? This could be a follow-up.

Background

MR !199893 (merged) successfully updated existing analytics dashboards to use the new gl-dashboard-layout framework, replacing the custom analytics_customizable_dashboard.vue and gridstack_wrapper components. However, during the review, it was identified that there are unused provide/inject patterns and related Ruby code that can be cleaned up.

Current State Analysis

After examining the codebase, the following unused code has been identified:

Frontend (Vue.js)

  1. dashboards_list.vue - Contains unused customDashboardsProject inject:

    inject: {
      // ... other injects
      customDashboardsProject: {
        type: Object,
        default: null,
      },
      // ... other injects
    }

    This property is injected but never used in the component.

  2. analytics_dashboard.vue - Contains unused customDashboardsProject inject:

    inject: {
      customDashboardsProject: {
        type: Object,
        default: null,
      },
      // ... other injects
    }

    This was removed from the component logic but the inject remains.

  3. index.js - Still provides customDashboardsProject:

    const customDashboardsProject = analyticsDashboardPointer;
    // ...
    provide: {
      // ... other provides
      customDashboardsProject,
      // ... other provides
    }

Backend (Ruby)

  1. analytics_dashboards_helper.rb - Contains analytics_dashboard_pointer_project method:

    def analytics_dashboard_pointer_project(namespace)
      pointer_project = project?(namespace) ? project_dashboard_pointer(namespace) : group_dashboard_pointer(namespace)
      # ... implementation
    end

    This method is used in the helper to provide data to the frontend, but the frontend no longer uses this data.

  2. Helper usage - The method is called in analytics_dashboards_list_app_data:

    dashboard_project: analytics_dashboard_pointer_project(namespace)&.to_json,

Tasks

Frontend Cleanup

  • Remove unused customDashboardsProject inject from dashboards_list.vue
  • Remove unused customDashboardsProject inject from analytics_dashboard.vue
  • Remove customDashboardsProject from the provide object in index.js
  • Remove related analyticsDashboardPointer and buildAnalyticsDashboardPointer logic from index.js

Backend Cleanup

  • Remove analytics_dashboard_pointer_project method from analytics_dashboards_helper.rb
  • Remove dashboard_project from the analytics_dashboards_list_app_data method
  • Remove supporting methods if they become unused:
    • project_dashboard_pointer
    • group_dashboard_pointer

Testing Updates

  • Update frontend specs that reference customDashboardsProject
  • Update any backend specs that test the removed helper methods
  • Verify that analytics dashboards still function correctly after cleanup

Verification Steps

  1. Ensure analytics dashboards load and function correctly
  2. Verify that dashboard configuration and pointer functionality (if still needed elsewhere) works
  3. Run the full test suite to ensure no regressions
  4. Test both project and group level analytics dashboards

Related Files

Frontend:

  • ee/app/assets/javascripts/analytics/analytics_dashboards/index.js
  • ee/app/assets/javascripts/analytics/analytics_dashboards/components/dashboards_list.vue
  • ee/app/assets/javascripts/analytics/analytics_dashboards/components/analytics_dashboard.vue

Backend:

  • ee/app/helpers/analytics/analytics_dashboards_helper.rb

Tests:

  • ee/spec/frontend/analytics/analytics_dashboards/components/dashboards_list_spec.js
  • ee/spec/frontend/analytics/analytics_dashboards/components/analytics_dashboard_spec.js
  • Any backend specs testing the helper methods

This cleanup will reduce technical debt and remove unused code paths that were left behind during the dashboard layout framework migration.

Edited by Daniele Rossetti