2018-12-13 13:39:08 +05:30
|
|
|
<script>
|
2020-03-13 15:44:24 +05:30
|
|
|
import { uniqBy } from 'lodash';
|
2021-01-29 00:20:46 +05:30
|
|
|
import { GlButton, 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: {
|
2021-01-29 00:20:46 +05:30
|
|
|
GlButton,
|
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() {
|
2021-03-08 18:12:59 +05:30
|
|
|
const authors = this.replies.map((reply) => reply.author || {});
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2021-03-08 18:12:59 +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>
|
2021-01-29 00:20:46 +05:30
|
|
|
<gl-button
|
|
|
|
class="js-replies-text"
|
|
|
|
category="tertiary"
|
|
|
|
variant="link"
|
2021-01-03 14:25:43 +05:30
|
|
|
data-qa-selector="expand_replies_button"
|
|
|
|
@click="toggle"
|
|
|
|
>
|
2018-12-13 13:39:08 +05:30
|
|
|
{{ replies.length }} {{ n__('reply', 'replies', replies.length) }}
|
2021-01-29 00:20:46 +05:30
|
|
|
</gl-button>
|
2018-12-13 13:39:08 +05:30
|
|
|
{{ __('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
|
2021-01-03 14:25:43 +05:30
|
|
|
class="collapse-replies-btn js-collapse-replies"
|
|
|
|
data-qa-selector="collapse_replies_button"
|
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>
|