summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/diff_notes/components/resolve_comment_btn.js.es6
blob: 1ffe4cf99d6fb246a158cd7d4b95192d19cbddc8 (plain)
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
((w) => {
  w.ResolveCommentBtn = Vue.extend({
    props: {
      discussionId: String
    },
    computed: {
      isDiscussionResolved: function () {
        const notes = CommentsStore.notesForDiscussion(this.discussionId),
              discussion = CommentsStore.state[this.discussionId];
        let allResolved = true;

        for (const noteId of notes) {
          const note = discussion[noteId];

          if (!note.resolved) {
            allResolved = false;
          }
        }

        return allResolved;
      },
      buttonText: function () {
        if (this.isDiscussionResolved) {
          return "Comment & unresolve discussion";
        } else {
          return "Comment & resolve discussion";
        }
      }
    }
  });
}(window));