2020-06-01 02:08:21 -04:00
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import { sprintf, s__, __ } from '~/locale';
|
2019-05-07 08:11:36 -04:00
|
|
|
|
2019-05-01 08:58:52 -04:00
|
|
|
export default {
|
2020-06-01 02:08:21 -04:00
|
|
|
props: {
|
|
|
|
discussionId: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
resolveDiscussion: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
isDraft: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
},
|
2019-05-01 08:58:52 -04:00
|
|
|
computed: {
|
2020-06-01 02:08:21 -04:00
|
|
|
...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-05-01 08:58:52 -04:00
|
|
|
resolveButtonTitle() {
|
2021-04-19 08:09:04 -04:00
|
|
|
const escapeParameters = false;
|
|
|
|
|
2020-06-01 02:08:21 -04:00
|
|
|
if (this.isDraft || this.discussionId) return this.resolvedStatusMessage;
|
|
|
|
|
2021-03-31 17:09:15 -04:00
|
|
|
let title = __('Resolve thread');
|
2020-10-22 11:08:25 -04:00
|
|
|
|
2019-05-01 08:58:52 -04:00
|
|
|
if (this.resolvedBy) {
|
2021-04-19 08:09:04 -04:00
|
|
|
title = sprintf(
|
|
|
|
__('Resolved by %{name}'),
|
|
|
|
{ name: this.resolvedBy.name },
|
|
|
|
escapeParameters,
|
|
|
|
);
|
2019-05-01 08:58:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return title;
|
|
|
|
},
|
|
|
|
},
|
2020-06-01 02:08:21 -04:00
|
|
|
showStaysResolved: true,
|
2019-05-01 08:58:52 -04:00
|
|
|
};
|