Commit 0487769e authored by Ryan Cobb's avatar Ryan Cobb

Add edit_path to metrics_dashboard endpoint

parent 2554bdc0
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
# to the parameters specified by the controller. # to the parameters specified by the controller.
module MetricsDashboard module MetricsDashboard
include RenderServiceResults include RenderServiceResults
include ChecksCollaboration
extend ActiveSupport::Concern extend ActiveSupport::Concern
def metrics_dashboard def metrics_dashboard
...@@ -14,7 +16,7 @@ module MetricsDashboard ...@@ -14,7 +16,7 @@ module MetricsDashboard
) )
if include_all_dashboards? && result if include_all_dashboards? && result
result[:all_dashboards] = dashboard_finder.find_all_paths(project_for_dashboard) result[:all_dashboards] = all_dashboards
end end
respond_to do |format| respond_to do |format|
...@@ -30,6 +32,22 @@ module MetricsDashboard ...@@ -30,6 +32,22 @@ module MetricsDashboard
private private
def all_dashboards
dashboards = dashboard_finder.find_all_paths(project_for_dashboard)
dashboards.map do |dashboard|
dashboard[:edit_path] = edit_path(dashboard)
dashboard
end
end
def edit_path(dashboard)
return unless project_for_dashboard
return if dashboard[:system_dashboard]
return unless can_collaborate_with_project?(project_for_dashboard, ref: project_for_dashboard.default_branch)
Gitlab::Routing.url_helpers.project_blob_path(project_for_dashboard, File.join(project_for_dashboard.default_branch, dashboard[:path]))
end
# Override in class to provide arguments to the finder. # Override in class to provide arguments to the finder.
def metrics_dashboard_params def metrics_dashboard_params
{} {}
......
...@@ -16,7 +16,8 @@ module Metrics ...@@ -16,7 +16,8 @@ module Metrics
{ {
path: filepath, path: filepath,
display_name: name_for_path(filepath), display_name: name_for_path(filepath),
default: false default: false,
system_dashboard: false
} }
end end
end end
......
...@@ -20,7 +20,8 @@ module Metrics ...@@ -20,7 +20,8 @@ module Metrics
[{ [{
path: SYSTEM_DASHBOARD_PATH, path: SYSTEM_DASHBOARD_PATH,
display_name: SYSTEM_DASHBOARD_NAME, display_name: SYSTEM_DASHBOARD_NAME,
default: true default: true,
system_dashboard: true
}] }]
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment