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-04-06 12:09:17 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-06 12:09:17 +0300
commiteaea945e0355826c58c3dcf887496ea91064f85c (patch)
tree0f20e03304d35e68375e99a606b9b94483e37ee5 /app
parentcce8cf03d3bebe8b05375e4db0004328f84b28a2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/blob/suggest_gitlab_ci_yml/components/popover.vue13
-rw-r--r--app/services/projects/prometheus/metrics/base_service.rb48
-rw-r--r--app/services/projects/prometheus/metrics/destroy_service.rb14
-rw-r--r--app/services/projects/prometheus/metrics/update_service.rb29
-rw-r--r--app/views/projects/network/show.html.haml3
5 files changed, 105 insertions, 2 deletions
diff --git a/app/assets/javascripts/blob/suggest_gitlab_ci_yml/components/popover.vue b/app/assets/javascripts/blob/suggest_gitlab_ci_yml/components/popover.vue
index e191bfd79cb..5023496e2c3 100644
--- a/app/assets/javascripts/blob/suggest_gitlab_ci_yml/components/popover.vue
+++ b/app/assets/javascripts/blob/suggest_gitlab_ci_yml/components/popover.vue
@@ -23,6 +23,8 @@ const popoverStates = {
},
};
export default {
+ dismissTrackValue: 10,
+ clickTrackValue: 'click_button',
components: {
GlPopover,
GlSprintf,
@@ -109,7 +111,16 @@ export default {
<template #title>
<span v-html="suggestTitle"></span>
<span class="ml-auto">
- <gl-deprecated-button :aria-label="__('Close')" class="btn-blank" @click="onDismiss">
+ <gl-deprecated-button
+ :aria-label="__('Close')"
+ class="btn-blank"
+ name="dismiss"
+ :data-track-property="humanAccess"
+ :data-track-value="$options.dismissTrackValue"
+ :data-track-event="$options.clickTrackValue"
+ :data-track-label="trackLabel"
+ @click="onDismiss"
+ >
<gl-icon name="close" aria-hidden="true" />
</gl-deprecated-button>
</span>
diff --git a/app/services/projects/prometheus/metrics/base_service.rb b/app/services/projects/prometheus/metrics/base_service.rb
new file mode 100644
index 00000000000..be1783dde70
--- /dev/null
+++ b/app/services/projects/prometheus/metrics/base_service.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+module Projects
+ module Prometheus
+ module Metrics
+ class BaseService
+ include Gitlab::Utils::StrongMemoize
+
+ def initialize(metric, params = {})
+ @metric = metric
+ @project = metric.project
+ @params = params.dup
+ end
+
+ protected
+
+ attr_reader :metric, :project, :params
+
+ def application
+ alert.environment.cluster_prometheus_adapter
+ end
+
+ def schedule_alert_update
+ return unless alert
+ return unless alert.environment
+
+ ::Clusters::Applications::ScheduleUpdateService.new(
+ alert.environment.cluster_prometheus_adapter, project).execute
+ end
+
+ def alert
+ strong_memoize(:alert) { find_alert(metric) }
+ end
+
+ def find_alert(metric)
+ Projects::Prometheus::AlertsFinder
+ .new(project: project, metric: metric)
+ .execute
+ .first
+ end
+
+ def has_alert?
+ alert.present?
+ end
+ end
+ end
+ end
+end
diff --git a/app/services/projects/prometheus/metrics/destroy_service.rb b/app/services/projects/prometheus/metrics/destroy_service.rb
new file mode 100644
index 00000000000..6a46eb5516c
--- /dev/null
+++ b/app/services/projects/prometheus/metrics/destroy_service.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+module Projects
+ module Prometheus
+ module Metrics
+ class DestroyService < Metrics::BaseService
+ def execute
+ schedule_alert_update if has_alert?
+ metric.destroy
+ end
+ end
+ end
+ end
+end
diff --git a/app/services/projects/prometheus/metrics/update_service.rb b/app/services/projects/prometheus/metrics/update_service.rb
new file mode 100644
index 00000000000..9b51f4ab47d
--- /dev/null
+++ b/app/services/projects/prometheus/metrics/update_service.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+module Projects
+ module Prometheus
+ module Metrics
+ class UpdateService < Metrics::BaseService
+ def execute
+ metric.update!(params)
+ schedule_alert_update if requires_alert_update?
+ metric
+ end
+
+ private
+
+ def requires_alert_update?
+ has_alert? && (changing_title? || changing_query?)
+ end
+
+ def changing_title?
+ metric.previous_changes.include?(:title)
+ end
+
+ def changing_query?
+ metric.previous_changes.include?(:query)
+ end
+ end
+ end
+ end
+end
diff --git a/app/views/projects/network/show.html.haml b/app/views/projects/network/show.html.haml
index 2d3f9116703..6821453cffa 100644
--- a/app/views/projects/network/show.html.haml
+++ b/app/views/projects/network/show.html.haml
@@ -16,4 +16,5 @@
- if @commit
.network-graph{ data: { url: @url, commit_url: @commit_url, ref: @ref, commit_id: @commit.id } }
- = spinner nil, true
+ .text-center.prepend-top-default
+ .spinner.spinner-md