diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 09:16:11 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 09:16:11 +0000 |
commit | edaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch) | |
tree | 11f143effbfeba52329fb7afbd05e6e2a3790241 /app/services/alert_management | |
parent | d8a5691316400a0f7ec4f83832698f1988eb27c1 (diff) | |
download | gitlab-ce-edaa33dee2ff2f7ea3fac488d41558eb5f86d68c.tar.gz |
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'app/services/alert_management')
-rw-r--r-- | app/services/alert_management/alerts/update_service.rb | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/app/services/alert_management/alerts/update_service.rb b/app/services/alert_management/alerts/update_service.rb index 089715a42fb..7a9bcf2a52d 100644 --- a/app/services/alert_management/alerts/update_service.rb +++ b/app/services/alert_management/alerts/update_service.rb @@ -2,7 +2,7 @@ module AlertManagement module Alerts - class UpdateService + class UpdateService < ::BaseProjectService include Gitlab::Utils::StrongMemoize # @param alert [AlertManagement::Alert] @@ -10,10 +10,10 @@ module AlertManagement # @param params [Hash] Attributes of the alert def initialize(alert, current_user, params) @alert = alert - @current_user = current_user - @params = params @param_errors = [] @status = params.delete(:status) + + super(project: alert.project, current_user: current_user, params: params) end def execute @@ -36,7 +36,7 @@ module AlertManagement private - attr_reader :alert, :current_user, :params, :param_errors, :status + attr_reader :alert, :param_errors, :status def allowed? current_user&.can?(:update_alert_management_alert, alert) @@ -109,7 +109,7 @@ module AlertManagement end def add_assignee_system_note(old_assignees) - SystemNoteService.change_issuable_assignees(alert, alert.project, current_user, old_assignees) + SystemNoteService.change_issuable_assignees(alert, project, current_user, old_assignees) end # ------ Status-related behavior ------- @@ -129,6 +129,7 @@ module AlertManagement def handle_status_change add_status_change_system_note resolve_todos if alert.resolved? + sync_to_incident if should_sync_to_incident? end def add_status_change_system_note @@ -139,6 +140,22 @@ module AlertManagement todo_service.resolve_todos_for_target(alert, current_user) end + def sync_to_incident + ::Issues::UpdateService.new( + project: project, + current_user: current_user, + params: { escalation_status: { status: status } } + ).execute(alert.issue) + end + + def should_sync_to_incident? + Feature.enabled?(:incident_escalations, project) && + alert.issue && + alert.issue.supports_escalation? && + alert.issue.escalation_status && + alert.issue.escalation_status.status != alert.status + end + def filter_duplicate # Only need to check if changing to an open status return unless params[:status_event] && AlertManagement::Alert.open_status?(status) @@ -154,7 +171,7 @@ module AlertManagement def open_alerts strong_memoize(:open_alerts) do - AlertManagement::Alert.for_fingerprint(alert.project, alert.fingerprint).open + AlertManagement::Alert.for_fingerprint(project, alert.fingerprint).open end end @@ -166,7 +183,7 @@ module AlertManagement def open_alert_url_params open_alert = open_alerts.first - alert_path = Gitlab::Routing.url_helpers.details_project_alert_management_path(alert.project, open_alert) + alert_path = Gitlab::Routing.url_helpers.details_project_alert_management_path(project, open_alert) { link_start: '<a href="%{url}">'.html_safe % { url: alert_path }, |