diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-03 09:07:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-03 09:07:46 +0300 |
commit | bbc0882f5730aff94a0739a481b42143708949c2 (patch) | |
tree | 88abf70b4247de8e93213bbc00c1f51d4e28a269 /app/services/incident_management | |
parent | 26dfad7651130842a18a3c05c7a9731084da1695 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/incident_management')
-rw-r--r-- | app/services/incident_management/timeline_events/create_service.rb | 6 | ||||
-rw-r--r-- | app/services/incident_management/timeline_events/update_service.rb | 9 |
2 files changed, 12 insertions, 3 deletions
diff --git a/app/services/incident_management/timeline_events/create_service.rb b/app/services/incident_management/timeline_events/create_service.rb index bf3de5c9293..32b9d3eab7b 100644 --- a/app/services/incident_management/timeline_events/create_service.rb +++ b/app/services/incident_management/timeline_events/create_service.rb @@ -97,7 +97,7 @@ module IncidentManagement timeline_event = IncidentManagement::TimelineEvent.new(timeline_event_params) - if timeline_event.save + if timeline_event.save(context: validation_context) add_system_note(timeline_event) track_usage_event(:incident_management_timeline_event_created, user.id) @@ -122,6 +122,10 @@ module IncidentManagement SystemNoteService.add_timeline_event(timeline_event) end + + def validation_context + :user_input if !auto_created && params[:promoted_from_note].blank? + end end end end diff --git a/app/services/incident_management/timeline_events/update_service.rb b/app/services/incident_management/timeline_events/update_service.rb index 012e2f0e260..8d4e29c6857 100644 --- a/app/services/incident_management/timeline_events/update_service.rb +++ b/app/services/incident_management/timeline_events/update_service.rb @@ -8,18 +8,23 @@ module IncidentManagement # @option params [string] note # @option params [datetime] occurred_at class UpdateService < TimelineEvents::BaseService + VALIDATION_CONTEXT = :user_input + def initialize(timeline_event, user, params) @timeline_event = timeline_event @incident = timeline_event.incident @user = user @note = params[:note] @occurred_at = params[:occurred_at] + @validation_context = VALIDATION_CONTEXT end def execute return error_no_permissions unless allowed? - if timeline_event.update(update_params) + timeline_event.assign_attributes(update_params) + + if timeline_event.save(context: validation_context) add_system_note(timeline_event) track_usage_event(:incident_management_timeline_event_edited, user.id) @@ -31,7 +36,7 @@ module IncidentManagement private - attr_reader :timeline_event, :incident, :user, :note, :occurred_at + attr_reader :timeline_event, :incident, :user, :note, :occurred_at, :validation_context def update_params { updated_by_user: user, note: note, occurred_at: occurred_at }.compact |