2020-06-23 00:09:42 +05:30
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import { sprintf, s__, __ } from '~/locale';
|
2019-09-04 21:01:54 +05:30
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
export default {
|
2020-06-23 00:09:42 +05:30
|
|
|
props: {
|
|
|
|
discussionId: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
resolveDiscussion: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
isDraft: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
},
|
2019-07-31 22:56:46 +05:30
|
|
|
computed: {
|
2020-06-23 00:09:42 +05:30
|
|
|
...mapGetters(['isDiscussionResolved']),
|
|
|
|
resolvedStatusMessage() {
|
|
|
|
let message;
|
|
|
|
const discussionResolved = this.isDiscussionResolved(
|
|
|
|
this.draft ? this.draft.discussion_id : this.discussionId,
|
|
|
|
);
|
|
|
|
const discussionToBeResolved = this.draft
|
|
|
|
? this.draft.resolve_discussion
|
|
|
|
: this.resolveDiscussion;
|
|
|
|
|
|
|
|
if (discussionToBeResolved && discussionResolved && !this.$options.showStaysResolved) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (discussionToBeResolved) {
|
|
|
|
message = discussionResolved
|
|
|
|
? s__('MergeRequests|Thread stays resolved')
|
|
|
|
: s__('MergeRequests|Thread will be resolved');
|
|
|
|
} else if (discussionResolved) {
|
|
|
|
message = s__('MergeRequests|Thread will be unresolved');
|
|
|
|
} else if (this.$options.showStaysResolved) {
|
|
|
|
message = s__('MergeRequests|Thread stays unresolved');
|
|
|
|
}
|
|
|
|
|
|
|
|
return message;
|
|
|
|
},
|
|
|
|
componentClasses() {
|
|
|
|
return this.resolveDiscussion ? 'is-resolving-discussion' : 'is-unresolving-discussion';
|
|
|
|
},
|
2019-07-31 22:56:46 +05:30
|
|
|
resolveButtonTitle() {
|
2021-04-29 21:17:54 +05:30
|
|
|
const escapeParameters = false;
|
2020-06-23 00:09:42 +05:30
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
if (this.isDraft || this.discussionId) return this.resolvedStatusMessage;
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
let title = __('Resolve thread');
|
2021-01-29 00:20:46 +05:30
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
if (this.resolvedBy) {
|
2021-04-29 21:17:54 +05:30
|
|
|
title = sprintf(
|
|
|
|
__('Resolved by %{name}'),
|
|
|
|
{ name: this.resolvedBy.name },
|
|
|
|
escapeParameters,
|
|
|
|
);
|
2019-07-31 22:56:46 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
return title;
|
|
|
|
},
|
|
|
|
},
|
2020-06-23 00:09:42 +05:30
|
|
|
showStaysResolved: true,
|
2019-07-31 22:56:46 +05:30
|
|
|
};
|