Add "project_blob_path", "can_edit" to "all_dashboards" in metrics_dashboard.json
Objective
Add an "Edit Dashboard" link in the metrics dashboard. Part of #34779 (closed)
Requirement
Add an edit_path project_blob_path
and can_edit
to the dashboard data in the GET metrics_dashboard.json
endpoint (e.g. /root/autodevops-deploy/environments/29/metrics_dashboard.json?...
)
edit_path can_edit
should only be true if the dashboard can be modified, and if they use can access this file in the reposity.
Example:
{
"all_dashboards": [
{
"default": true,
"can_edit": false,
"display_name": "Default",
"path": "config/prometheus/common_metrics.yml",
"project_blob_path": null,
"system_dashboard": true
},
{
"default": false,
"can_edit": true,
"display_name": "anomaly_simple.yml",
"path": ".gitlab/dashboards/anomaly_simple.yml",
"project_blob_path": "/root/autodevops-deploy/blob/master/.gitlab/dashboards/anomaly_simple.yml",
"system_dashboard": false
},
{
"default": false,
"can_edit": true,
"display_name": "anomaly_subqueries.yml",
"path": ".gitlab/dashboards/anomaly_subqueries.yml",
"project_blob_path": "/root/autodevops-deploy/blob/master/.gitlab/dashboards/anomaly_subqueries.yml",
"system_dashboard": false
}
],
"dashboard": {
"dashboard": "My Dashboard",
....
},
"status": "success"
}
Technical Implementation
New property could be added here:
- https://gitlab.com/gitlab-org/gitlab/blob/master/app/services/metrics/dashboard/project_dashboard_service.rb#L17
- https://gitlab.com/gitlab-org/gitlab/blob/master/app/services/metrics/dashboard/system_dashboard_service.rb#L21
Original Discussion
The following discussion from !19279 (merged) should be addressed:
-
@mrincon started a discussion: Hardcoding
/blob/master/
here is probably a bad approach, I am still search for solutions.
Edited by Miguel Rincon