Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/metrics/dashboard/finder.rb')
-rw-r--r--lib/gitlab/metrics/dashboard/finder.rb45
1 files changed, 25 insertions, 20 deletions
diff --git a/lib/gitlab/metrics/dashboard/finder.rb b/lib/gitlab/metrics/dashboard/finder.rb
index 1373830844b..66c4d662a6c 100644
--- a/lib/gitlab/metrics/dashboard/finder.rb
+++ b/lib/gitlab/metrics/dashboard/finder.rb
@@ -12,21 +12,37 @@ module Gitlab
# @param project [Project]
# @param user [User]
# @param environment [Environment]
- # @param opts - dashboard_path [String] Path at which the
- # dashboard can be found. Nil values will
- # default to the system dashboard.
- # @param opts - embedded [Boolean] Determines whether the
+ # @param options - embedded [Boolean] Determines whether the
# dashboard is to be rendered as part of an
# issue or location other than the primary
# metrics dashboard UI. Returns only the
# Memory/CPU charts of the system dash.
+ # @param options - dashboard_path [String] Path at which the
+ # dashboard can be found. Nil values will
+ # default to the system dashboard.
+ # @param options - group [String] Title of the group
+ # to which a panel might belong. Used by
+ # embedded dashboards.
+ # @param options - title [String] Title of the panel.
+ # Used by embedded dashboards.
+ # @param options - y_label [String] Y-Axis label of
+ # a panel. Used by embedded dashboards.
# @return [Hash]
- def find(project, user, environment, dashboard_path: nil, embedded: false)
- service_for_path(dashboard_path, embedded: embedded)
- .new(project, user, environment: environment, dashboard_path: dashboard_path)
+ def find(project, user, environment, options = {})
+ service_for(options)
+ .new(project, user, options.merge(environment: environment))
.get_dashboard
end
+ # Returns a dashboard without any supplemental info.
+ # Returns only full, yml-defined dashboards.
+ # @return [Hash]
+ def find_raw(project, dashboard_path: nil)
+ service_for(dashboard_path: dashboard_path)
+ .new(project, nil, dashboard_path: dashboard_path)
+ .raw_dashboard
+ end
+
# Summary of all known dashboards.
# @return [Array<Hash>] ex) [{ path: String,
# display_name: String,
@@ -46,13 +62,6 @@ module Gitlab
private
- def service_for_path(dashboard_path, embedded:)
- return embed_service if embedded
- return system_service if system_dashboard?(dashboard_path)
-
- project_service
- end
-
def system_service
::Metrics::Dashboard::SystemDashboardService
end
@@ -61,12 +70,8 @@ module Gitlab
::Metrics::Dashboard::ProjectDashboardService
end
- def embed_service
- ::Metrics::Dashboard::DefaultEmbedService
- end
-
- def system_dashboard?(filepath)
- !filepath || system_service.system_dashboard?(filepath)
+ def service_for(options)
+ Gitlab::Metrics::Dashboard::ServiceSelector.call(options)
end
end
end