2018-06-26 08:29:06 -04:00
|
|
|
<script>
|
2021-02-14 13:09:20 -05:00
|
|
|
import { GlLabel, GlTooltipDirective, GlIcon } from '@gitlab/ui';
|
2020-03-12 11:09:39 -04:00
|
|
|
import { sortBy } from 'lodash';
|
2020-12-22 07:10:09 -05:00
|
|
|
import { mapActions, mapState } from 'vuex';
|
2021-02-25 01:10:51 -05:00
|
|
|
import boardCardInner from 'ee_else_ce/boards/mixins/board_card_inner';
|
2021-02-01 10:08:56 -05:00
|
|
|
import { isScopedLabel } from '~/lib/utils/common_utils';
|
|
|
|
import { updateHistory } from '~/lib/utils/url_utility';
|
2021-02-14 13:09:20 -05:00
|
|
|
import { sprintf, __, n__ } from '~/locale';
|
|
|
|
import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate.vue';
|
2018-10-30 16:28:31 -04:00
|
|
|
import UserAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue';
|
2020-12-14 16:09:47 -05:00
|
|
|
import { ListType } from '../constants';
|
2021-02-14 13:09:20 -05:00
|
|
|
import eventHub from '../eventhub';
|
2021-02-01 10:08:56 -05:00
|
|
|
import IssueDueDate from './issue_due_date.vue';
|
|
|
|
import IssueTimeEstimate from './issue_time_estimate.vue';
|
2018-06-26 08:29:06 -04:00
|
|
|
|
2018-10-30 16:28:31 -04:00
|
|
|
export default {
|
|
|
|
components: {
|
2020-03-09 05:07:45 -04:00
|
|
|
GlLabel,
|
2020-08-24 11:10:11 -04:00
|
|
|
GlIcon,
|
2018-11-07 12:20:17 -05:00
|
|
|
UserAvatarLink,
|
|
|
|
TooltipOnTruncate,
|
|
|
|
IssueDueDate,
|
|
|
|
IssueTimeEstimate,
|
2019-04-18 10:10:58 -04:00
|
|
|
IssueCardWeight: () => import('ee_component/boards/components/issue_card_weight.vue'),
|
2018-10-30 16:28:31 -04:00
|
|
|
},
|
|
|
|
directives: {
|
2018-11-07 12:20:17 -05:00
|
|
|
GlTooltip: GlTooltipDirective,
|
2018-10-30 16:28:31 -04:00
|
|
|
},
|
2021-02-25 01:10:51 -05:00
|
|
|
mixins: [boardCardInner],
|
2021-01-12 07:10:49 -05:00
|
|
|
inject: ['groupId', 'rootPath', 'scopedLabelsAvailable'],
|
2018-10-30 16:28:31 -04:00
|
|
|
props: {
|
2021-02-25 01:10:51 -05:00
|
|
|
item: {
|
2018-10-30 16:28:31 -04:00
|
|
|
type: Object,
|
|
|
|
required: true,
|
2018-06-26 08:29:06 -04:00
|
|
|
},
|
2018-10-30 16:28:31 -04:00
|
|
|
list: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
|
|
|
updateFilters: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2020-09-17 05:09:32 -04:00
|
|
|
},
|
2018-10-30 16:28:31 -04:00
|
|
|
data() {
|
|
|
|
return {
|
2018-11-07 12:20:17 -05:00
|
|
|
limitBeforeCounter: 2,
|
|
|
|
maxRender: 3,
|
2018-10-30 16:28:31 -04:00
|
|
|
maxCounter: 99,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
2021-02-25 01:10:51 -05:00
|
|
|
...mapState(['isShowingLabels', 'isEpicBoard']),
|
2020-12-22 07:10:09 -05:00
|
|
|
cappedAssignees() {
|
|
|
|
// e.g. maxRender is 4,
|
|
|
|
// Render up to all 4 assignees if there are only 4 assigness
|
|
|
|
// Otherwise render up to the limitBeforeCounter
|
2021-02-25 01:10:51 -05:00
|
|
|
if (this.item.assignees.length <= this.maxRender) {
|
|
|
|
return this.item.assignees.slice(0, this.maxRender);
|
2020-12-22 07:10:09 -05:00
|
|
|
}
|
|
|
|
|
2021-02-25 01:10:51 -05:00
|
|
|
return this.item.assignees.slice(0, this.limitBeforeCounter);
|
2020-12-22 07:10:09 -05:00
|
|
|
},
|
2018-10-30 16:28:31 -04:00
|
|
|
numberOverLimit() {
|
2021-02-25 01:10:51 -05:00
|
|
|
return this.item.assignees.length - this.limitBeforeCounter;
|
2018-10-30 16:28:31 -04:00
|
|
|
},
|
|
|
|
assigneeCounterTooltip() {
|
2018-11-07 12:20:17 -05:00
|
|
|
const { numberOverLimit, maxCounter } = this;
|
|
|
|
const count = numberOverLimit > maxCounter ? maxCounter : numberOverLimit;
|
|
|
|
return sprintf(__('%{count} more assignees'), { count });
|
2018-10-30 16:28:31 -04:00
|
|
|
},
|
|
|
|
assigneeCounterLabel() {
|
|
|
|
if (this.numberOverLimit > this.maxCounter) {
|
|
|
|
return `${this.maxCounter}+`;
|
|
|
|
}
|
2018-06-26 08:29:06 -04:00
|
|
|
|
2018-10-30 16:28:31 -04:00
|
|
|
return `+${this.numberOverLimit}`;
|
|
|
|
},
|
|
|
|
shouldRenderCounter() {
|
2021-02-25 01:10:51 -05:00
|
|
|
if (this.item.assignees.length <= this.maxRender) {
|
2018-06-26 08:29:06 -04:00
|
|
|
return false;
|
2018-10-30 16:28:31 -04:00
|
|
|
}
|
2018-06-26 08:29:06 -04:00
|
|
|
|
2021-02-25 01:10:51 -05:00
|
|
|
return this.item.assignees.length > this.numberOverLimit;
|
2018-10-30 16:28:31 -04:00
|
|
|
},
|
2021-02-25 01:10:51 -05:00
|
|
|
itemPrefix() {
|
|
|
|
return this.isEpicBoard ? '&' : '#';
|
|
|
|
},
|
|
|
|
|
|
|
|
itemId() {
|
|
|
|
if (this.item.iid) {
|
|
|
|
return `${this.itemPrefix}${this.item.iid}`;
|
2018-10-30 16:28:31 -04:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
showLabelFooter() {
|
2021-02-25 01:10:51 -05:00
|
|
|
return this.isShowingLabels && this.item.labels.find(this.showLabel);
|
2018-10-30 16:28:31 -04:00
|
|
|
},
|
2021-02-25 01:10:51 -05:00
|
|
|
itemReferencePath() {
|
|
|
|
const { referencePath } = this.item;
|
|
|
|
return referencePath.split(this.itemPrefix)[0];
|
2018-11-07 12:20:17 -05:00
|
|
|
},
|
2019-04-03 08:22:11 -04:00
|
|
|
orderedLabels() {
|
2021-02-25 01:10:51 -05:00
|
|
|
return sortBy(this.item.labels.filter(this.isNonListLabel), 'title');
|
2019-04-03 08:22:11 -04:00
|
|
|
},
|
2020-11-06 04:08:56 -05:00
|
|
|
blockedLabel() {
|
2021-02-25 01:10:51 -05:00
|
|
|
if (this.item.blockedByCount) {
|
|
|
|
return n__(`Blocked by %d issue`, `Blocked by %d issues`, this.item.blockedByCount);
|
2020-11-06 04:08:56 -05:00
|
|
|
}
|
|
|
|
return __('Blocked issue');
|
|
|
|
},
|
2018-10-30 16:28:31 -04:00
|
|
|
},
|
|
|
|
methods: {
|
2020-12-22 07:10:09 -05:00
|
|
|
...mapActions(['performSearch']),
|
2018-10-30 16:28:31 -04:00
|
|
|
isIndexLessThanlimit(index) {
|
|
|
|
return index < this.limitBeforeCounter;
|
|
|
|
},
|
|
|
|
assigneeUrl(assignee) {
|
2018-11-07 12:20:17 -05:00
|
|
|
if (!assignee) return '';
|
2018-10-30 16:28:31 -04:00
|
|
|
return `${this.rootPath}${assignee.username}`;
|
|
|
|
},
|
|
|
|
avatarUrlTitle(assignee) {
|
2019-06-28 15:28:02 -04:00
|
|
|
return sprintf(__(`Avatar for %{assigneeName}`), { assigneeName: assignee.name });
|
2018-10-30 16:28:31 -04:00
|
|
|
},
|
2020-12-22 07:10:09 -05:00
|
|
|
avatarUrl(assignee) {
|
|
|
|
return assignee.avatarUrl || assignee.avatar || gon.default_avatar_url;
|
|
|
|
},
|
2018-10-30 16:28:31 -04:00
|
|
|
showLabel(label) {
|
|
|
|
if (!label.id) return false;
|
|
|
|
return true;
|
|
|
|
},
|
2019-10-10 20:06:24 -04:00
|
|
|
isNonListLabel(label) {
|
2020-12-14 16:09:47 -05:00
|
|
|
return (
|
|
|
|
label.id &&
|
|
|
|
!(
|
|
|
|
(this.list.type || this.list.listType) === ListType.label &&
|
|
|
|
this.list.title === label.title
|
|
|
|
)
|
|
|
|
);
|
2019-10-10 20:06:24 -04:00
|
|
|
},
|
2018-11-07 12:20:17 -05:00
|
|
|
filterByLabel(label) {
|
|
|
|
if (!this.updateFilters) return;
|
2020-12-22 07:10:09 -05:00
|
|
|
const filterPath = window.location.search ? `${window.location.search}&` : '?';
|
|
|
|
const filter = `label_name[]=${encodeURIComponent(label.title)}`;
|
2018-11-07 12:20:17 -05:00
|
|
|
|
2020-12-22 07:10:09 -05:00
|
|
|
if (!filterPath.includes(filter)) {
|
|
|
|
updateHistory({
|
|
|
|
url: `${filterPath}${filter}`,
|
|
|
|
});
|
|
|
|
this.performSearch();
|
|
|
|
eventHub.$emit('updateTokens');
|
|
|
|
}
|
2018-10-30 16:28:31 -04:00
|
|
|
},
|
2019-04-15 05:58:30 -04:00
|
|
|
showScopedLabel(label) {
|
2020-12-22 07:10:09 -05:00
|
|
|
return this.scopedLabelsAvailable && isScopedLabel(label);
|
2019-04-15 05:58:30 -04:00
|
|
|
},
|
2018-10-30 16:28:31 -04:00
|
|
|
},
|
|
|
|
};
|
2018-06-26 08:29:06 -04:00
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<div>
|
2020-10-26 11:08:40 -04:00
|
|
|
<div class="gl-display-flex" dir="auto">
|
2020-05-25 02:08:38 -04:00
|
|
|
<h4 class="board-card-title gl-mb-0 gl-mt-0">
|
2020-08-24 11:10:11 -04:00
|
|
|
<gl-icon
|
2021-02-25 01:10:51 -05:00
|
|
|
v-if="item.blocked"
|
2020-02-10 22:09:13 -05:00
|
|
|
v-gl-tooltip
|
|
|
|
name="issue-block"
|
2020-11-06 04:08:56 -05:00
|
|
|
:title="blockedLabel"
|
2020-06-24 14:09:03 -04:00
|
|
|
class="issue-blocked-icon gl-mr-2"
|
2020-11-06 04:08:56 -05:00
|
|
|
:aria-label="blockedLabel"
|
|
|
|
data-testid="issue-blocked-icon"
|
2020-02-10 22:09:13 -05:00
|
|
|
/>
|
2020-08-24 11:10:11 -04:00
|
|
|
<gl-icon
|
2021-02-25 01:10:51 -05:00
|
|
|
v-if="item.confidential"
|
2018-11-07 12:20:17 -05:00
|
|
|
v-gl-tooltip
|
2018-10-15 14:35:00 -04:00
|
|
|
name="eye-slash"
|
2018-11-07 12:20:17 -05:00
|
|
|
:title="__('Confidential')"
|
2020-06-24 14:09:03 -04:00
|
|
|
class="confidential-icon gl-mr-2"
|
2018-11-07 12:20:17 -05:00
|
|
|
:aria-label="__('Confidential')"
|
2019-06-28 15:28:02 -04:00
|
|
|
/>
|
2020-11-24 01:09:49 -05:00
|
|
|
<a
|
2021-02-25 01:10:51 -05:00
|
|
|
:href="item.path || item.webUrl || ''"
|
|
|
|
:title="item.title"
|
2020-11-24 01:09:49 -05:00
|
|
|
class="js-no-trigger"
|
|
|
|
@mousemove.stop
|
2021-02-25 01:10:51 -05:00
|
|
|
>{{ item.title }}</a
|
2020-11-24 01:09:49 -05:00
|
|
|
>
|
2018-11-07 12:20:17 -05:00
|
|
|
</h4>
|
|
|
|
</div>
|
2020-10-26 11:08:40 -04:00
|
|
|
<div v-if="showLabelFooter" class="board-card-labels gl-mt-2 gl-display-flex gl-flex-wrap">
|
2019-10-10 20:06:24 -04:00
|
|
|
<template v-for="label in orderedLabels">
|
2020-03-09 05:07:45 -04:00
|
|
|
<gl-label
|
2019-04-15 05:58:30 -04:00
|
|
|
:key="label.id"
|
2020-03-09 05:07:45 -04:00
|
|
|
:background-color="label.color"
|
|
|
|
:title="label.title"
|
|
|
|
:description="label.description"
|
|
|
|
size="sm"
|
|
|
|
:scoped="showScopedLabel(label)"
|
2019-04-15 05:58:30 -04:00
|
|
|
@click="filterByLabel(label)"
|
2020-03-09 05:07:45 -04:00
|
|
|
/>
|
2019-04-15 05:58:30 -04:00
|
|
|
</template>
|
2018-11-07 12:20:17 -05:00
|
|
|
</div>
|
2020-10-26 11:08:40 -04:00
|
|
|
<div
|
|
|
|
class="board-card-footer gl-display-flex gl-justify-content-space-between gl-align-items-flex-end"
|
|
|
|
>
|
2018-11-16 15:07:38 -05:00
|
|
|
<div
|
2020-10-26 11:08:40 -04:00
|
|
|
class="gl-display-flex align-items-start flex-wrap-reverse board-card-number-container gl-overflow-hidden js-board-card-number-container"
|
2018-11-16 15:07:38 -05:00
|
|
|
>
|
2018-06-26 08:29:06 -04:00
|
|
|
<span
|
2021-02-25 01:10:51 -05:00
|
|
|
v-if="item.referencePath"
|
2020-10-26 11:08:40 -04:00
|
|
|
class="board-card-number gl-overflow-hidden gl-display-flex gl-mr-3 gl-mt-3"
|
2021-02-25 01:10:51 -05:00
|
|
|
:class="{ 'gl-font-base': isEpicBoard }"
|
2018-06-26 08:29:06 -04:00
|
|
|
>
|
2018-11-07 12:20:17 -05:00
|
|
|
<tooltip-on-truncate
|
2021-02-25 01:10:51 -05:00
|
|
|
v-if="itemReferencePath"
|
|
|
|
:title="itemReferencePath"
|
2018-11-07 12:20:17 -05:00
|
|
|
placement="bottom"
|
2021-02-25 01:10:51 -05:00
|
|
|
class="board-item-path gl-text-truncate gl-font-weight-bold"
|
|
|
|
>{{ itemReferencePath }}</tooltip-on-truncate
|
2019-06-28 15:28:02 -04:00
|
|
|
>
|
2021-02-25 01:10:51 -05:00
|
|
|
{{ itemId }}
|
2018-06-26 08:29:06 -04:00
|
|
|
</span>
|
2020-10-26 11:08:40 -04:00
|
|
|
<span class="board-info-items gl-mt-3 gl-display-inline-block">
|
2020-11-24 01:09:49 -05:00
|
|
|
<issue-due-date
|
2021-02-25 01:10:51 -05:00
|
|
|
v-if="item.dueDate"
|
|
|
|
:date="item.dueDate"
|
|
|
|
:closed="item.closed || Boolean(item.closedAt)"
|
2020-11-24 01:09:49 -05:00
|
|
|
/>
|
2021-02-25 01:10:51 -05:00
|
|
|
<issue-time-estimate v-if="item.timeEstimate" :estimate="item.timeEstimate" />
|
2019-06-28 15:28:02 -04:00
|
|
|
<issue-card-weight
|
2021-02-25 01:10:51 -05:00
|
|
|
v-if="validIssueWeight(item)"
|
|
|
|
:weight="item.weight"
|
|
|
|
@click="filterByWeight(item.weight)"
|
2018-11-07 12:20:17 -05:00
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
</div>
|
2020-10-26 11:08:40 -04:00
|
|
|
<div class="board-card-assignee gl-display-flex">
|
2018-06-26 08:29:06 -04:00
|
|
|
<user-avatar-link
|
2020-12-22 07:10:09 -05:00
|
|
|
v-for="assignee in cappedAssignees"
|
2018-06-26 08:29:06 -04:00
|
|
|
:key="assignee.id"
|
|
|
|
:link-href="assigneeUrl(assignee)"
|
|
|
|
:img-alt="avatarUrlTitle(assignee)"
|
2020-12-22 07:10:09 -05:00
|
|
|
:img-src="avatarUrl(assignee)"
|
2018-11-07 12:20:17 -05:00
|
|
|
:img-size="24"
|
2018-06-26 08:29:06 -04:00
|
|
|
class="js-no-trigger"
|
|
|
|
tooltip-placement="bottom"
|
2018-11-07 12:20:17 -05:00
|
|
|
>
|
|
|
|
<span class="js-assignee-tooltip">
|
2020-10-26 11:08:40 -04:00
|
|
|
<span class="gl-font-weight-bold gl-display-block">{{ __('Assignee') }}</span>
|
2019-06-28 15:28:02 -04:00
|
|
|
{{ assignee.name }}
|
2018-11-07 12:20:17 -05:00
|
|
|
<span class="text-white-50">@{{ assignee.username }}</span>
|
|
|
|
</span>
|
|
|
|
</user-avatar-link>
|
2018-06-26 08:29:06 -04:00
|
|
|
<span
|
|
|
|
v-if="shouldRenderCounter"
|
2018-11-07 12:20:17 -05:00
|
|
|
v-gl-tooltip
|
2018-06-26 08:29:06 -04:00
|
|
|
:title="assigneeCounterTooltip"
|
2018-06-27 10:10:50 -04:00
|
|
|
class="avatar-counter"
|
2018-11-07 12:20:17 -05:00
|
|
|
data-placement="bottom"
|
2019-06-28 15:28:02 -04:00
|
|
|
>{{ assigneeCounterLabel }}</span
|
2018-06-26 08:29:06 -04:00
|
|
|
>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|