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