debian-mirror-gitlab/app/assets/javascripts/issuable/components/related_issuable_item.vue

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

238 lines
7.4 KiB
Vue
Raw Normal View History

2019-07-07 11:18:12 +05:30
<script>
2019-07-31 22:56:46 +05:30
import '~/commons/bootstrap';
2023-03-04 22:38:38 +05:30
import { GlIcon, GlLink, GlTooltip, GlTooltipDirective, GlButton } from '@gitlab/ui';
import SafeHtml from '~/vue_shared/directives/safe_html';
2020-10-24 23:57:45 +05:30
import IssueDueDate from '~/boards/components/issue_due_date.vue';
2023-04-23 21:23:45 +05:30
import { TYPENAME_WORK_ITEM } from '~/graphql_shared/constants';
2022-08-27 11:52:29 +05:30
import { convertToGraphQLId } from '~/graphql_shared/utils';
2022-10-11 01:57:18 +05:30
import { isMetaKey } from '~/lib/utils/common_utils';
2022-08-27 11:52:29 +05:30
import { setUrlParams, updateHistory } from '~/lib/utils/url_utility';
2021-03-11 19:13:27 +05:30
import { sprintf } from '~/locale';
2022-01-26 12:08:38 +05:30
import CiIcon from '~/vue_shared/components/ci_icon.vue';
2022-08-27 11:52:29 +05:30
import WorkItemDetailModal from '~/work_items/components/work_item_detail_modal.vue';
2022-01-26 12:08:38 +05:30
import relatedIssuableMixin from '../mixins/related_issuable_mixin';
2021-03-11 19:13:27 +05:30
import IssueAssignees from './issue_assignees.vue';
import IssueMilestone from './issue_milestone.vue';
2019-07-07 11:18:12 +05:30
export default {
components: {
IssueMilestone,
IssueAssignees,
CiIcon,
2020-05-24 23:13:21 +05:30
GlIcon,
2022-08-27 11:52:29 +05:30
GlLink,
2019-09-30 21:07:59 +05:30
GlTooltip,
2020-10-24 23:57:45 +05:30
IssueWeight: () => import('ee_component/boards/components/issue_card_weight.vue'),
IssueDueDate,
2020-11-24 15:15:51 +05:30
GlButton,
2022-08-27 11:52:29 +05:30
WorkItemDetailModal,
2019-07-07 11:18:12 +05:30
},
directives: {
GlTooltip: GlTooltipDirective,
2021-11-18 22:05:49 +05:30
SafeHtml,
2019-07-07 11:18:12 +05:30
},
mixins: [relatedIssuableMixin],
props: {
canReorder: {
type: Boolean,
required: false,
default: false,
},
2020-11-24 15:15:51 +05:30
isLocked: {
type: Boolean,
required: false,
default: false,
},
lockedMessage: {
type: String,
required: false,
default: '',
},
2022-08-27 11:52:29 +05:30
workItemType: {
type: String,
required: false,
default: '',
},
2019-07-07 11:18:12 +05:30
},
computed: {
stateTitle() {
return sprintf(
'<span class="bold">%{state}</span> %{timeInWords}<br/><span class="text-tertiary">%{timestamp}</span>',
{
state: this.stateText,
timeInWords: this.stateTimeInWords,
timestamp: this.stateTimestamp,
},
);
},
2020-05-24 23:13:21 +05:30
iconClasses() {
return `${this.iconClass} ic-${this.iconName}`;
},
2022-08-27 11:52:29 +05:30
workItemId() {
2023-04-23 21:23:45 +05:30
return convertToGraphQLId(TYPENAME_WORK_ITEM, this.idKey);
2022-08-27 11:52:29 +05:30
},
},
methods: {
handleTitleClick(event) {
if (this.workItemType === 'TASK') {
2022-10-11 01:57:18 +05:30
if (isMetaKey(event)) {
return;
}
2022-08-27 11:52:29 +05:30
event.preventDefault();
this.$refs.modal.show();
this.updateWorkItemIdUrlQuery(this.idKey);
}
},
handleWorkItemDeleted(workItemId) {
this.$emit('relatedIssueRemoveRequest', workItemId);
},
updateWorkItemIdUrlQuery(workItemId) {
updateHistory({
url: setUrlParams({ work_item_id: workItemId }),
replace: true,
});
},
2019-07-07 11:18:12 +05:30
},
};
</script>
<template>
<div
:class="{
'issuable-info-container': !canReorder,
'card-body': canReorder,
}"
2023-05-27 22:25:52 +05:30
class="item-body gl-display-flex gl-align-items-center gl-gap-3 gl-mx-n2"
2019-07-07 11:18:12 +05:30
>
2020-10-24 23:57:45 +05:30
<div
2023-05-27 22:25:52 +05:30
class="item-contents gl-display-flex gl-align-items-center gl-flex-wrap gl-flex-grow-1 gl-gap-2 gl-px-3 gl-py-2 py-xl-0 flex-xl-nowrap gl-min-h-7"
2020-10-24 23:57:45 +05:30
>
2019-09-30 21:07:59 +05:30
<!-- Title area: Status icon (XL) and title -->
2023-05-27 22:25:52 +05:30
<div class="item-title gl-display-flex gl-gap-3 gl-min-w-0">
<gl-icon
v-if="hasState"
ref="iconElementXL"
:class="iconClasses"
:name="iconName"
:title="stateTitle"
:aria-label="state"
/>
2019-09-30 21:07:59 +05:30
<gl-tooltip :target="() => $refs.iconElementXL">
2021-11-18 22:05:49 +05:30
<span v-safe-html="stateTitle"></span>
2019-09-30 21:07:59 +05:30
</gl-tooltip>
2020-05-24 23:13:21 +05:30
<gl-icon
2019-07-07 11:18:12 +05:30
v-if="confidential"
v-gl-tooltip
name="eye-slash"
:title="__('Confidential')"
2023-05-27 22:25:52 +05:30
class="confidential-icon"
2019-07-07 11:18:12 +05:30
:aria-label="__('Confidential')"
/>
2023-05-27 22:25:52 +05:30
<gl-link :href="computedPath" class="sortable-link" @click="handleTitleClick">
2022-08-27 11:52:29 +05:30
{{ title }}
</gl-link>
2019-07-07 11:18:12 +05:30
</div>
2019-09-30 21:07:59 +05:30
<!-- Info area: meta, path, and assignees -->
2023-05-27 22:25:52 +05:30
<div
class="item-info-area gl-display-flex gl-flex-grow-1 gl-flex-shrink-0 gl-gap-3 gl-ml-6 ml-xl-0"
>
2019-09-30 21:07:59 +05:30
<!-- Meta area: path and attributes -->
<!-- If there is no room beside the path, meta attributes are put ABOVE it (flex-wrap-reverse). -->
<!-- See design: https://gitlab-org.gitlab.io/gitlab-design/hosted/pedro/%2383-issue-mr-rows-cards-spec-previews/#artboard16 -->
2019-07-31 22:56:46 +05:30
<div
2023-05-27 22:25:52 +05:30
class="item-meta gl-display-flex gl-md-justify-content-space-between gl-gap-3 gl-flex-wrap-wrap-reverse"
2019-07-31 22:56:46 +05:30
>
2019-09-30 21:07:59 +05:30
<!-- Path area: status icon (<XL), path, issue # -->
<div
2023-05-27 22:25:52 +05:30
class="item-path-area item-path-id gl-display-flex gl-align-items-center gl-flex-wrap gl-gap-3"
2019-09-30 21:07:59 +05:30
>
2022-07-16 23:28:13 +05:30
<gl-tooltip :target="() => $refs.iconElement">
2021-11-18 22:05:49 +05:30
<span v-safe-html="stateTitle"></span>
2019-09-30 21:07:59 +05:30
</gl-tooltip>
2023-05-27 22:25:52 +05:30
<span
v-if="itemPath"
v-gl-tooltip
:title="itemPath"
class="path-id-text d-inline-block"
>{{ itemPath }}</span
>
2019-09-30 21:07:59 +05:30
<span>{{ pathIdSeparator }}{{ itemId }}</span>
</div>
<!-- Attributes area: CI, epic count, weight, milestone -->
<!-- They have a different order on large screen sizes -->
2023-05-27 22:25:52 +05:30
<div
class="item-attributes-area gl-display-flex gl-align-items-center gl-flex-wrap gl-gap-3"
>
2019-09-30 21:07:59 +05:30
<span v-if="hasPipeline" class="mr-ci-status order-md-last">
<a :href="pipelineStatus.details_path">
<ci-icon v-gl-tooltip :status="pipelineStatus" :title="pipelineStatusTooltip" />
</a>
</span>
<issue-milestone
v-if="hasMilestone"
:milestone="milestone"
2023-05-27 22:25:52 +05:30
class="item-milestone gl-font-sm gl-display-flex gl-align-items-center order-md-first"
2019-09-30 21:07:59 +05:30
/>
<!-- Flex order for slots is defined in the parent component: e.g. related_issues_block.vue -->
2020-10-24 23:57:45 +05:30
<span v-if="weight > 0" class="order-md-1">
<issue-weight
:weight="weight"
class="item-weight gl-display-flex gl-align-items-center"
tag-name="span"
/>
</span>
<span v-if="dueDate" class="order-md-1">
<issue-due-date
:date="dueDate"
2021-06-08 01:23:25 +05:30
:closed="Boolean(closedAt)"
2020-10-24 23:57:45 +05:30
tooltip-placement="top"
css-class="item-due-date gl-display-flex gl-align-items-center"
/>
</span>
2019-09-30 21:07:59 +05:30
<issue-assignees
v-if="hasAssignees"
:assignees="assignees"
2023-05-27 22:25:52 +05:30
class="item-assignees gl-display-flex gl-align-items-center gl-align-self-end gl-flex-shrink-0 order-md-2"
2019-09-30 21:07:59 +05:30
/>
</div>
2019-07-07 11:18:12 +05:30
</div>
</div>
</div>
2019-09-30 21:07:59 +05:30
2020-11-24 15:15:51 +05:30
<span
v-if="isLocked"
v-gl-tooltip
2023-05-27 22:25:52 +05:30
class="gl-display-inline-block gl-cursor-not-allowed"
2020-11-24 15:15:51 +05:30
:title="lockedMessage"
2022-08-27 11:52:29 +05:30
data-testid="lockIcon"
2020-11-24 15:15:51 +05:30
>
<gl-icon name="lock" />
</span>
<gl-button
v-else-if="canRemove"
2019-09-30 21:07:59 +05:30
v-gl-tooltip
2020-11-24 15:15:51 +05:30
icon="close"
category="tertiary"
2023-05-27 22:25:52 +05:30
size="small"
2019-07-07 11:18:12 +05:30
:disabled="removeDisabled"
2023-05-27 22:25:52 +05:30
class="js-issue-item-remove-button"
2019-12-21 20:55:43 +05:30
data-qa-selector="remove_related_issue_button"
2019-09-30 21:07:59 +05:30
:title="__('Remove')"
:aria-label="__('Remove')"
2019-07-07 11:18:12 +05:30
@click="onRemoveRequest"
2020-11-24 15:15:51 +05:30
/>
2022-08-27 11:52:29 +05:30
<work-item-detail-modal
ref="modal"
:work-item-id="workItemId"
@close="updateWorkItemIdUrlQuery"
@workItemDeleted="handleWorkItemDeleted"
/>
2019-07-07 11:18:12 +05:30
</div>
</template>