diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-08 18:12:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-08 18:12:33 +0300 |
commit | 6225d57e55eaa0205e939e7ed6577636b0ee47cf (patch) | |
tree | be54b280f0631a1e9c8e767c675e610c65925b2e /app/services/incident_management | |
parent | dcc096f21918399d7061372c0a22b9a5408a00a5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/incident_management')
-rw-r--r-- | app/services/incident_management/incidents/create_service.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/app/services/incident_management/incidents/create_service.rb b/app/services/incident_management/incidents/create_service.rb index f8437290d9b..ef66325fdcc 100644 --- a/app/services/incident_management/incidents/create_service.rb +++ b/app/services/incident_management/incidents/create_service.rb @@ -2,15 +2,16 @@ module IncidentManagement module Incidents - class CreateService < BaseService + class CreateService < ::BaseProjectService ISSUE_TYPE = 'incident' - def initialize(project, current_user, title:, description:, severity: IssuableSeverity::DEFAULT) - super(project, current_user) + def initialize(project, current_user, title:, description:, severity: IssuableSeverity::DEFAULT, alert: nil) + super(project: project, current_user: current_user) @title = title @description = description @severity = severity + @alert = alert end def execute @@ -21,11 +22,16 @@ module IncidentManagement title: title, description: description, issue_type: ISSUE_TYPE, - severity: severity + severity: severity, + alert_management_alert: alert }, spam_params: nil ).execute + if alert + return error(alert.errors.full_messages.to_sentence, issue) unless alert.valid? + end + return error(issue.errors.full_messages.to_sentence, issue) unless issue.valid? success(issue) @@ -33,7 +39,7 @@ module IncidentManagement private - attr_reader :title, :description, :severity + attr_reader :title, :description, :severity, :alert def success(issue) ServiceResponse.success(payload: { issue: issue }) |