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.vuethat also doesn't seem to be used. WDYT about completely removing the provide/inject and the relatedanalytics_dashboard_pointer_projectin 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)
-
dashboards_list.vue- Contains unusedcustomDashboardsProjectinject:inject: { // ... other injects customDashboardsProject: { type: Object, default: null, }, // ... other injects }This property is injected but never used in the component.
-
analytics_dashboard.vue- Contains unusedcustomDashboardsProjectinject:inject: { customDashboardsProject: { type: Object, default: null, }, // ... other injects }This was removed from the component logic but the inject remains.
-
index.js- Still providescustomDashboardsProject:const customDashboardsProject = analyticsDashboardPointer; // ... provide: { // ... other provides customDashboardsProject, // ... other provides }
Backend (Ruby)
-
analytics_dashboards_helper.rb- Containsanalytics_dashboard_pointer_projectmethod:def analytics_dashboard_pointer_project(namespace) pointer_project = project?(namespace) ? project_dashboard_pointer(namespace) : group_dashboard_pointer(namespace) # ... implementation endThis method is used in the helper to provide data to the frontend, but the frontend no longer uses this data.
-
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 customDashboardsProjectinject fromdashboards_list.vue -
Remove unused customDashboardsProjectinject fromanalytics_dashboard.vue -
Remove customDashboardsProjectfrom the provide object inindex.js -
Remove related analyticsDashboardPointerandbuildAnalyticsDashboardPointerlogic fromindex.js
Backend Cleanup
-
Remove analytics_dashboard_pointer_projectmethod fromanalytics_dashboards_helper.rb -
Remove dashboard_projectfrom theanalytics_dashboards_list_app_datamethod -
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
- Ensure analytics dashboards load and function correctly
- Verify that dashboard configuration and pointer functionality (if still needed elsewhere) works
- Run the full test suite to ensure no regressions
- Test both project and group level analytics dashboards
Related Files
Frontend:
ee/app/assets/javascripts/analytics/analytics_dashboards/index.jsee/app/assets/javascripts/analytics/analytics_dashboards/components/dashboards_list.vueee/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.jsee/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.