2018-03-17 18:26:18 +05:30
|
|
|
<script>
|
2020-11-24 15:15:51 +05:30
|
|
|
/* eslint-disable vue/no-v-html */
|
2021-03-11 19:13:27 +05:30
|
|
|
import { GlIcon, GlLoadingIcon, GlTooltipDirective } from '@gitlab/ui';
|
2018-05-09 12:01:36 +05:30
|
|
|
import { mapActions } from 'vuex';
|
2020-04-22 19:07:51 +05:30
|
|
|
import timeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
|
2021-03-11 19:13:27 +05:30
|
|
|
import UserNameWithStatus from '../../sidebar/components/assignees/user_name_with_status.vue';
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
timeAgoTooltip,
|
2020-05-24 23:13:21 +05:30
|
|
|
GitlabTeamMemberBadge: () =>
|
|
|
|
import('ee_component/vue_shared/components/user_avatar/badges/gitlab_team_member_badge.vue'),
|
|
|
|
GlIcon,
|
2020-11-24 15:15:51 +05:30
|
|
|
GlLoadingIcon,
|
2021-03-11 19:13:27 +05:30
|
|
|
UserNameWithStatus,
|
2020-05-24 23:13:21 +05:30
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
GlTooltip: GlTooltipDirective,
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
props: {
|
|
|
|
author: {
|
|
|
|
type: Object,
|
2018-11-20 20:47:30 +05:30
|
|
|
required: false,
|
|
|
|
default: () => ({}),
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
createdAt: {
|
|
|
|
type: String,
|
2018-12-05 23:21:45 +05:30
|
|
|
required: false,
|
|
|
|
default: null,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
actionText: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
noteId: {
|
2018-12-05 23:21:45 +05:30
|
|
|
type: [String, Number],
|
|
|
|
required: false,
|
|
|
|
default: null,
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
includeToggle: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
expanded: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: true,
|
|
|
|
},
|
2020-04-22 19:07:51 +05:30
|
|
|
showSpinner: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: true,
|
|
|
|
},
|
2020-05-24 23:13:21 +05:30
|
|
|
isConfidential: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isUsernameLinkHovered: false,
|
|
|
|
emojiTitle: '',
|
|
|
|
authorStatusHasTooltip: false,
|
|
|
|
};
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
computed: {
|
2021-01-29 00:20:46 +05:30
|
|
|
toggleChevronIconName() {
|
|
|
|
return this.expanded ? 'chevron-up' : 'chevron-down';
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
noteTimestampLink() {
|
2020-04-22 19:07:51 +05:30
|
|
|
return this.noteId ? `#note_${this.noteId}` : undefined;
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
hasAuthor() {
|
|
|
|
return this.author && Object.keys(this.author).length;
|
|
|
|
},
|
2020-05-24 23:13:21 +05:30
|
|
|
authorLinkClasses() {
|
|
|
|
return {
|
|
|
|
hover: this.isUsernameLinkHovered,
|
|
|
|
'text-underline': this.isUsernameLinkHovered,
|
|
|
|
'author-name-link': true,
|
|
|
|
'js-user-link': true,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
authorStatus() {
|
2021-02-22 17:27:13 +05:30
|
|
|
if (this.author?.show_status) {
|
|
|
|
return this.author.status_tooltip_html;
|
|
|
|
}
|
|
|
|
return false;
|
2020-05-24 23:13:21 +05:30
|
|
|
},
|
|
|
|
emojiElement() {
|
|
|
|
return this.$refs?.authorStatus?.querySelector('gl-emoji');
|
2020-04-22 19:07:51 +05:30
|
|
|
},
|
2021-01-29 00:20:46 +05:30
|
|
|
authorName() {
|
|
|
|
return this.author.name;
|
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
2020-05-24 23:13:21 +05:30
|
|
|
mounted() {
|
|
|
|
this.emojiTitle = this.emojiElement ? this.emojiElement.getAttribute('title') : '';
|
|
|
|
|
|
|
|
const authorStatusTitle = this.$refs?.authorStatus
|
|
|
|
?.querySelector('.user-status-emoji')
|
|
|
|
?.getAttribute('title');
|
|
|
|
this.authorStatusHasTooltip = authorStatusTitle && authorStatusTitle !== '';
|
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
methods: {
|
|
|
|
...mapActions(['setTargetNoteHash']),
|
|
|
|
handleToggle() {
|
|
|
|
this.$emit('toggleHandler');
|
|
|
|
},
|
|
|
|
updateTargetNoteHash() {
|
2020-04-22 19:07:51 +05:30
|
|
|
if (this.$store) {
|
|
|
|
this.setTargetNoteHash(this.noteTimestampLink);
|
|
|
|
}
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
2020-05-24 23:13:21 +05:30
|
|
|
removeEmojiTitle() {
|
|
|
|
this.emojiElement.removeAttribute('title');
|
|
|
|
},
|
|
|
|
addEmojiTitle() {
|
|
|
|
this.emojiElement.setAttribute('title', this.emojiTitle);
|
|
|
|
},
|
|
|
|
handleUsernameMouseEnter() {
|
|
|
|
this.$refs.authorNameLink.dispatchEvent(new Event('mouseenter'));
|
|
|
|
this.isUsernameLinkHovered = true;
|
|
|
|
},
|
|
|
|
handleUsernameMouseLeave() {
|
|
|
|
this.$refs.authorNameLink.dispatchEvent(new Event('mouseleave'));
|
|
|
|
this.isUsernameLinkHovered = false;
|
|
|
|
},
|
2021-03-11 19:13:27 +05:30
|
|
|
userAvailability(selectedAuthor) {
|
|
|
|
return selectedAuthor?.availability || '';
|
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
};
|
2018-03-17 18:26:18 +05:30
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="note-header-info">
|
2020-03-13 15:44:24 +05:30
|
|
|
<div v-if="includeToggle" ref="discussionActions" class="discussion-actions">
|
2018-11-08 19:23:39 +05:30
|
|
|
<button
|
|
|
|
class="note-action-button discussion-toggle-button js-vue-toggle-button"
|
|
|
|
type="button"
|
2019-02-15 15:39:39 +05:30
|
|
|
@click="handleToggle"
|
|
|
|
>
|
2021-02-22 17:27:13 +05:30
|
|
|
<gl-icon ref="chevronIcon" :name="toggleChevronIconName" />
|
2019-09-30 21:07:59 +05:30
|
|
|
{{ __('Toggle thread') }}
|
2018-11-08 19:23:39 +05:30
|
|
|
</button>
|
|
|
|
</div>
|
2020-04-22 19:07:51 +05:30
|
|
|
<template v-if="hasAuthor">
|
|
|
|
<a
|
2020-05-24 23:13:21 +05:30
|
|
|
ref="authorNameLink"
|
2020-04-22 19:07:51 +05:30
|
|
|
:href="author.path"
|
2020-05-24 23:13:21 +05:30
|
|
|
:class="authorLinkClasses"
|
2020-04-22 19:07:51 +05:30
|
|
|
:data-user-id="author.id"
|
|
|
|
:data-username="author.username"
|
|
|
|
>
|
|
|
|
<slot name="note-header-info"></slot>
|
2021-03-11 19:13:27 +05:30
|
|
|
<user-name-with-status
|
|
|
|
:name="authorName"
|
|
|
|
:availability="userAvailability(author)"
|
|
|
|
container-classes="note-header-author-name gl-font-weight-bold"
|
|
|
|
/>
|
2020-04-22 19:07:51 +05:30
|
|
|
</a>
|
2020-05-24 23:13:21 +05:30
|
|
|
<span
|
|
|
|
v-if="authorStatus"
|
|
|
|
ref="authorStatus"
|
|
|
|
v-on="
|
|
|
|
authorStatusHasTooltip ? { mouseenter: removeEmojiTitle, mouseleave: addEmojiTitle } : {}
|
|
|
|
"
|
|
|
|
v-html="authorStatus"
|
|
|
|
></span>
|
|
|
|
<span class="text-nowrap author-username">
|
|
|
|
<a
|
|
|
|
ref="authorUsernameLink"
|
|
|
|
class="author-username-link"
|
|
|
|
:href="author.path"
|
|
|
|
@mouseenter="handleUsernameMouseEnter"
|
|
|
|
@mouseleave="handleUsernameMouseLeave"
|
|
|
|
><span class="note-headline-light">@{{ author.username }}</span>
|
|
|
|
</a>
|
|
|
|
<gitlab-team-member-badge v-if="author && author.is_gitlab_employee" />
|
|
|
|
</span>
|
2020-04-22 19:07:51 +05:30
|
|
|
</template>
|
2019-07-07 11:18:12 +05:30
|
|
|
<span v-else>{{ __('A deleted user') }}</span>
|
|
|
|
<span class="note-headline-light note-headline-meta">
|
2021-01-29 00:20:46 +05:30
|
|
|
<span class="system-note-message" data-qa-selector="system_note_content">
|
|
|
|
<slot></slot>
|
|
|
|
</span>
|
2019-07-07 11:18:12 +05:30
|
|
|
<template v-if="createdAt">
|
2020-03-13 15:44:24 +05:30
|
|
|
<span ref="actionText" class="system-note-separator">
|
2019-07-07 11:18:12 +05:30
|
|
|
<template v-if="actionText">{{ actionText }}</template>
|
|
|
|
</span>
|
|
|
|
<a
|
2020-04-22 19:07:51 +05:30
|
|
|
v-if="noteTimestampLink"
|
|
|
|
ref="noteTimestampLink"
|
2019-07-07 11:18:12 +05:30
|
|
|
:href="noteTimestampLink"
|
|
|
|
class="note-timestamp system-note-separator"
|
|
|
|
@click="updateTargetNoteHash"
|
2018-03-17 18:26:18 +05:30
|
|
|
>
|
2019-07-07 11:18:12 +05:30
|
|
|
<time-ago-tooltip :time="createdAt" tooltip-placement="bottom" />
|
|
|
|
</a>
|
2020-04-22 19:07:51 +05:30
|
|
|
<time-ago-tooltip v-else ref="noteTimestamp" :time="createdAt" tooltip-placement="bottom" />
|
2019-07-07 11:18:12 +05:30
|
|
|
</template>
|
2020-05-24 23:13:21 +05:30
|
|
|
<gl-icon
|
|
|
|
v-if="isConfidential"
|
|
|
|
v-gl-tooltip:tooltipcontainer.bottom
|
|
|
|
data-testid="confidentialIndicator"
|
|
|
|
name="eye-slash"
|
2021-03-11 19:13:27 +05:30
|
|
|
:size="16"
|
|
|
|
:title="s__('Notes|This comment is confidential and only visible to project members')"
|
|
|
|
class="gl-ml-1 gl-text-orange-700 align-middle"
|
2020-05-24 23:13:21 +05:30
|
|
|
/>
|
2019-12-26 22:10:19 +05:30
|
|
|
<slot name="extra-controls"></slot>
|
2020-11-24 15:15:51 +05:30
|
|
|
<gl-loading-icon
|
2020-04-22 19:07:51 +05:30
|
|
|
v-if="showSpinner"
|
|
|
|
ref="spinner"
|
2021-09-30 23:02:18 +05:30
|
|
|
size="sm"
|
2020-11-24 15:15:51 +05:30
|
|
|
class="editing-spinner"
|
|
|
|
:label="__('Comment is being updated')"
|
|
|
|
/>
|
2018-03-17 18:26:18 +05:30
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</template>
|