summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/notes/components/noteable_note.vue
diff options
context:
space:
mode:
authorConstance Okoghenun <constanceokoghenun@gmail.com>2019-01-17 12:15:33 +0100
committerConstance Okoghenun <constanceokoghenun@gmail.com>2019-01-17 12:15:33 +0100
commitc1c0c0c21b075ee9ee2eddb75ad9681f29765bb2 (patch)
tree81b8fac501896868be78ecefb1cda93188a3d24d /app/assets/javascripts/notes/components/noteable_note.vue
parenteec16ee28c7b377101ab3d5f81835cd8c2020981 (diff)
downloadgitlab-ce-c1c0c0c21b075ee9ee2eddb75ad9681f29765bb2.tar.gz
Display "commented" only for commit discussions on merge requests
Add commit prop to NoteableNote component and pass it from NoteableDiscussion
Diffstat (limited to 'app/assets/javascripts/notes/components/noteable_note.vue')
-rw-r--r--app/assets/javascripts/notes/components/noteable_note.vue30
1 files changed, 28 insertions, 2 deletions
diff --git a/app/assets/javascripts/notes/components/noteable_note.vue b/app/assets/javascripts/notes/components/noteable_note.vue
index 4c02588127e..c39dcc71aa6 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">&middot;</span>';
+ },
},
created() {
@@ -205,8 +230,9 @@ export default {
:author="author"
:created-at="note.created_at"
:note-id="note.id"
- action-text="commented"
- />
+ >
+ <span v-html="actionText"></span>
+ </note-header>
<note-actions
:author-id="author.id"
:note-id="note.id"