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
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-07-31 03:09:37 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-07-31 03:09:37 +0300
commit73094cfac5fd07027a307183044c375932b4e591 (patch)
tree089e0b278c742734678a796301d39f617487116f /app
parent5629d98f5325487f66dea52c2d662ea4b46d8c07 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/helpers/environments_helper.rb2
-rw-r--r--app/models/repository.rb10
-rw-r--r--app/services/metrics/dashboard/clone_dashboard_service.rb2
-rw-r--r--app/services/metrics/dashboard/custom_dashboard_service.rb13
-rw-r--r--app/services/metrics/dashboard/update_dashboard_service.rb2
5 files changed, 11 insertions, 18 deletions
diff --git a/app/helpers/environments_helper.rb b/app/helpers/environments_helper.rb
index c83bf702f50..7d5a1adc1dc 100644
--- a/app/helpers/environments_helper.rb
+++ b/app/helpers/environments_helper.rb
@@ -111,7 +111,7 @@ module EnvironmentsHelper
'empty-no-data-svg-path' => image_path('illustrations/monitoring/no_data.svg'),
'empty-no-data-small-svg-path' => image_path('illustrations/chart-empty-state-small.svg'),
'empty-unable-to-connect-svg-path' => image_path('illustrations/monitoring/unable_to_connect.svg'),
- 'custom-dashboard-base-path' => Metrics::Dashboard::CustomDashboardService::DASHBOARD_ROOT
+ 'custom-dashboard-base-path' => Gitlab::Metrics::Dashboard::RepoDashboardFinder::DASHBOARD_ROOT
}
end
end
diff --git a/app/models/repository.rb b/app/models/repository.rb
index bec7cda5250..f4244764338 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -43,7 +43,7 @@ class Repository
gitlab_ci_yml branch_names tag_names branch_count
tag_count avatar exists? root_ref merged_branch_names
has_visible_content? issue_template_names merge_request_template_names
- metrics_dashboard_paths xcode_project?).freeze
+ user_defined_metrics_dashboard_paths xcode_project?).freeze
# Methods that use cache_method but only memoize the value
MEMOIZED_CACHED_METHODS = %i(license).freeze
@@ -61,7 +61,7 @@ class Repository
avatar: :avatar,
issue_template: :issue_template_names,
merge_request_template: :merge_request_template_names,
- metrics_dashboard: :metrics_dashboard_paths,
+ metrics_dashboard: :user_defined_metrics_dashboard_paths,
xcode_config: :xcode_project?
}.freeze
@@ -576,10 +576,10 @@ class Repository
end
cache_method :merge_request_template_names, fallback: []
- def metrics_dashboard_paths
- Gitlab::Metrics::Dashboard::Finder.find_all_paths_from_source(project)
+ def user_defined_metrics_dashboard_paths
+ Gitlab::Metrics::Dashboard::RepoDashboardFinder.list_dashboards(project)
end
- cache_method :metrics_dashboard_paths
+ cache_method :user_defined_metrics_dashboard_paths, fallback: []
def readme
head_tree&.readme
diff --git a/app/services/metrics/dashboard/clone_dashboard_service.rb b/app/services/metrics/dashboard/clone_dashboard_service.rb
index a2605ca21dc..b5df82ea92a 100644
--- a/app/services/metrics/dashboard/clone_dashboard_service.rb
+++ b/app/services/metrics/dashboard/clone_dashboard_service.rb
@@ -9,7 +9,7 @@ module Metrics
include Gitlab::Utils::StrongMemoize
ALLOWED_FILE_TYPE = '.yml'
- USER_DASHBOARDS_DIR = ::Metrics::Dashboard::CustomDashboardService::DASHBOARD_ROOT
+ USER_DASHBOARDS_DIR = ::Gitlab::Metrics::Dashboard::RepoDashboardFinder::DASHBOARD_ROOT
SEQUENCES = {
::Metrics::Dashboard::SystemDashboardService::DASHBOARD_PATH => [
::Gitlab::Metrics::Dashboard::Stages::CommonMetricsInserter,
diff --git a/app/services/metrics/dashboard/custom_dashboard_service.rb b/app/services/metrics/dashboard/custom_dashboard_service.rb
index 741738cc3af..f0f19bf2ba3 100644
--- a/app/services/metrics/dashboard/custom_dashboard_service.rb
+++ b/app/services/metrics/dashboard/custom_dashboard_service.rb
@@ -6,16 +6,13 @@
module Metrics
module Dashboard
class CustomDashboardService < ::Metrics::Dashboard::BaseService
- DASHBOARD_ROOT = ".gitlab/dashboards"
-
class << self
def valid_params?(params)
params[:dashboard_path].present?
end
def all_dashboard_paths(project)
- file_finder(project)
- .list_files_for(DASHBOARD_ROOT)
+ project.repository.user_defined_metrics_dashboard_paths
.map do |filepath|
{
path: filepath,
@@ -27,13 +24,9 @@ module Metrics
end
end
- def file_finder(project)
- Gitlab::Template::Finders::RepoTemplateFinder.new(project, DASHBOARD_ROOT, '.yml')
- end
-
# Grabs the filepath after the base directory.
def name_for_path(filepath)
- filepath.delete_prefix("#{DASHBOARD_ROOT}/")
+ filepath.delete_prefix("#{Gitlab::Metrics::Dashboard::RepoDashboardFinder::DASHBOARD_ROOT}/")
end
end
@@ -41,7 +34,7 @@ module Metrics
# Searches the project repo for a custom-defined dashboard.
def get_raw_dashboard
- yml = self.class.file_finder(project).read(dashboard_path)
+ yml = Gitlab::Metrics::Dashboard::RepoDashboardFinder.read_dashboard(project, dashboard_path)
load_yaml(yml)
end
diff --git a/app/services/metrics/dashboard/update_dashboard_service.rb b/app/services/metrics/dashboard/update_dashboard_service.rb
index b501e368153..d990e96ecb5 100644
--- a/app/services/metrics/dashboard/update_dashboard_service.rb
+++ b/app/services/metrics/dashboard/update_dashboard_service.rb
@@ -7,7 +7,7 @@ module Metrics
include Stepable
ALLOWED_FILE_TYPE = '.yml'
- USER_DASHBOARDS_DIR = ::Metrics::Dashboard::CustomDashboardService::DASHBOARD_ROOT
+ USER_DASHBOARDS_DIR = ::Gitlab::Metrics::Dashboard::RepoDashboardFinder::DASHBOARD_ROOT
steps :check_push_authorized,
:check_branch_name,