Skip to content
代码片段 群组 项目
提交 847bad44 编辑于 作者: Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak
浏览文件

Merge branch '372994-promote-note-text-backend' into 'master'

Add prefix comment on note when promoted to timeline event

See merge request gitlab-org/gitlab!97473
No related branches found
No related tags found
无相关合并请求
......@@ -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
......
......@@ -46564,6 +46564,9 @@ msgstr ""
msgid "comment"
msgstr ""
 
msgid "commented"
msgstr ""
msgid "commented on %{link_to_project}"
msgstr ""
 
......@@ -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,
......
......@@ -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
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册