diff options
Diffstat (limited to 'app/assets/javascripts/batch_comments/mixins/resolved_status.js')
-rw-r--r-- | app/assets/javascripts/batch_comments/mixins/resolved_status.js | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/app/assets/javascripts/batch_comments/mixins/resolved_status.js b/app/assets/javascripts/batch_comments/mixins/resolved_status.js index 3bbbaa86b51..2517fb198f0 100644 --- a/app/assets/javascripts/batch_comments/mixins/resolved_status.js +++ b/app/assets/javascripts/batch_comments/mixins/resolved_status.js @@ -1,9 +1,58 @@ -import { sprintf, __ } from '~/locale'; +import { mapGetters } from 'vuex'; +import { sprintf, s__, __ } from '~/locale'; export default { + props: { + discussionId: { + type: String, + required: false, + default: null, + }, + resolveDiscussion: { + type: Boolean, + required: false, + default: false, + }, + isDraft: { + type: Boolean, + required: false, + default: false, + }, + }, computed: { + ...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'; + }, resolveButtonTitle() { - let title = __('Mark comment as resolved'); + if (this.isDraft || this.discussionId) return this.resolvedStatusMessage; + + let title = __('Mark as resolved'); if (this.resolvedBy) { title = sprintf(__('Resolved by %{name}'), { name: this.resolvedBy.name }); @@ -12,4 +61,5 @@ export default { return title; }, }, + showStaysResolved: true, }; |