diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 12:45:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 12:45:46 +0300 |
commit | a7b3560714b4d9cc4ab32dffcd1f74a284b93580 (patch) | |
tree | 7452bd5c3545c2fa67a28aa013835fb4fa071baf /app/services/system_notes | |
parent | ee9173579ae56a3dbfe5afe9f9410c65bb327ca7 (diff) |
Add latest changes from gitlab-org/gitlab@14-8-stable-eev14.8.0-rc42
Diffstat (limited to 'app/services/system_notes')
-rw-r--r-- | app/services/system_notes/alert_management_service.rb | 26 | ||||
-rw-r--r-- | app/services/system_notes/incident_service.rb | 15 | ||||
-rw-r--r-- | app/services/system_notes/issuables_service.rb | 29 |
3 files changed, 48 insertions, 22 deletions
diff --git a/app/services/system_notes/alert_management_service.rb b/app/services/system_notes/alert_management_service.rb index 70cdd5c6434..994e3174668 100644 --- a/app/services/system_notes/alert_management_service.rb +++ b/app/services/system_notes/alert_management_service.rb @@ -24,11 +24,12 @@ module SystemNotes # Example Note text: # # "changed the status to Acknowledged" + # "changed the status to Acknowledged by changing the incident status of #540" # # Returns the created Note object - def change_alert_status(alert) - status = alert.state.to_s.titleize - body = "changed the status to **#{status}**" + def change_alert_status(reason) + status = noteable.state.to_s.titleize + body = "changed the status to **#{status}**#{reason}" create_note(NoteSummary.new(noteable, project, author, body, action: 'status')) end @@ -39,30 +40,15 @@ module SystemNotes # # Example Note text: # - # "created issue #17 for this alert" + # "created incident #17 for this alert" # # Returns the created Note object def new_alert_issue(issue) - body = "created issue #{issue.to_reference(project)} for this alert" + body = "created incident #{issue.to_reference(project)} for this alert" create_note(NoteSummary.new(noteable, project, author, body, action: 'alert_issue_added')) end - # Called when an AlertManagement::Alert is resolved due to the associated issue being closed - # - # issue - Issue object. - # - # Example Note text: - # - # "changed the status to Resolved by closing issue #17" - # - # Returns the created Note object - def closed_alert_issue(issue) - body = "changed the status to **Resolved** by closing issue #{issue.to_reference(project)}" - - create_note(NoteSummary.new(noteable, project, author, body, action: 'status')) - end - # Called when an alert is resolved due to received resolving alert payload # # alert - AlertManagement::Alert object. diff --git a/app/services/system_notes/incident_service.rb b/app/services/system_notes/incident_service.rb index 785291e0637..f3f9dfbec96 100644 --- a/app/services/system_notes/incident_service.rb +++ b/app/services/system_notes/incident_service.rb @@ -26,8 +26,19 @@ module SystemNotes end end - def resolve_incident_status - body = 'changed the status to **Resolved** by closing the incident' + # Called when the status of an IncidentManagement::IssuableEscalationStatus has changed + # + # reason - String. + # + # Example Note text: + # + # "changed the incident status to Acknowledged" + # "changed the incident status to Acknowledged by changing the status of ^alert#540" + # + # Returns the created Note object + def change_incident_status(reason) + status = noteable.escalation_status.status_name.to_s.titleize + body = "changed the incident status to **#{status}**#{reason}" create_note(NoteSummary.new(noteable, project, author, body, action: 'status')) end diff --git a/app/services/system_notes/issuables_service.rb b/app/services/system_notes/issuables_service.rb index d33dcd65589..09f36bb6501 100644 --- a/app/services/system_notes/issuables_service.rb +++ b/app/services/system_notes/issuables_service.rb @@ -111,6 +111,35 @@ module SystemNotes create_note(NoteSummary.new(noteable, project, author, body, action: 'reviewer')) end + # Called when the contacts of an issuable are changed or removed + # We intend to reference the contacts but for security we are just + # going to state how many were added/removed for now. See discussion: + # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/77816#note_806114273 + # + # added_count - number of contacts added, or 0 + # removed_count - number of contacts removed, or 0 + # + # Example Note text: + # + # "added 2 contacts" + # + # "added 3 contacts and removed one contact" + # + # Returns the created Note object + def change_issuable_contacts(added_count, removed_count) + text_parts = [] + + Gitlab::I18n.with_default_locale do + text_parts << "added #{added_count} #{'contact'.pluralize(added_count)}" if added_count > 0 + text_parts << "removed #{removed_count} #{'contact'.pluralize(removed_count)}" if removed_count > 0 + end + + return if text_parts.empty? + + body = text_parts.join(' and ') + create_note(NoteSummary.new(noteable, project, author, body, action: 'contact')) + end + # Called when the title of a Noteable is changed # # old_title - Previous String title |