diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2018-12-06 15:10:14 +0100 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2018-12-19 23:54:54 +0100 |
commit | 6aed2212bd82ca09780b2a1dc686fae20dc78dac (patch) | |
tree | 38b2e5066a6efe6da90aac83936e3c904a2d92ac | |
parent | 0ee8b2a74bfb2e292874939188929d262a62a0bb (diff) | |
download | gitlab-ce-6aed2212bd82ca09780b2a1dc686fae20dc78dac.tar.gz |
Display "commented" only for commit discussions on merge requests
Add commit prop to NoteableNote component and pass it from
NoteableDiscussion
-rw-r--r-- | app/assets/javascripts/notes/components/noteable_discussion.vue | 11 | ||||
-rw-r--r-- | app/assets/javascripts/notes/components/noteable_note.vue | 35 | ||||
-rw-r--r-- | changelogs/unreleased/winh-discussion-header-commented.yml | 5 | ||||
-rw-r--r-- | locale/gitlab.pot | 3 |
4 files changed, 47 insertions, 7 deletions
diff --git a/app/assets/javascripts/notes/components/noteable_discussion.vue b/app/assets/javascripts/notes/components/noteable_discussion.vue index d9dd08a7a6b..bba215852b7 100644 --- a/app/assets/javascripts/notes/components/noteable_discussion.vue +++ b/app/assets/javascripts/notes/components/noteable_discussion.vue @@ -211,6 +211,16 @@ export default { return this.line; }, + commit() { + if (!this.discussion.for_commit) { + return null; + } + + return { + id: this.discussion.commit_id, + url: this.discussion.discussion_path, + }; + }, }, watch: { isReplying() { @@ -376,6 +386,7 @@ Please check your network connection and try again.`; :note="componentData(initialDiscussion)" :line="line" :help-page-path="helpPagePath" + :commit="commit" @handleDeleteNote="deleteNoteHandler" > <note-edited-text diff --git a/app/assets/javascripts/notes/components/noteable_note.vue b/app/assets/javascripts/notes/components/noteable_note.vue index 4c02588127e..6edc65c856e 100644 --- a/app/assets/javascripts/notes/components/noteable_note.vue +++ b/app/assets/javascripts/notes/components/noteable_note.vue @@ -2,6 +2,8 @@ import $ from 'jquery'; import { mapGetters, mapActions } from 'vuex'; 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 Flash from '../../flash'; import userAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue'; @@ -37,6 +39,11 @@ export default { required: false, default: '', }, + commit: { + type: Object, + required: false, + default: () => null, + }, }, data() { return { @@ -73,6 +80,24 @@ export default { isTarget() { 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">·</span>'; + }, }, created() { @@ -200,13 +225,9 @@ export default { </div> <div class="timeline-content"> <div class="note-header"> - <note-header - v-once - :author="author" - :created-at="note.created_at" - :note-id="note.id" - action-text="commented" - /> + <note-header v-once :author="author" :created-at="note.created_at" :note-id="note.id"> + <span v-html="actionText"></span> + </note-header> <note-actions :author-id="author.id" :note-id="note.id" diff --git a/changelogs/unreleased/winh-discussion-header-commented.yml b/changelogs/unreleased/winh-discussion-header-commented.yml new file mode 100644 index 00000000000..8d08409b504 --- /dev/null +++ b/changelogs/unreleased/winh-discussion-header-commented.yml @@ -0,0 +1,5 @@ +--- +title: Display "commented" only for commit discussions on merge requests +merge_request: 23622 +author: +type: fixed diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 61fb56d2fa2..7c534b4260f 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -4123,6 +4123,9 @@ msgstr "" msgid "MergeRequests|View replaced file @ %{commitId}" msgstr "" +msgid "MergeRequests|commented on commit %{linkStart}%{commitId}%{linkEnd}" +msgstr "" + msgid "MergeRequests|started a discussion" msgstr "" |