Commit 347e3747 authored by Constance Okoghenun's avatar Constance Okoghenun

EE Port of Display "commented" only for commit discussions

EE backport of
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/24427
parent 1ad50299
...@@ -222,6 +222,16 @@ export default { ...@@ -222,6 +222,16 @@ export default {
return this.line; return this.line;
}, },
commit() {
if (!this.discussion.for_commit) {
return null;
}
return {
id: this.discussion.commit_id,
url: this.discussion.discussion_path,
};
},
}, },
watch: { watch: {
isReplying() { isReplying() {
...@@ -386,6 +396,7 @@ Please check your network connection and try again.`; ...@@ -386,6 +396,7 @@ Please check your network connection and try again.`;
:is="componentName(initialDiscussion)" :is="componentName(initialDiscussion)"
:note="componentData(initialDiscussion)" :note="componentData(initialDiscussion)"
:line="line" :line="line"
:commit="commit"
:help-page-path="helpPagePath" :help-page-path="helpPagePath"
@handleDeleteNote="deleteNoteHandler" @handleDeleteNote="deleteNoteHandler"
> >
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import $ from 'jquery'; import $ from 'jquery';
import { mapGetters, mapActions } from 'vuex'; import { mapGetters, mapActions } from 'vuex';
import { escape } from 'underscore'; import { escape } from 'underscore';
import { truncateSha } from '~/lib/utils/text_utility';
import TimelineEntryItem from '~/vue_shared/components/notes/timeline_entry_item.vue'; import TimelineEntryItem from '~/vue_shared/components/notes/timeline_entry_item.vue';
import Flash from '../../flash'; import Flash from '../../flash';
import userAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue'; import userAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue';
...@@ -37,6 +38,11 @@ export default { ...@@ -37,6 +38,11 @@ export default {
required: false, required: false,
default: '', default: '',
}, },
commit: {
type: Object,
required: false,
default: () => null,
},
}, },
data() { data() {
return { return {
...@@ -73,6 +79,13 @@ export default { ...@@ -73,6 +79,13 @@ export default {
isTarget() { isTarget() {
return this.targetNoteHash === this.noteAnchorId; return this.targetNoteHash === this.noteAnchorId;
}, },
truncatedHash() {
if (!this.commit) {
return null;
}
return truncateSha(this.commit.id);
},
}, },
created() { created() {
...@@ -204,14 +217,12 @@ export default { ...@@ -204,14 +217,12 @@ export default {
</div> </div>
<div class="timeline-content"> <div class="timeline-content">
<div class="note-header"> <div class="note-header">
<note-header <note-header v-once :author="author" :created-at="note.created_at" :note-id="note.id">
v-once <span v-if="commit">
:author="author" {{ s__('MergeRequests|commented on commit ')
:created-at="note.created_at" }}<a class="commit-sha monospace" :href="commit.url">{{ truncatedHash }}</a>
:note-id="note.id" </span>
action-text="commented" <span v-else class="d-none d-sm-inline">&middot;</span>
>
<slot slot="note-header-info" name="note-header-info"> </slot>
</note-header> </note-header>
<note-actions <note-actions
:author-id="author.id" :author-id="author.id"
......
...@@ -85,7 +85,7 @@ module NotesHelper ...@@ -85,7 +85,7 @@ module NotesHelper
diffs_project_merge_request_path(discussion.project, discussion.noteable, path_params) diffs_project_merge_request_path(discussion.project, discussion.noteable, path_params)
elsif discussion.for_commit? elsif discussion.for_commit?
anchor = discussion.line_code if discussion.diff_discussion? anchor = discussion.diff_discussion? ? discussion.line_code : "note_#{discussion.first_note.id}"
project_commit_path(discussion.project, discussion.noteable, anchor: anchor) project_commit_path(discussion.project, discussion.noteable, anchor: anchor)
end end
......
---
title: Display "commented" only for commit discussions on merge requests
merge_request: 24427
author:
type: changed
...@@ -5644,6 +5644,9 @@ msgstr "" ...@@ -5644,6 +5644,9 @@ msgstr ""
msgid "MergeRequests|View replaced file @ %{commitId}" msgid "MergeRequests|View replaced file @ %{commitId}"
msgstr "" msgstr ""
msgid "MergeRequests|commented on commit "
msgstr ""
msgid "MergeRequests|started a discussion" msgid "MergeRequests|started a discussion"
msgstr "" msgstr ""
......
...@@ -88,5 +88,17 @@ describe 'Merge request > User sees discussions', :js do ...@@ -88,5 +88,17 @@ describe 'Merge request > User sees discussions', :js do
expect(page).to have_content "started a discussion on commit #{note.commit_id[0...7]}" expect(page).to have_content "started a discussion on commit #{note.commit_id[0...7]}"
end end
end end
context 'a commit non-diff discussion' do
let(:note) { create(:discussion_note_on_commit, project: project) }
it 'displays correct header' do
page.within(find("#note_#{note.id}", match: :first)) do
refresh # Trigger a refresh of notes.
wait_for_requests
expect(page).to have_content "commented on commit #{note.commit_id[0...7]}"
end
end
end
end end
end end
...@@ -185,8 +185,8 @@ describe NotesHelper do ...@@ -185,8 +185,8 @@ describe NotesHelper do
context 'for a non-diff discussion' do context 'for a non-diff discussion' do
let(:discussion) { create(:discussion_note_on_commit, project: project).to_discussion } let(:discussion) { create(:discussion_note_on_commit, project: project).to_discussion }
it 'returns the commit path' do it 'returns the commit path with the note anchor' do
expect(helper.discussion_path(discussion)).to eq(project_commit_path(project, commit)) expect(helper.discussion_path(discussion)).to eq(project_commit_path(project, commit, anchor: "note_#{discussion.first_note.id}"))
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment