diff options
3 files changed, 82 insertions, 61 deletions
diff --git a/app/assets/javascripts/diff_notes/components/resolve_discussion_btn.js b/app/assets/javascripts/diff_notes/components/resolve_discussion_btn.js deleted file mode 100644 index 6a036e96171..00000000000 --- a/app/assets/javascripts/diff_notes/components/resolve_discussion_btn.js +++ /dev/null @@ -1,60 +0,0 @@ -/* eslint-disable object-shorthand, func-names, space-before-function-paren, comma-dangle, no-else-return, quotes, max-len */ -/* global CommentsStore */ -/* global ResolveService */ - -import Vue from 'vue'; - -const ResolveDiscussionBtn = Vue.extend({ - props: { - discussionId: String, - mergeRequestId: Number, - canResolve: Boolean, - }, - data: function() { - return { - discussion: {}, - }; - }, - computed: { - 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.mergeRequestId, this.discussionId); - } - }, - created: function () { - CommentsStore.createDiscussion(this.discussionId, this.canResolve); - - this.discussion = CommentsStore.state[this.discussionId]; - } -}); - -Vue.component('resolve-discussion-btn', ResolveDiscussionBtn); diff --git a/app/assets/javascripts/diff_notes/components/resolve_discussion_btn.vue b/app/assets/javascripts/diff_notes/components/resolve_discussion_btn.vue new file mode 100644 index 00000000000..3090167cf2d --- /dev/null +++ b/app/assets/javascripts/diff_notes/components/resolve_discussion_btn.vue @@ -0,0 +1,81 @@ +<script> + /* eslint-disable object-shorthand, func-names, space-before-function-paren, comma-dangle, no-else-return, quotes, max-len */ + /* global CommentsStore */ + /* global ResolveService */ + + import Vue from 'vue'; + + const ResolveDiscussionBtn = Vue.extend({ + props: { + discussionId: String, + mergeRequestId: Number, + canResolve: Boolean, + }, + data: function() { + return { + discussion: {}, + }; + }, + computed: { + 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.mergeRequestId, this.discussionId); + } + }, + created: function () { + CommentsStore.createDiscussion(this.discussionId, this.canResolve); + + this.discussion = CommentsStore.state[this.discussionId]; + } + }); + + Vue.component('resolve-discussion-btn', ResolveDiscussionBtn); +</script> + +<template> + <div + class="btn-group" + role="group" + v-if="showButton" + > + <button + class="btn btn-default" + type="button" + @click="resolve" + :disabled="loading" + v-cloak="true" + > + <loading-icon v-show="loading" /> + {{ buttonText }} + </button> + </div> +</template> diff --git a/app/assets/javascripts/diff_notes/diff_notes_bundle.js b/app/assets/javascripts/diff_notes/diff_notes_bundle.js index a5b2df97fda..87a36fa8f98 100644 --- a/app/assets/javascripts/diff_notes/diff_notes_bundle.js +++ b/app/assets/javascripts/diff_notes/diff_notes_bundle.js @@ -11,7 +11,7 @@ import './components/comment_resolve_btn.vue'; import './components/jump_to_discussion.vue'; import './components/resolve_btn.vue'; import './components/resolve_count'; -import './components/resolve_discussion_btn'; +import './components/resolve_discussion_btn.vue'; import './components/diff_note_avatars'; import './components/new_issue_for_discussion'; |