2018-11-08 02:58:45 -05:00
|
|
|
<script>
|
2020-10-21 23:08:25 -04:00
|
|
|
import { GlButton, GlIcon } from '@gitlab/ui';
|
2021-02-14 13:09:20 -05:00
|
|
|
import { uniqBy } from 'lodash';
|
2018-11-08 02:58:45 -05:00
|
|
|
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
|
2021-02-14 13:09:20 -05:00
|
|
|
import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue';
|
2018-11-08 02:58:45 -05:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2020-10-21 23:08:25 -04:00
|
|
|
GlButton,
|
2020-08-24 11:10:11 -04:00
|
|
|
GlIcon,
|
2018-11-08 02:58:45 -05:00
|
|
|
UserAvatarLink,
|
|
|
|
TimeAgoTooltip,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
collapsed: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
replies: {
|
|
|
|
type: Array,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
lastReply() {
|
|
|
|
return this.replies[this.replies.length - 1];
|
|
|
|
},
|
|
|
|
uniqueAuthors() {
|
2020-12-23 16:10:24 -05:00
|
|
|
const authors = this.replies.map((reply) => reply.author || {});
|
2018-11-08 02:58:45 -05:00
|
|
|
|
2020-12-23 16:10:24 -05:00
|
|
|
return uniqBy(authors, (author) => author.username);
|
2018-11-08 02:58:45 -05:00
|
|
|
},
|
|
|
|
className() {
|
|
|
|
return this.collapsed ? 'collapsed' : 'expanded';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toggle() {
|
|
|
|
this.$emit('toggle');
|
|
|
|
},
|
|
|
|
},
|
2021-01-22 04:08:53 -05:00
|
|
|
ICON_CLASS: 'gl-mr-3 gl-cursor-pointer',
|
2018-11-08 02:58:45 -05:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2021-01-22 04:08:53 -05:00
|
|
|
<li
|
|
|
|
:class="className"
|
|
|
|
class="replies-toggle js-toggle-replies gl-display-flex! gl-align-items-center gl-flex-wrap"
|
|
|
|
>
|
2018-11-08 02:58:45 -05:00
|
|
|
<template v-if="collapsed">
|
2021-01-22 04:08:53 -05:00
|
|
|
<gl-icon :class="$options.ICON_CLASS" name="chevron-right" @click.native="toggle" />
|
2018-11-08 02:58:45 -05:00
|
|
|
<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"
|
2022-03-31 11:08:32 -04:00
|
|
|
:img-size="24"
|
2018-11-08 02:58:45 -05:00
|
|
|
:tooltip-text="author.name"
|
|
|
|
tooltip-placement="bottom"
|
|
|
|
/>
|
|
|
|
</div>
|
2020-10-21 23:08:25 -04:00
|
|
|
<gl-button
|
2021-01-22 04:08:53 -05:00
|
|
|
class="js-replies-text gl-mr-2"
|
2020-10-21 23:08:25 -04:00
|
|
|
category="tertiary"
|
|
|
|
variant="link"
|
2020-09-22 20:09:45 -04:00
|
|
|
data-qa-selector="expand_replies_button"
|
|
|
|
@click="toggle"
|
|
|
|
>
|
2018-11-08 02:58:45 -05:00
|
|
|
{{ replies.length }} {{ n__('reply', 'replies', replies.length) }}
|
2020-10-21 23:08:25 -04:00
|
|
|
</gl-button>
|
2018-11-08 02:58:45 -05:00
|
|
|
{{ __('Last reply by') }}
|
2022-05-25 11:08:05 -04:00
|
|
|
<a :href="lastReply.author.path" class="btn btn-link author-link gl-mx-2 gl-button">
|
2018-11-08 02:58:45 -05:00
|
|
|
{{ lastReply.author.name }}
|
|
|
|
</a>
|
2018-11-16 15:07:38 -05:00
|
|
|
<time-ago-tooltip :time="lastReply.created_at" tooltip-placement="bottom" />
|
2018-11-08 02:58:45 -05:00
|
|
|
</template>
|
2021-01-22 04:08:53 -05:00
|
|
|
<div
|
2019-01-03 09:57:51 -05:00
|
|
|
v-else
|
2021-01-22 04:08:53 -05:00
|
|
|
class="collapse-replies-btn js-collapse-replies gl-display-flex align-items-center"
|
2020-09-22 20:09:45 -04:00
|
|
|
data-qa-selector="collapse_replies_button"
|
2019-01-03 09:57:51 -05:00
|
|
|
@click="toggle"
|
|
|
|
>
|
2021-01-22 04:08:53 -05:00
|
|
|
<gl-icon :class="$options.ICON_CLASS" name="chevron-down" />
|
|
|
|
<span class="gl-cursor-pointer">{{ s__('Notes|Collapse replies') }}</span>
|
|
|
|
</div>
|
2018-11-08 02:58:45 -05:00
|
|
|
</li>
|
|
|
|
</template>
|