All files / app/assets/javascripts/notes/mixins resolvable.js

17.64% Statements 3/17
11.76% Branches 2/17
40% Functions 2/5
17.64% Lines 3/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49            43x 43x           27x                                                                      
import { createAlert } from '~/alert';
import { __ } from '~/locale';
 
export default {
  computed: {
    discussionResolved() {
      Eif (this.discussion) {
        return Boolean(this.discussion.resolved);
      }
 
      return this.note.resolved;
    },
    resolveButtonTitle() {
      return this.discussionResolved ? __('Unresolve thread') : __('Resolve thread');
    },
  },
  methods: {
    resolveHandler(resolvedState = false) {
      if (this.note && this.note.isDraft) {
        return this.$emit('toggleResolveStatus');
      }
 
      this.isResolving = true;
      const isResolved = this.discussionResolved || resolvedState;
      const discussion = this.resolveAsThread;
      let endpoint =
        discussion && this.discussion ? this.discussion.resolve_path : `${this.note.path}/resolve`;
 
      if (this.discussionResolvePath) {
        endpoint = this.discussionResolvePath;
      }
 
      return this.toggleResolveNote({ endpoint, isResolved, discussion })
        .then(() => {
          this.isResolving = false;
        })
        .catch(() => {
          this.isResolving = false;
 
          const msg = __('Something went wrong while resolving this discussion. Please try again.');
          createAlert({
            message: msg,
            parent: this.$el,
          });
        });
    },
  },
};