2018-11-08 02:58:45 -05:00
|
|
|
<script>
|
|
|
|
import _ from 'underscore';
|
|
|
|
import Icon from '~/vue_shared/components/icon.vue';
|
|
|
|
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: {
|
|
|
|
Icon,
|
|
|
|
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 || {});
|
|
|
|
|
|
|
|
return _.uniq(authors, author => author.username);
|
|
|
|
},
|
|
|
|
className() {
|
|
|
|
return this.collapsed ? 'collapsed' : 'expanded';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toggle() {
|
|
|
|
this.$emit('toggle');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2018-11-21 09:31:23 -05:00
|
|
|
<li :class="className" class="replies-toggle js-toggle-replies">
|
2018-11-08 02:58:45 -05:00
|
|
|
<template v-if="collapsed">
|
2018-11-16 15:07:38 -05:00
|
|
|
<icon 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"
|
|
|
|
:img-size="26"
|
|
|
|
:tooltip-text="author.name"
|
|
|
|
tooltip-placement="bottom"
|
|
|
|
/>
|
|
|
|
</div>
|
2019-01-03 09:57:51 -05:00
|
|
|
<button class="btn btn-link js-replies-text qa-expand-replies" type="button" @click="toggle">
|
2018-11-08 02:58:45 -05:00
|
|
|
{{ replies.length }} {{ n__('reply', 'replies', replies.length) }}
|
|
|
|
</button>
|
|
|
|
{{ __('Last reply by') }}
|
2018-11-16 15:07:38 -05:00
|
|
|
<a :href="lastReply.author.path" class="btn btn-link author-link">
|
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>
|
2019-01-03 09:57:51 -05:00
|
|
|
<span
|
|
|
|
v-else
|
|
|
|
class="collapse-replies-btn js-collapse-replies qa-collapse-replies"
|
|
|
|
@click="toggle"
|
|
|
|
>
|
2018-11-16 15:07:38 -05:00
|
|
|
<icon name="chevron-down" /> {{ s__('Notes|Collapse replies') }}
|
2018-11-08 02:58:45 -05:00
|
|
|
</span>
|
|
|
|
</li>
|
|
|
|
</template>
|