Commit 2a5dbf1e authored by Winnie Hellmann's avatar Winnie Hellmann

Display "commented" only for commit discussions on merge requests

Add commit prop to NoteableNote component and pass it from
NoteableDiscussion

(cherry picked from commit 3df4f2a20ece8a12413b91d93ddbc5f9da9a8744)

Conflicts:
	app/assets/javascripts/notes/components/noteable_note.vue
parent 262c8f35
...@@ -221,6 +221,16 @@ export default { ...@@ -221,6 +221,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.`;
:note="componentData(initialDiscussion)" :note="componentData(initialDiscussion)"
:line="line" :line="line"
:help-page-path="helpPagePath" :help-page-path="helpPagePath"
:commit="commit"
@handleDeleteNote="deleteNoteHandler" @handleDeleteNote="deleteNoteHandler"
> >
<note-edited-text <note-edited-text
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
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 { s__, sprintf } from '~/locale';
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 +39,11 @@ export default { ...@@ -37,6 +39,11 @@ export default {
required: false, required: false,
default: '', default: '',
}, },
commit: {
type: Object,
required: false,
default: () => null,
},
}, },
data() { data() {
return { return {
...@@ -73,6 +80,24 @@ export default { ...@@ -73,6 +80,24 @@ export default {
isTarget() { isTarget() {
return this.targetNoteHash === this.noteAnchorId; return this.targetNoteHash === this.noteAnchorId;
}, },
actionText() {
if (this.commit) {
const { id, url } = this.commit;
const linkStart = `<a class="commit-sha monospace" href="${escape(url)}">`;
const linkEnd = '</a>';
return sprintf(
s__('MergeRequests|commented on commit %{linkStart}%{commitId}%{linkEnd}'),
{
commitId: truncateSha(id),
linkStart,
linkEnd,
},
false,
);
}
return '<span class="d-none d-sm-inline">&middot;</span>';
},
}, },
created() { created() {
...@@ -204,14 +229,9 @@ export default { ...@@ -204,14 +229,9 @@ 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 <slot slot="note-header-info" name="note-header-info"></slot>
:author="author" <span v-html="actionText"></span>
:created-at="note.created_at"
:note-id="note.id"
action-text="commented"
>
<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"
......
---
title: Display "commented" only for commit discussions on merge requests
merge_request: 23622
author:
type: fixed
...@@ -5423,6 +5423,9 @@ msgstr "" ...@@ -5423,6 +5423,9 @@ msgstr ""
msgid "MergeRequests|View replaced file @ %{commitId}" msgid "MergeRequests|View replaced file @ %{commitId}"
msgstr "" msgstr ""
msgid "MergeRequests|commented on commit %{linkStart}%{commitId}%{linkEnd}"
msgstr ""
msgid "MergeRequests|started a discussion" msgid "MergeRequests|started a discussion"
msgstr "" msgstr ""
......
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