diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-25 18:07:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-25 18:07:47 +0300 |
commit | 6f2065c468b05658125b746169c56764a8ccddb1 (patch) | |
tree | 544a488ae2e65e2fcfe4acce4e56623b85bbce5e /app | |
parent | e6baeabaa9651d90b03bb64ffce75a2c3cb89aab (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/graphql/resolvers/merge_requests_resolver.rb | 3 | ||||
-rw-r--r-- | app/helpers/notifications_helper.rb | 4 | ||||
-rw-r--r-- | app/presenters/project_presenter.rb | 12 | ||||
-rw-r--r-- | app/services/metrics/dashboard/gitlab_alert_embed_service.rb | 72 | ||||
-rw-r--r-- | app/views/shared/notifications/_custom_notifications.html.haml | 2 | ||||
-rw-r--r-- | app/workers/all_queues.yml | 2 | ||||
-rw-r--r-- | app/workers/project_export_worker.rb | 1 |
7 files changed, 93 insertions, 3 deletions
diff --git a/app/graphql/resolvers/merge_requests_resolver.rb b/app/graphql/resolvers/merge_requests_resolver.rb index 1740d614b69..406a1fac05c 100644 --- a/app/graphql/resolvers/merge_requests_resolver.rb +++ b/app/graphql/resolvers/merge_requests_resolver.rb @@ -15,7 +15,8 @@ module Resolvers alias_method :project, :object def resolve(**args) - return unless project.present? + project = object.respond_to?(:sync) ? object.sync : object + return MergeRequest.none if project.nil? args[:iids] ||= [args[:iid]].compact diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index 9a64fe98f86..8fd277564df 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -120,4 +120,8 @@ module NotificationsHelper def can_read_project?(project) can?(current_user, :read_project, project) end + + def notification_event_disabled?(event) + event == :fixed_pipeline && Feature.disabled?(:ci_pipeline_fixed_notifications) + end end diff --git a/app/presenters/project_presenter.rb b/app/presenters/project_presenter.rb index 3af6be26843..a663bc555f6 100644 --- a/app/presenters/project_presenter.rb +++ b/app/presenters/project_presenter.rb @@ -25,6 +25,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated branches_anchor_data, tags_anchor_data, files_anchor_data, + storage_anchor_data, releases_anchor_data ].compact.select(&:is_link) end @@ -154,6 +155,17 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated empty_repo? ? nil : project_tree_path(project)) end + def storage_anchor_data + AnchorData.new(true, + statistic_icon('disk') + + _('%{strong_start}%{human_size}%{strong_end} Storage').html_safe % { + human_size: storage_counter(statistics.storage_size), + strong_start: '<strong class="project-stat-value">'.html_safe, + strong_end: '</strong>'.html_safe + }, + empty_repo? ? nil : project_tree_path(project)) + end + def releases_anchor_data return unless can?(current_user, :read_release, project) diff --git a/app/services/metrics/dashboard/gitlab_alert_embed_service.rb b/app/services/metrics/dashboard/gitlab_alert_embed_service.rb new file mode 100644 index 00000000000..5515b84f112 --- /dev/null +++ b/app/services/metrics/dashboard/gitlab_alert_embed_service.rb @@ -0,0 +1,72 @@ +# frozen_string_literal: true + +# Responsible for returning an embed containing the specified +# metrics chart for an alert. Creates panels based on the +# matching metric stored in the database. +# +# Use Gitlab::Metrics::Dashboard::Finder to retrieve dashboards. +module Metrics + module Dashboard + class GitlabAlertEmbedService < ::Metrics::Dashboard::BaseEmbedService + include Gitlab::Utils::StrongMemoize + + SEQUENCE = [STAGES::EndpointInserter].freeze + + class << self + # Determines whether the provided params are sufficient + # to uniquely identify a panel composed of user-defined + # custom metrics from the DB. + def valid_params?(params) + [ + embedded?(params[:embedded]), + params[:prometheus_alert_id].is_a?(Integer) + ].all? + end + end + + def raw_dashboard + panels_not_found!(alert_id: alert_id) unless alert && prometheus_metric + + { 'panel_groups' => [{ 'panels' => [panel] }] } + end + + private + + def allowed? + Ability.allowed?(current_user, :read_prometheus_alerts, project) + end + + def alert_id + params[:prometheus_alert_id] + end + + def alert + strong_memoize(:alert) do + Projects::Prometheus::AlertsFinder.new(id: alert_id).execute.first + end + end + + def process_params + params.merge(environment: alert.environment) + end + + def prometheus_metric + strong_memoize(:prometheus_metric) do + PrometheusMetricsFinder.new(id: alert.prometheus_metric_id).execute.first + end + end + + def panel + { + title: prometheus_metric.title, + y_label: prometheus_metric.y_label, + metrics: [prometheus_metric.to_metric_hash] + } + end + + def sequence + SEQUENCE + end + end + end +end diff --git a/app/views/shared/notifications/_custom_notifications.html.haml b/app/views/shared/notifications/_custom_notifications.html.haml index 58d02602423..0142deb47f8 100644 --- a/app/views/shared/notifications/_custom_notifications.html.haml +++ b/app/views/shared/notifications/_custom_notifications.html.haml @@ -23,7 +23,7 @@ #{ paragraph.html_safe } .col-lg-8 - notification_setting.email_events.each_with_index do |event, index| - - next if event == :fixed_pipeline && Feature.disabled?(:ci_pipeline_fixed_notifications) + - next if notification_event_disabled?(event) - field_id = "#{notifications_menu_identifier("modal", notification_setting)}_notification_setting[#{event}]" .form-group .form-check{ class: ("prepend-top-0" if index == 0) } diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml index c101759ff9b..72a5a2b653e 100644 --- a/app/workers/all_queues.yml +++ b/app/workers/all_queues.yml @@ -1224,7 +1224,7 @@ - :name: project_export :feature_category: :importers :has_external_dependencies: - :urgency: :low + :urgency: :throttled :resource_boundary: :memory :weight: 1 :idempotent: diff --git a/app/workers/project_export_worker.rb b/app/workers/project_export_worker.rb index aaaf70f09b5..a287c511a65 100644 --- a/app/workers/project_export_worker.rb +++ b/app/workers/project_export_worker.rb @@ -7,6 +7,7 @@ class ProjectExportWorker # rubocop:disable Scalability/IdempotentWorker feature_category :importers worker_resource_boundary :memory + urgency :throttled def perform(current_user_id, project_id, after_export_strategy = {}, params = {}) current_user = User.find(current_user_id) |