2018-12-13 13:39:08 +05:30
|
|
|
<script>
|
2020-03-13 15:44:24 +05:30
|
|
|
import { uniqBy } from 'lodash';
|
2020-11-24 15:15:51 +05:30
|
|
|
import { GlIcon } from '@gitlab/ui';
|
2018-12-13 13:39:08 +05:30
|
|
|
import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue';
|
|
|
|
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2020-11-24 15:15:51 +05:30
|
|
|
GlIcon,
|
2018-12-13 13:39:08 +05:30
|
|
|
UserAvatarLink,
|
|
|
|
TimeAgoTooltip,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
collapsed: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
replies: {
|
|
|
|
type: Array,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
lastReply() {
|
|
|
|
return this.replies[this.replies.length - 1];
|
|
|
|
},
|
|
|
|
uniqueAuthors() {
|
|
|
|
const authors = this.replies.map(reply => reply.author || {});
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
return uniqBy(authors, author => author.username);
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
|
|
|
className() {
|
|
|
|
return this.collapsed ? 'collapsed' : 'expanded';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toggle() {
|
|
|
|
this.$emit('toggle');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2019-02-15 15:39:39 +05:30
|
|
|
<li :class="className" class="replies-toggle js-toggle-replies">
|
2018-12-13 13:39:08 +05:30
|
|
|
<template v-if="collapsed">
|
2020-11-24 15:15:51 +05:30
|
|
|
<gl-icon name="chevron-right" @click.native="toggle" />
|
2018-12-13 13:39:08 +05:30
|
|
|
<div>
|
|
|
|
<user-avatar-link
|
|
|
|
v-for="author in uniqueAuthors"
|
|
|
|
:key="author.username"
|
|
|
|
:link-href="author.path"
|
|
|
|
:img-alt="author.name"
|
|
|
|
:img-src="author.avatar_url"
|
|
|
|
:img-size="26"
|
|
|
|
:tooltip-text="author.name"
|
|
|
|
tooltip-placement="bottom"
|
|
|
|
/>
|
|
|
|
</div>
|
2019-02-15 15:39:39 +05:30
|
|
|
<button class="btn btn-link js-replies-text qa-expand-replies" type="button" @click="toggle">
|
2018-12-13 13:39:08 +05:30
|
|
|
{{ replies.length }} {{ n__('reply', 'replies', replies.length) }}
|
|
|
|
</button>
|
|
|
|
{{ __('Last reply by') }}
|
2019-02-15 15:39:39 +05:30
|
|
|
<a :href="lastReply.author.path" class="btn btn-link author-link">
|
2018-12-13 13:39:08 +05:30
|
|
|
{{ lastReply.author.name }}
|
|
|
|
</a>
|
2019-02-15 15:39:39 +05:30
|
|
|
<time-ago-tooltip :time="lastReply.created_at" tooltip-placement="bottom" />
|
2018-12-13 13:39:08 +05:30
|
|
|
</template>
|
2019-01-03 12:48:30 +05:30
|
|
|
<span
|
|
|
|
v-else
|
2019-02-15 15:39:39 +05:30
|
|
|
class="collapse-replies-btn js-collapse-replies qa-collapse-replies"
|
2019-01-03 12:48:30 +05:30
|
|
|
@click="toggle"
|
|
|
|
>
|
2020-11-24 15:15:51 +05:30
|
|
|
<gl-icon name="chevron-down" /> {{ s__('Notes|Collapse replies') }}
|
2018-12-13 13:39:08 +05:30
|
|
|
</span>
|
|
|
|
</li>
|
|
|
|
</template>
|