summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/diff_notes/components/resolve_discussion_btn.js.es6
blob: e373b06b1ebd51662ec17282be2c32629db56d6e (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
((w) => {
  w.ResolveDiscussionBtn = Vue.extend({
    mixins: [
      ButtonMixins
    ],
    props: {
      discussionId: String,
      mergeRequestId: Number,
      namespacePath: String,
      projectPath: String,
      canResolve: Boolean,
    },
    data: function() {
      return {
        discussions: CommentsStore.state
      };
    },
    computed: {
      discussion: function () {
        return this.discussions[this.discussionId];
      },
      showButton: function () {
        if (this.discussion) {
          return this.discussion.isResolvable();
        } else {
          return false;
        }
      },
      isDiscussionResolved: function () {
        if (this.discussion) {
          return this.discussion.isResolved();
        } else {
          return false;
        }
      },
      buttonText: function () {
        if (this.isDiscussionResolved) {
          return "Unresolve discussion";
        } else {
          return "Resolve discussion";
        }
      },
      loading: function () {
        if (this.discussion) {
          return this.discussion.loading;
        } else {
          return false;
        }
      }
    },
    methods: {
      resolve: function () {
        ResolveService.toggleResolveForDiscussion(this.namespace, this.mergeRequestId, this.discussionId);
      }
    },
    created: function () {
      CommentsStore.createDiscussion(this.discussionId, this.canResolve);
    }
  });
})(window);