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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-08-18 11:17:02 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-08-18 11:17:02 +0300
commitb39512ed755239198a9c294b6a45e65c05900235 (patch)
treed234a3efade1de67c46b9e5a38ce813627726aa7 /app/services/incident_management/timeline_events/create_service.rb
parentd31474cf3b17ece37939d20082b07f6657cc79a9 (diff)
Add latest changes from gitlab-org/gitlab@15-3-stable-eev15.3.0-rc42
Diffstat (limited to 'app/services/incident_management/timeline_events/create_service.rb')
-rw-r--r--app/services/incident_management/timeline_events/create_service.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/services/incident_management/timeline_events/create_service.rb b/app/services/incident_management/timeline_events/create_service.rb
index 3cb67ccf2b1..40ce9097c88 100644
--- a/app/services/incident_management/timeline_events/create_service.rb
+++ b/app/services/incident_management/timeline_events/create_service.rb
@@ -48,6 +48,26 @@ module IncidentManagement
new(incident, user, note: note, occurred_at: occurred_at, action: action, auto_created: true).execute
end
+
+ def change_labels(incident, user, added_labels: [], removed_labels: [])
+ return if Feature.disabled?(:incident_timeline_events_from_labels, incident.project)
+
+ if added_labels.blank? && removed_labels.blank?
+ return ServiceResponse.error(message: _('There are no changed labels'))
+ end
+
+ labels_note = -> (verb, labels) {
+ "#{verb} #{labels.map(&:to_reference).join(' ')} #{'label'.pluralize(labels.count)}" if labels.present?
+ }
+
+ added_note = labels_note.call('added', added_labels)
+ removed_note = labels_note.call('removed', removed_labels)
+ note = "@#{user.username} #{[added_note, removed_note].compact.join(' and ')}"
+ occurred_at = incident.updated_at
+ action = 'label'
+
+ new(incident, user, note: note, occurred_at: occurred_at, action: action, auto_created: true).execute
+ end
end
def execute