2019-07-07 11:18:12 +05:30
|
|
|
<script>
|
2020-04-22 19:07:51 +05:30
|
|
|
/* eslint-disable @gitlab/vue-require-i18n-strings */
|
2020-11-24 15:15:51 +05:30
|
|
|
import { GlPopover, GlDeprecatedSkeletonLoading as GlSkeletonLoading } from '@gitlab/ui';
|
2022-06-21 17:19:12 +05:30
|
|
|
import CiIcon from '~/vue_shared/components/ci_icon.vue';
|
|
|
|
import timeagoMixin from '~/vue_shared/mixins/timeago';
|
2019-07-07 11:18:12 +05:30
|
|
|
import { mrStates, humanMRStates } from '../constants';
|
2021-03-11 19:13:27 +05:30
|
|
|
import query from '../queries/merge_request.query.graphql';
|
2019-07-07 11:18:12 +05:30
|
|
|
|
|
|
|
export default {
|
2019-10-12 21:52:04 +05:30
|
|
|
// name: 'MRPopover' is a false positive: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/25
|
2020-04-22 19:07:51 +05:30
|
|
|
name: 'MRPopover', // eslint-disable-line @gitlab/require-i18n-strings
|
2019-07-07 11:18:12 +05:30
|
|
|
components: {
|
|
|
|
GlPopover,
|
|
|
|
GlSkeletonLoading,
|
|
|
|
CiIcon,
|
|
|
|
},
|
|
|
|
mixins: [timeagoMixin],
|
|
|
|
props: {
|
|
|
|
target: {
|
|
|
|
type: HTMLAnchorElement,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
projectPath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
mergeRequestIID: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
mergeRequestTitle: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
mergeRequest: {},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
detailedStatus() {
|
|
|
|
return this.mergeRequest.headPipeline && this.mergeRequest.headPipeline.detailedStatus;
|
|
|
|
},
|
|
|
|
formattedTime() {
|
2020-01-01 13:55:28 +05:30
|
|
|
return this.timeFormatted(this.mergeRequest.createdAt);
|
2019-07-07 11:18:12 +05:30
|
|
|
},
|
|
|
|
statusBoxClass() {
|
|
|
|
switch (this.mergeRequest.state) {
|
|
|
|
case mrStates.merged:
|
|
|
|
return 'status-box-mr-merged';
|
|
|
|
case mrStates.closed:
|
|
|
|
return 'status-box-closed';
|
|
|
|
default:
|
|
|
|
return 'status-box-open';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
stateHumanName() {
|
|
|
|
switch (this.mergeRequest.state) {
|
|
|
|
case mrStates.merged:
|
|
|
|
return humanMRStates.merged;
|
|
|
|
case mrStates.closed:
|
|
|
|
return humanMRStates.closed;
|
|
|
|
default:
|
|
|
|
return humanMRStates.open;
|
|
|
|
}
|
|
|
|
},
|
2022-01-26 12:08:38 +05:30
|
|
|
title() {
|
|
|
|
return this.mergeRequest?.title || this.mergeRequestTitle;
|
|
|
|
},
|
2019-07-07 11:18:12 +05:30
|
|
|
showDetails() {
|
|
|
|
return Object.keys(this.mergeRequest).length > 0;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
apollo: {
|
|
|
|
mergeRequest: {
|
|
|
|
query,
|
2021-03-08 18:12:59 +05:30
|
|
|
update: (data) => data.project.mergeRequest,
|
2019-07-07 11:18:12 +05:30
|
|
|
variables() {
|
|
|
|
const { projectPath, mergeRequestIID } = this;
|
|
|
|
|
|
|
|
return {
|
|
|
|
projectPath,
|
|
|
|
mergeRequestIID,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<gl-popover :target="target" boundary="viewport" placement="top" show>
|
|
|
|
<div class="mr-popover">
|
2022-01-26 12:08:38 +05:30
|
|
|
<div v-if="$apollo.queries.mergeRequest.loading">
|
2019-07-07 11:18:12 +05:30
|
|
|
<gl-skeleton-loading :lines="1" class="animation-container-small mt-1" />
|
|
|
|
</div>
|
|
|
|
<div v-else-if="showDetails" class="d-flex align-items-center justify-content-between">
|
|
|
|
<div class="d-inline-flex align-items-center">
|
|
|
|
<div :class="`issuable-status-box status-box ${statusBoxClass}`">
|
|
|
|
{{ stateHumanName }}
|
|
|
|
</div>
|
2022-01-26 12:08:38 +05:30
|
|
|
<span class="gl-text-secondary">Opened <time v-text="formattedTime"></time></span>
|
2019-07-07 11:18:12 +05:30
|
|
|
</div>
|
|
|
|
<ci-icon v-if="detailedStatus" :status="detailedStatus" />
|
|
|
|
</div>
|
2022-01-26 12:08:38 +05:30
|
|
|
<h5 v-if="!$apollo.queries.mergeRequest.loading" class="my-2">{{ title }}</h5>
|
2020-04-22 19:07:51 +05:30
|
|
|
<!-- eslint-disable @gitlab/vue-require-i18n-strings -->
|
2022-01-26 12:08:38 +05:30
|
|
|
<div class="gl-text-secondary">
|
2019-07-07 11:18:12 +05:30
|
|
|
{{ `${projectPath}!${mergeRequestIID}` }}
|
|
|
|
</div>
|
2020-04-22 19:07:51 +05:30
|
|
|
<!-- eslint-enable @gitlab/vue-require-i18n-strings -->
|
2019-07-07 11:18:12 +05:30
|
|
|
</div>
|
|
|
|
</gl-popover>
|
|
|
|
</template>
|