2019-02-15 15:39:39 +05:30
|
|
|
<script>
|
|
|
|
import { GlTooltipDirective } from '@gitlab/ui';
|
|
|
|
import { __, sprintf } from '~/locale';
|
|
|
|
import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
UserAvatarLink,
|
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
GlTooltip: GlTooltipDirective,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
assignees: {
|
|
|
|
type: Array,
|
|
|
|
required: true,
|
|
|
|
},
|
2019-12-26 22:10:19 +05:30
|
|
|
iconSize: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
|
|
|
default: 24,
|
|
|
|
},
|
|
|
|
imgCssClasses: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
maxVisible: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
|
|
|
default: 3,
|
|
|
|
},
|
2019-02-15 15:39:39 +05:30
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
maxAssignees: 99,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
assigneesToShow() {
|
2019-12-26 22:10:19 +05:30
|
|
|
const numShownAssignees = this.assignees.length - this.numHiddenAssignees;
|
|
|
|
return this.assignees.slice(0, numShownAssignees);
|
2019-02-15 15:39:39 +05:30
|
|
|
},
|
|
|
|
assigneesCounterTooltip() {
|
2019-12-26 22:10:19 +05:30
|
|
|
return sprintf(__('%{count} more assignees'), { count: this.numHiddenAssignees });
|
2019-02-15 15:39:39 +05:30
|
|
|
},
|
2019-12-26 22:10:19 +05:30
|
|
|
numHiddenAssignees() {
|
|
|
|
if (this.assignees.length > this.maxVisible) {
|
|
|
|
return this.assignees.length - this.maxVisible + 1;
|
2019-02-15 15:39:39 +05:30
|
|
|
}
|
2019-12-26 22:10:19 +05:30
|
|
|
return 0;
|
2019-02-15 15:39:39 +05:30
|
|
|
},
|
|
|
|
assigneeCounterLabel() {
|
2019-12-26 22:10:19 +05:30
|
|
|
if (this.numHiddenAssignees > this.maxAssignees) {
|
2019-02-15 15:39:39 +05:30
|
|
|
return `${this.maxAssignees}+`;
|
|
|
|
}
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
return `+${this.numHiddenAssignees}`;
|
2019-02-15 15:39:39 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
avatarUrlTitle(assignee) {
|
2021-09-04 01:27:46 +05:30
|
|
|
return sprintf(__('Assigned to %{assigneeName}'), {
|
2019-02-15 15:39:39 +05:30
|
|
|
assigneeName: assignee.name,
|
|
|
|
});
|
|
|
|
},
|
2019-09-04 21:01:54 +05:30
|
|
|
// This method is for backward compat
|
|
|
|
// since Graph query would return camelCase
|
|
|
|
// props while Rails would return snake_case
|
|
|
|
webUrl(assignee) {
|
|
|
|
return assignee.web_url || assignee.webUrl;
|
|
|
|
},
|
|
|
|
avatarUrl(assignee) {
|
|
|
|
return assignee.avatar_url || assignee.avatarUrl;
|
|
|
|
},
|
2019-02-15 15:39:39 +05:30
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
2021-11-18 22:05:49 +05:30
|
|
|
<div>
|
2019-02-15 15:39:39 +05:30
|
|
|
<user-avatar-link
|
|
|
|
v-for="assignee in assigneesToShow"
|
|
|
|
:key="assignee.id"
|
2019-09-04 21:01:54 +05:30
|
|
|
:link-href="webUrl(assignee)"
|
2019-02-15 15:39:39 +05:30
|
|
|
:img-alt="avatarUrlTitle(assignee)"
|
2019-12-26 22:10:19 +05:30
|
|
|
:img-css-classes="imgCssClasses"
|
2019-09-04 21:01:54 +05:30
|
|
|
:img-src="avatarUrl(assignee)"
|
2019-12-26 22:10:19 +05:30
|
|
|
:img-size="iconSize"
|
2020-10-24 23:57:45 +05:30
|
|
|
class="js-no-trigger author-link"
|
2019-02-15 15:39:39 +05:30
|
|
|
tooltip-placement="bottom"
|
2020-10-24 23:57:45 +05:30
|
|
|
data-qa-selector="assignee_link"
|
2019-02-15 15:39:39 +05:30
|
|
|
>
|
|
|
|
<span class="js-assignee-tooltip">
|
|
|
|
<span class="bold d-block">{{ __('Assignee') }}</span> {{ assignee.name }}
|
2020-10-24 23:57:45 +05:30
|
|
|
<span v-if="assignee.username" class="text-white-50">@{{ assignee.username }}</span>
|
2019-02-15 15:39:39 +05:30
|
|
|
</span>
|
|
|
|
</user-avatar-link>
|
|
|
|
<span
|
2019-12-26 22:10:19 +05:30
|
|
|
v-if="numHiddenAssignees > 0"
|
2021-11-18 22:05:49 +05:30
|
|
|
v-gl-tooltip.bottom
|
2019-02-15 15:39:39 +05:30
|
|
|
:title="assigneesCounterTooltip"
|
|
|
|
class="avatar-counter"
|
2020-10-24 23:57:45 +05:30
|
|
|
data-qa-selector="avatar_counter_content"
|
2019-02-15 15:39:39 +05:30
|
|
|
>{{ assigneeCounterLabel }}</span
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
</template>
|