gitlab-org--gitlab-foss/app/assets/javascripts/notes/components/note_header.vue

121 lines
2.7 KiB
Vue
Raw Normal View History

<script>
2018-03-16 20:16:21 +00:00
import { mapActions } from 'vuex';
import timeAgoTooltip from '../../vue_shared/components/time_ago_tooltip.vue';
2018-03-16 20:16:21 +00:00
export default {
components: {
timeAgoTooltip,
},
props: {
author: {
type: Object,
required: false,
default: () => ({}),
2018-01-05 00:18:35 +00:00
},
2018-03-16 20:16:21 +00:00
createdAt: {
type: String,
required: true,
},
2018-03-16 20:16:21 +00:00
actionText: {
type: String,
required: false,
default: '',
},
2018-03-16 20:16:21 +00:00
noteId: {
type: String,
2018-03-16 20:16:21 +00:00
required: true,
},
includeToggle: {
type: Boolean,
required: false,
default: false,
},
expanded: {
type: Boolean,
required: false,
default: true,
},
},
computed: {
toggleChevronClass() {
return this.expanded ? 'fa-chevron-up' : 'fa-chevron-down';
},
noteTimestampLink() {
return `#note_${this.noteId}`;
},
},
methods: {
...mapActions(['setTargetNoteHash']),
handleToggle() {
this.$emit('toggleHandler');
},
updateTargetNoteHash() {
this.setTargetNoteHash(this.noteTimestampLink);
},
},
};
</script>
<template>
<div class="note-header-info">
<div
v-if="includeToggle"
class="discussion-actions">
<button
class="note-action-button discussion-toggle-button js-vue-toggle-button"
2018-06-11 09:49:47 +00:00
type="button"
@click="handleToggle">
<i
:class="toggleChevronClass"
class="fa"
aria-hidden="true">
</i>
{{ __('Toggle discussion') }}
</button>
</div>
<a
v-if="Object.keys(author).length"
:href="author.path"
>
<span class="note-header-author-name">{{ author.name }}</span>
<span
v-if="author.status_tooltip_html"
v-html="author.status_tooltip_html"></span>
<span class="note-headline-light">
2018-01-05 00:18:35 +00:00
@{{ author.username }}
</span>
</a>
<span v-else>
{{ __('A deleted user') }}
</span>
<span class="note-headline-light">
<span class="note-headline-meta">
<template v-if="actionText">
2018-01-05 00:18:35 +00:00
{{ actionText }}
</template>
2018-06-21 12:22:40 +00:00
<span class="system-note-message">
<slot></slot>
</span>
<span class="system-note-separator">
&middot;
</span>
<a
:href="noteTimestampLink"
2018-06-11 09:49:47 +00:00
class="note-timestamp system-note-separator"
@click="updateTargetNoteHash">
<time-ago-tooltip
:time="createdAt"
tooltip-placement="bottom"
2018-01-05 00:18:35 +00:00
/>
</a>
<i
class="fa fa-spinner fa-spin editing-spinner"
aria-label="Comment is being updated"
2018-01-05 00:18:35 +00:00
aria-hidden="true"
>
</i>
</span>
</span>
</div>
</template>