debian-mirror-gitlab/app/assets/javascripts/sidebar/components/participants/participants.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

138 lines
3.6 KiB
Vue
Raw Normal View History

2018-03-17 18:26:18 +05:30
<script>
2022-06-21 17:19:12 +05:30
import { GlButton, GlIcon, GlLoadingIcon, GlTooltipDirective } from '@gitlab/ui';
2018-12-13 13:39:08 +05:30
import { __, n__, sprintf } from '~/locale';
import userAvatarImage from '~/vue_shared/components/user_avatar/user_avatar_image.vue';
2018-03-17 18:26:18 +05:30
2018-12-13 13:39:08 +05:30
export default {
directives: {
2021-01-03 14:25:43 +05:30
GlTooltip: GlTooltipDirective,
2018-12-13 13:39:08 +05:30
},
components: {
2022-06-21 17:19:12 +05:30
GlButton,
2020-11-24 15:15:51 +05:30
GlIcon,
2018-12-13 13:39:08 +05:30
GlLoadingIcon,
2022-06-21 17:19:12 +05:30
userAvatarImage,
2018-12-13 13:39:08 +05:30
},
props: {
loading: {
type: Boolean,
required: false,
default: false,
2018-10-15 14:42:47 +05:30
},
2018-12-13 13:39:08 +05:30
participants: {
type: Array,
required: false,
default: () => [],
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
numberOfLessParticipants: {
type: Number,
required: false,
default: 7,
2018-03-17 18:26:18 +05:30
},
2020-03-13 15:44:24 +05:30
showParticipantLabel: {
type: Boolean,
required: false,
default: true,
},
2021-10-27 15:23:28 +05:30
lazy: {
type: Boolean,
required: false,
default: true,
},
2018-12-13 13:39:08 +05:30
},
data() {
return {
isShowingMoreParticipants: false,
};
},
computed: {
lessParticipants() {
return this.participants.slice(0, this.numberOfLessParticipants);
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
visibleParticipants() {
return this.isShowingMoreParticipants ? this.participants : this.lessParticipants;
},
hasMoreParticipants() {
return this.participants.length > this.numberOfLessParticipants;
},
toggleLabel() {
let label = '';
if (this.isShowingMoreParticipants) {
label = __('- show less');
} else {
label = sprintf(__('+ %{moreCount} more'), {
moreCount: this.participants.length - this.numberOfLessParticipants,
});
}
2018-03-17 18:26:18 +05:30
2018-12-13 13:39:08 +05:30
return label;
},
participantLabel() {
return sprintf(
n__('%{count} participant', '%{count} participants', this.participants.length),
{ count: this.loading ? '' : this.participantCount },
);
},
participantCount() {
return this.participants.length;
},
},
methods: {
toggleMoreParticipants() {
this.isShowingMoreParticipants = !this.isShowingMoreParticipants;
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
onClickCollapsedIcon() {
this.$emit('toggleSidebar');
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
},
};
2018-03-17 18:26:18 +05:30
</script>
<template>
<div>
2018-10-15 14:42:47 +05:30
<div
2020-03-13 15:44:24 +05:30
v-if="showParticipantLabel"
2021-01-03 14:25:43 +05:30
v-gl-tooltip.left.viewport
2018-11-08 19:23:39 +05:30
:title="participantLabel"
class="sidebar-collapsed-icon"
2018-10-15 14:42:47 +05:30
@click="onClickCollapsedIcon"
>
2020-11-24 15:15:51 +05:30
<gl-icon name="users" />
2021-09-30 23:02:18 +05:30
<gl-loading-icon v-if="loading" size="sm" />
2020-05-24 23:13:21 +05:30
<span v-else data-testid="collapsed-count"> {{ participantCount }} </span>
2018-03-17 18:26:18 +05:30
</div>
2021-10-27 15:23:28 +05:30
<div v-if="showParticipantLabel" class="title hide-collapsed gl-mb-2 gl-line-height-20">
2021-09-30 23:02:18 +05:30
<gl-loading-icon v-if="loading" size="sm" :inline="true" />
2018-03-17 18:26:18 +05:30
{{ participantLabel }}
</div>
2021-11-18 22:05:49 +05:30
<div class="hide-collapsed gl-display-flex gl-flex-wrap">
2018-03-17 18:26:18 +05:30
<div
v-for="participant in visibleParticipants"
:key="participant.id"
2021-11-18 22:05:49 +05:30
class="participants-author gl-display-inline-block gl-pr-3 gl-pb-3"
2018-03-17 18:26:18 +05:30
>
2021-06-08 01:23:25 +05:30
<a :href="participant.web_url || participant.webUrl" class="author-link">
2018-03-17 18:26:18 +05:30
<user-avatar-image
2021-10-27 15:23:28 +05:30
:lazy="lazy"
2021-06-08 01:23:25 +05:30
:img-src="participant.avatar_url || participant.avatarUrl"
2018-03-17 18:26:18 +05:30
:size="24"
:tooltip-text="participant.name"
2021-10-27 15:23:28 +05:30
:img-alt="participant.name"
2018-11-08 19:23:39 +05:30
css-classes="avatar-inline"
2018-03-17 18:26:18 +05:30
tooltip-placement="bottom"
/>
</a>
</div>
</div>
2019-02-15 15:39:39 +05:30
<div v-if="hasMoreParticipants" class="participants-more hide-collapsed">
2022-06-21 17:19:12 +05:30
<gl-button
variant="link"
button-text-classes="gl-text-secondary"
data-testid="more-participants"
@click="toggleMoreParticipants"
>{{ toggleLabel }}</gl-button
>
2018-03-17 18:26:18 +05:30
</div>
</div>
</template>