Commit cbb659cd authored by André Luís's avatar André Luís

Backport EE fixes to CE checking resolvability

EE branch: 7921-fix-batch-comments-resolution
fixes the checks to know whether discussion will
be resolved upon posting a comment or not. It
covers scenarios where Batch Comments are enabled
and disabled. To minimise risk of conflicts between
CE and EE, the checks have been backported.

this.shouldResolve() will not exist in CE.
parent e5ae0be4
...@@ -102,6 +102,18 @@ export default { ...@@ -102,6 +102,18 @@ export default {
}, },
methods: { methods: {
...mapActions(['toggleResolveNote']), ...mapActions(['toggleResolveNote']),
shouldToggleResolved(shouldResolve, beforeSubmitDiscussionState) {
// shouldBeResolved() checks the actual resolution state,
// considering batchComments (EEP), if applicable/enabled.
const newResolvedStateAfterUpdate =
this.shouldBeResolved && this.shouldBeResolved(shouldResolve);
const shouldToggleState =
newResolvedStateAfterUpdate !== undefined &&
beforeSubmitDiscussionState !== newResolvedStateAfterUpdate;
return shouldResolve || shouldToggleState;
},
handleUpdate(shouldResolve) { handleUpdate(shouldResolve) {
const beforeSubmitDiscussionState = this.discussionResolved; const beforeSubmitDiscussionState = this.discussionResolved;
this.isSubmitting = true; this.isSubmitting = true;
...@@ -109,7 +121,7 @@ export default { ...@@ -109,7 +121,7 @@ export default {
this.$emit('handleFormUpdate', this.updatedNoteBody, this.$refs.editNoteForm, () => { this.$emit('handleFormUpdate', this.updatedNoteBody, this.$refs.editNoteForm, () => {
this.isSubmitting = false; this.isSubmitting = false;
if (shouldResolve) { if (this.shouldToggleResolved(shouldResolve, beforeSubmitDiscussionState)) {
this.resolveHandler(beforeSubmitDiscussionState); this.resolveHandler(beforeSubmitDiscussionState);
} }
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment