diff --git a/app/graphql/mutations/incident_management/timeline_event/promote_from_note.rb b/app/graphql/mutations/incident_management/timeline_event/promote_from_note.rb index 31ae29d896b0b947b82bb352e446bbc683a60f11..bb1da9278ffa1875d59591b87f9bf4e8cb94100f 100644 --- a/app/graphql/mutations/incident_management/timeline_event/promote_from_note.rb +++ b/app/graphql/mutations/incident_management/timeline_event/promote_from_note.rb @@ -6,6 +6,8 @@ module TimelineEvent class PromoteFromNote < Base graphql_name 'TimelineEventPromoteFromNote' + include NotesHelper + argument :note_id, Types::GlobalIDType[::Note], required: true, description: 'Note ID from which the timeline event promoted.' @@ -20,7 +22,7 @@ def resolve(note_id:) incident, current_user, promoted_from_note: note, - note: note.note, + note: build_note_string(note), occurred_at: note.created_at, editable: true ).execute @@ -38,6 +40,11 @@ def authorize!(object) super end + def build_note_string(note) + commented = _('commented') + "@#{note.author.username} [#{commented}](#{noteable_note_url(note)}): '#{note.note}'" + end + def raise_noteable_not_incident! raise_resource_not_available_error! 'Note does not belong to an incident' end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index ad5d4eb09425b45ae14618a2356284df17e9bf1b..732436619690b9a6855b4c84418692a3cec963cc 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -46564,6 +46564,9 @@ msgstr "" msgid "comment" msgstr "" +msgid "commented" +msgstr "" + msgid "commented on %{link_to_project}" msgstr "" diff --git a/spec/graphql/mutations/incident_management/timeline_event/promote_from_note_spec.rb b/spec/graphql/mutations/incident_management/timeline_event/promote_from_note_spec.rb index 4541f8af7d3c709ab96935231bbb595850be33f2..56514c985ff52f266a5abf64a0a24dcd9e482c19 100644 --- a/spec/graphql/mutations/incident_management/timeline_event/promote_from_note_spec.rb +++ b/spec/graphql/mutations/incident_management/timeline_event/promote_from_note_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe Mutations::IncidentManagement::TimelineEvent::PromoteFromNote do + include NotesHelper + let_it_be(:current_user) { create(:user) } let_it_be(:project) { create(:project) } let_it_be(:incident) { create(:incident, project: project) } @@ -23,7 +25,7 @@ let(:expected_timeline_event) do instance_double( 'IncidentManagement::TimelineEvent', - note: comment.note, + note: "@#{comment.author.username} [commented](#{noteable_note_url(comment)}): '#{comment.note}'", occurred_at: comment.created_at.to_s, incident: incident, author: current_user, diff --git a/spec/requests/api/graphql/mutations/incident_management/timeline_event/promote_from_note_spec.rb b/spec/requests/api/graphql/mutations/incident_management/timeline_event/promote_from_note_spec.rb index 9272e2181721c543d22f95e829be07f1301b2180..85eaec90f475785e44f15ef52ffbc54796a031c7 100644 --- a/spec/requests/api/graphql/mutations/incident_management/timeline_event/promote_from_note_spec.rb +++ b/spec/requests/api/graphql/mutations/incident_management/timeline_event/promote_from_note_spec.rb @@ -4,6 +4,7 @@ RSpec.describe 'Promote an incident timeline event from a comment' do include GraphqlHelpers + include NotesHelper let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project) } @@ -53,7 +54,7 @@ 'promotedFromNote' => { 'id' => comment.to_global_id.to_s }, - 'note' => comment.note, + 'note' => "@#{comment.author.username} [commented](#{noteable_note_url(comment)}): '#{comment.note}'", 'action' => 'comment', 'editable' => true, 'occurredAt' => comment.created_at.iso8601