Commit 682a4393 authored by Constance Okoghenun's avatar Constance Okoghenun

Refactored implementation of discussion note header

- Removed use of v-html
- Removed HTML content from the computed property
parent b3d748b8
...@@ -3,7 +3,6 @@ import $ from 'jquery'; ...@@ -3,7 +3,6 @@ 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 { 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';
...@@ -80,23 +79,12 @@ export default { ...@@ -80,23 +79,12 @@ export default {
isTarget() { isTarget() {
return this.targetNoteHash === this.noteAnchorId; return this.targetNoteHash === this.noteAnchorId;
}, },
actionText() { truncatedHash() {
if (this.commit) { if (!this.commit) {
const { id, url } = this.commit; return null;
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>'; return truncateSha(this.commit.id);
}, },
}, },
...@@ -225,13 +213,12 @@ export default { ...@@ -225,13 +213,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>
> <span v-else class="d-none d-sm-inline">&middot;</span>
<span v-html="actionText"></span>
</note-header> </note-header>
<note-actions <note-actions
:author-id="author.id" :author-id="author.id"
......
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