2018-06-26 08:29:06 -04:00
|
|
|
<script>
|
2021-06-21 11:07:30 -04:00
|
|
|
import { GlLabel, GlTooltip, GlTooltipDirective, GlIcon, GlLoadingIcon } from '@gitlab/ui';
|
2020-03-12 11:09:39 -04:00
|
|
|
import { sortBy } from 'lodash';
|
2021-03-05 04:09:07 -05:00
|
|
|
import { mapActions, mapGetters, 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-03-16 02:09:57 -04:00
|
|
|
import BoardBlockedIcon from './board_blocked_icon.vue';
|
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: {
|
2021-06-21 11:07:30 -04:00
|
|
|
GlTooltip,
|
2020-03-09 05:07:45 -04:00
|
|
|
GlLabel,
|
2021-05-21 02:11:06 -04:00
|
|
|
GlLoadingIcon,
|
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'),
|
2021-03-16 02:09:57 -04:00
|
|
|
BoardBlockedIcon,
|
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-03-10 04:09:29 -05:00
|
|
|
inject: ['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-06-21 11:07:30 -04:00
|
|
|
...mapState(['isShowingLabels', 'issuableType', 'allowSubEpics']),
|
2021-03-05 04:09:07 -05:00
|
|
|
...mapGetters(['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;
|
|
|
|
},
|
2021-06-21 11:07:30 -04:00
|
|
|
shouldRenderEpicCountables() {
|
|
|
|
return this.isEpicBoard && this.item.hasIssues;
|
|
|
|
},
|
2018-10-30 16:28:31 -04:00
|
|
|
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');
|
|
|
|
},
|
2021-06-21 11:07:30 -04:00
|
|
|
totalEpicsCount() {
|
|
|
|
return this.item.descendantCounts.openedEpics + this.item.descendantCounts.closedEpics;
|
|
|
|
},
|
|
|
|
totalIssuesCount() {
|
|
|
|
return this.item.descendantCounts.openedIssues + this.item.descendantCounts.closedIssues;
|
|
|
|
},
|
|
|
|
totalWeight() {
|
|
|
|
return (
|
|
|
|
this.item.descendantWeightSum.openedIssues + this.item.descendantWeightSum.closedIssues
|
|
|
|
);
|
|
|
|
},
|
2018-10-30 16:28:31 -04:00
|
|
|
},
|
|
|
|
methods: {
|
2021-03-16 02:09:57 -04:00
|
|
|
...mapActions(['performSearch', 'setError']),
|
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">
|
2021-03-16 02:09:57 -04:00
|
|
|
<board-blocked-icon
|
2021-02-25 01:10:51 -05:00
|
|
|
v-if="item.blocked"
|
2021-03-16 02:09:57 -04:00
|
|
|
:item="item"
|
|
|
|
:unique-id="`${item.id}${list.id}`"
|
|
|
|
:issuable-type="issuableType"
|
|
|
|
@blocking-issuables-error="setError"
|
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
|
|
|
/>
|
2021-05-21 02:11:06 -04:00
|
|
|
<a
|
|
|
|
:href="item.path || item.webUrl || ''"
|
|
|
|
:title="item.title"
|
|
|
|
:class="{ 'gl-text-gray-400!': item.isLoading }"
|
|
|
|
@mousemove.stop
|
|
|
|
>{{ item.title }}</a
|
|
|
|
>
|
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"
|
2021-04-29 11:10:07 -04:00
|
|
|
class="js-no-trigger"
|
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
|
|
|
>
|
2021-05-21 02:11:06 -04:00
|
|
|
<gl-loading-icon v-if="item.isLoading" size="md" class="mt-3" />
|
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">
|
2021-06-21 11:07:30 -04:00
|
|
|
<span v-if="shouldRenderEpicCountables" data-testid="epic-countables">
|
|
|
|
<gl-tooltip :target="() => $refs.countBadge" data-testid="epic-countables-tooltip">
|
|
|
|
<p v-if="allowSubEpics" class="gl-font-weight-bold gl-m-0">
|
|
|
|
{{ __('Epics') }} •
|
|
|
|
<span class="gl-font-weight-normal"
|
|
|
|
>{{
|
|
|
|
sprintf(__('%{openedEpics} open, %{closedEpics} closed'), {
|
|
|
|
openedEpics: item.descendantCounts.openedEpics,
|
|
|
|
closedEpics: item.descendantCounts.closedEpics,
|
|
|
|
})
|
|
|
|
}}
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
<p class="gl-font-weight-bold gl-m-0">
|
|
|
|
{{ __('Issues') }} •
|
|
|
|
<span class="gl-font-weight-normal"
|
|
|
|
>{{
|
|
|
|
sprintf(__('%{openedIssues} open, %{closedIssues} closed'), {
|
|
|
|
openedIssues: item.descendantCounts.openedIssues,
|
|
|
|
closedIssues: item.descendantCounts.closedIssues,
|
|
|
|
})
|
|
|
|
}}
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
<p class="gl-font-weight-bold gl-m-0">
|
|
|
|
{{ __('Weight') }} •
|
|
|
|
<span class="gl-font-weight-normal" data-testid="epic-countables-total-weight"
|
|
|
|
>{{
|
|
|
|
sprintf(__('%{closedWeight} complete, %{openWeight} incomplete'), {
|
|
|
|
openWeight: item.descendantWeightSum.openedIssues,
|
|
|
|
closedWeight: item.descendantWeightSum.closedIssues,
|
|
|
|
})
|
|
|
|
}}
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
</gl-tooltip>
|
|
|
|
|
|
|
|
<span ref="countBadge" class="issue-count-badge board-card-info">
|
|
|
|
<span v-if="allowSubEpics" class="gl-mr-3">
|
|
|
|
<gl-icon name="epic" />
|
|
|
|
{{ totalEpicsCount }}
|
|
|
|
</span>
|
|
|
|
<span class="gl-mr-3" data-testid="epic-countables-counts-issues">
|
|
|
|
<gl-icon name="issues" />
|
|
|
|
{{ totalIssuesCount }}
|
|
|
|
</span>
|
|
|
|
<span class="gl-mr-3" data-testid="epic-countables-weight-issues">
|
|
|
|
<gl-icon name="weight" />
|
|
|
|
{{ totalWeight }}
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
<span v-if="!isEpicBoard">
|
|
|
|
<issue-due-date
|
|
|
|
v-if="item.dueDate"
|
|
|
|
:date="item.dueDate"
|
|
|
|
:closed="item.closed || Boolean(item.closedAt)"
|
|
|
|
/>
|
|
|
|
<issue-time-estimate v-if="item.timeEstimate" :estimate="item.timeEstimate" />
|
|
|
|
<issue-card-weight
|
|
|
|
v-if="validIssueWeight(item)"
|
|
|
|
:weight="item.weight"
|
|
|
|
@click="filterByWeight(item.weight)"
|
|
|
|
/>
|
|
|
|
</span>
|
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>
|