2020-03-23 21:09:46 +00:00
|
|
|
import { isEmpty } from 'lodash';
|
2019-04-05 00:15:56 +00:00
|
|
|
import { sprintf, __ } from '~/locale';
|
2019-02-27 19:12:40 +00:00
|
|
|
import { formatDate } from '~/lib/utils/datetime_utility';
|
|
|
|
import tooltip from '~/vue_shared/directives/tooltip';
|
|
|
|
import icon from '~/vue_shared/components/icon.vue';
|
|
|
|
import timeagoMixin from '~/vue_shared/mixins/timeago';
|
|
|
|
|
|
|
|
const mixins = {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
removeDisabled: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
idKey: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
displayReference: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
pathIdSeparator: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
eventNamespace: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
confidential: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
title: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
path: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
state: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
createdAt: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
closedAt: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
2019-04-05 00:15:56 +00:00
|
|
|
mergedAt: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
2019-02-27 19:12:40 +00:00
|
|
|
milestone: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
|
|
|
dueDate: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
assignees: {
|
|
|
|
type: Array,
|
|
|
|
required: false,
|
|
|
|
default: () => [],
|
|
|
|
},
|
|
|
|
weight: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
|
|
|
default: 0,
|
|
|
|
},
|
|
|
|
canRemove: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2019-04-05 00:15:56 +00:00
|
|
|
isMergeRequest: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
pipelineStatus: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
2019-02-27 19:12:40 +00:00
|
|
|
},
|
|
|
|
components: {
|
|
|
|
icon,
|
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
tooltip,
|
|
|
|
},
|
|
|
|
mixins: [timeagoMixin],
|
|
|
|
computed: {
|
|
|
|
hasState() {
|
|
|
|
return this.state && this.state.length > 0;
|
|
|
|
},
|
2019-04-05 00:15:56 +00:00
|
|
|
hasPipeline() {
|
|
|
|
return this.isMergeRequest && this.pipelineStatus && Object.keys(this.pipelineStatus).length;
|
|
|
|
},
|
2019-02-27 19:12:40 +00:00
|
|
|
isOpen() {
|
|
|
|
return this.state === 'opened';
|
|
|
|
},
|
|
|
|
isClosed() {
|
|
|
|
return this.state === 'closed';
|
|
|
|
},
|
2019-04-05 00:15:56 +00:00
|
|
|
isMerged() {
|
|
|
|
return this.state === 'merged';
|
|
|
|
},
|
2019-02-27 19:12:40 +00:00
|
|
|
hasTitle() {
|
|
|
|
return this.title.length > 0;
|
|
|
|
},
|
2019-06-27 06:12:38 +00:00
|
|
|
hasAssignees() {
|
|
|
|
return this.assignees.length > 0;
|
|
|
|
},
|
2019-02-27 19:12:40 +00:00
|
|
|
hasMilestone() {
|
2020-03-23 21:09:46 +00:00
|
|
|
return !isEmpty(this.milestone);
|
2019-02-27 19:12:40 +00:00
|
|
|
},
|
|
|
|
iconName() {
|
2019-04-05 00:15:56 +00:00
|
|
|
if (this.isMergeRequest && this.isMerged) {
|
|
|
|
return 'merge';
|
|
|
|
}
|
|
|
|
|
2019-02-27 19:12:40 +00:00
|
|
|
return this.isOpen ? 'issue-open-m' : 'issue-close';
|
|
|
|
},
|
|
|
|
iconClass() {
|
2019-04-05 00:15:56 +00:00
|
|
|
if (this.isMergeRequest && this.isClosed) {
|
|
|
|
return 'merge-request-status closed issue-token-state-icon-closed';
|
|
|
|
}
|
|
|
|
|
2019-02-27 19:12:40 +00:00
|
|
|
return this.isOpen ? 'issue-token-state-icon-open' : 'issue-token-state-icon-closed';
|
|
|
|
},
|
|
|
|
computedLinkElementType() {
|
|
|
|
return this.path.length > 0 ? 'a' : 'span';
|
|
|
|
},
|
|
|
|
computedPath() {
|
|
|
|
return this.path.length ? this.path : null;
|
|
|
|
},
|
|
|
|
itemPath() {
|
|
|
|
return this.displayReference.split(this.pathIdSeparator)[0];
|
|
|
|
},
|
|
|
|
itemId() {
|
|
|
|
return this.displayReference.split(this.pathIdSeparator).pop();
|
|
|
|
},
|
|
|
|
createdAtInWords() {
|
2019-12-12 09:07:48 +00:00
|
|
|
return this.createdAt ? this.timeFormatted(this.createdAt) : '';
|
2019-02-27 19:12:40 +00:00
|
|
|
},
|
|
|
|
createdAtTimestamp() {
|
|
|
|
return this.createdAt ? formatDate(new Date(this.createdAt)) : '';
|
|
|
|
},
|
2019-04-05 00:15:56 +00:00
|
|
|
mergedAtTimestamp() {
|
|
|
|
return this.mergedAt ? formatDate(new Date(this.mergedAt)) : '';
|
|
|
|
},
|
|
|
|
mergedAtInWords() {
|
2019-12-12 09:07:48 +00:00
|
|
|
return this.mergedAt ? this.timeFormatted(this.mergedAt) : '';
|
2019-04-05 00:15:56 +00:00
|
|
|
},
|
2019-02-27 19:12:40 +00:00
|
|
|
closedAtInWords() {
|
2019-12-12 09:07:48 +00:00
|
|
|
return this.closedAt ? this.timeFormatted(this.closedAt) : '';
|
2019-02-27 19:12:40 +00:00
|
|
|
},
|
|
|
|
closedAtTimestamp() {
|
|
|
|
return this.closedAt ? formatDate(new Date(this.closedAt)) : '';
|
|
|
|
},
|
2019-04-05 00:15:56 +00:00
|
|
|
stateText() {
|
|
|
|
if (this.isMerged) {
|
|
|
|
return __('Merged');
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.isOpen ? __('Opened') : __('Closed');
|
|
|
|
},
|
|
|
|
stateTimeInWords() {
|
|
|
|
if (this.isMerged) {
|
|
|
|
return this.mergedAtInWords;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.isOpen ? this.createdAtInWords : this.closedAtInWords;
|
|
|
|
},
|
|
|
|
stateTimestamp() {
|
|
|
|
if (this.isMerged) {
|
|
|
|
return this.mergedAtTimestamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.isOpen ? this.createdAtTimestamp : this.closedAtTimestamp;
|
|
|
|
},
|
|
|
|
pipelineStatusTooltip() {
|
|
|
|
return this.hasPipeline
|
|
|
|
? sprintf(__('Pipeline: %{status}'), { status: this.pipelineStatus.label })
|
|
|
|
: '';
|
|
|
|
},
|
2019-02-27 19:12:40 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onRemoveRequest() {
|
|
|
|
let namespacePrefix = '';
|
|
|
|
if (this.eventNamespace && this.eventNamespace.length > 0) {
|
|
|
|
namespacePrefix = `${this.eventNamespace}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$emit(`${namespacePrefix}RemoveRequest`, this.idKey);
|
|
|
|
|
|
|
|
this.removeDisabled = true;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export default mixins;
|