diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /app/services/incident_management | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'app/services/incident_management')
4 files changed, 13 insertions, 1 deletions
diff --git a/app/services/incident_management/timeline_events/base_service.rb b/app/services/incident_management/timeline_events/base_service.rb index cae58465e4a..7168e2fdd38 100644 --- a/app/services/incident_management/timeline_events/base_service.rb +++ b/app/services/incident_management/timeline_events/base_service.rb @@ -3,6 +3,8 @@ module IncidentManagement module TimelineEvents class BaseService + include Gitlab::Utils::UsageData + def allowed? user&.can?(:admin_incident_management_timeline_event, incident) end diff --git a/app/services/incident_management/timeline_events/create_service.rb b/app/services/incident_management/timeline_events/create_service.rb index 7d287e1bd82..5e5feed65c2 100644 --- a/app/services/incident_management/timeline_events/create_service.rb +++ b/app/services/incident_management/timeline_events/create_service.rb @@ -3,6 +3,7 @@ module IncidentManagement module TimelineEvents DEFAULT_ACTION = 'comment' + DEFAULT_EDITABLE = false class CreateService < TimelineEvents::BaseService def initialize(incident, user, params) @@ -23,7 +24,8 @@ module IncidentManagement action: params.fetch(:action, DEFAULT_ACTION), note_html: params[:note_html].presence || params[:note], occurred_at: params[:occurred_at], - promoted_from_note: params[:promoted_from_note] + promoted_from_note: params[:promoted_from_note], + editable: params.fetch(:editable, DEFAULT_EDITABLE) } timeline_event = IncidentManagement::TimelineEvent.new(timeline_event_params) @@ -31,6 +33,7 @@ module IncidentManagement if timeline_event.save add_system_note(timeline_event) + track_usage_event(:incident_management_timeline_event_created, user.id) success(timeline_event) else error_in_save(timeline_event) diff --git a/app/services/incident_management/timeline_events/destroy_service.rb b/app/services/incident_management/timeline_events/destroy_service.rb index 8bb186c289a..90e95ae8869 100644 --- a/app/services/incident_management/timeline_events/destroy_service.rb +++ b/app/services/incident_management/timeline_events/destroy_service.rb @@ -18,6 +18,7 @@ module IncidentManagement if timeline_event.destroy add_system_note(incident, user) + track_usage_event(:incident_management_timeline_event_deleted, user.id) success(timeline_event) else error_in_save(timeline_event) diff --git a/app/services/incident_management/timeline_events/update_service.rb b/app/services/incident_management/timeline_events/update_service.rb index fe8b4879561..83497b123dd 100644 --- a/app/services/incident_management/timeline_events/update_service.rb +++ b/app/services/incident_management/timeline_events/update_service.rb @@ -17,11 +17,13 @@ module IncidentManagement end def execute + return error_non_editable unless timeline_event.editable? return error_no_permissions unless allowed? if timeline_event.update(update_params) add_system_note(timeline_event) + track_usage_event(:incident_management_timeline_event_edited, user.id) success(timeline_event) else error_in_save(timeline_event) @@ -56,6 +58,10 @@ module IncidentManagement :none end + + def error_non_editable + error(_('You cannot edit this timeline event.')) + end end end end |