提交 5e860656 编写于 作者: P Phil Hughes

Added ability to toggle resolving by commenting

上级 6537a4a8
......@@ -40,15 +40,7 @@
},
methods: {
resolve: function () {
let promise;
if (this.allResolved) {
promise = ResolveService
.unResolveAll(this.namespace, this.mergeRequestId, this.discussionId);
} else {
promise = ResolveService
.resolveAll(this.namespace, this.mergeRequestId, this.discussionId);
}
ResolveService.toggleResolveForDiscussion(this.namespace, this.mergeRequestId, this.discussionId);
}
}
});
......
......@@ -23,6 +23,25 @@
return this.noteResource.delete({ noteId }, {});
}
toggleResolveForDiscussion(namespace, mergeRequestId, discussionId) {
const noteIds = CommentsStore.notesForDiscussion(discussionId);
let isResolved = true;
for (const noteId of noteIds) {
const resolved = CommentsStore.state[discussionId][noteId];
if (!resolved) {
isResolved = false;
}
}
if (isResolved) {
return this.unResolveAll(namespace, mergeRequestId, discussionId);
} else {
return this.resolveAll(namespace, mergeRequestId, discussionId);
}
}
resolveAll(namespace, mergeRequestId, discussionId) {
this.setCSRF();
Vue.http.options.root = `/${namespace}`;
......
......@@ -25,13 +25,22 @@
}
},
updateCommentsForDiscussion: function (discussionId, resolve) {
const noteIds = CommentsStore.notesForDiscussion(discussionId, resolve);
const noteIds = CommentsStore.resolvedNotesForDiscussion(discussionId, resolve);
for (const noteId of noteIds) {
CommentsStore.update(discussionId, noteId, resolve);
}
},
notesForDiscussion: function (discussionId, resolve) {
notesForDiscussion: function (discussionId) {
let ids = [];
for (const noteId in CommentsStore.state[discussionId]) {
ids.push(noteId);
}
return ids;
},
resolvedNotesForDiscussion: function (discussionId, resolve) {
let ids = [];
for (const noteId in CommentsStore.state[discussionId]) {
......
......@@ -401,11 +401,14 @@
this.removeDiscussionNoteForm($form);
if ($form.attr('data-resolve-all') != null) {
var namespace = $form.attr('data-namespace'),
discussionId = $form.attr('data-discussion-id');
var namespacePath = $form.attr('data-namespace-path'),
projectPath = $form.attr('data-project-path')
discussionId = $form.attr('data-discussion-id'),
mergeRequestId = $('input[name="noteable_iid"]', $form).val(),
namespace = `${namespacePath}/${projectPath}`;
if (ResolveService != null) {
ResolveService.resolveAll(namespace, discussionId, false)
ResolveService.toggleResolveForDiscussion(namespace, mergeRequestId, discussionId);
}
}
};
......@@ -771,7 +774,8 @@
.closest('form')
.attr('data-discussion-id', discussionId)
.attr('data-resolve-all', 'true')
.attr('data-namespace', $this.attr('data-namespace'));
.attr('data-namespace-path', $this.attr('data-namespace-path'))
.attr('data-project-path', $this.attr('data-project-path'));
};
return Notes;
......
......@@ -4,6 +4,6 @@
= link_to 'Close merge request', merge_request_path(@merge_request, merge_request: {state_event: :close }), method: :put, class: "btn btn-nr btn-comment btn-close close-mr-link js-note-target-close", title: "Close merge request", data: {original_text: "Close merge request", alternative_text: "Comment & close merge request"}
- if @merge_request.closed?
= link_to 'Reopen merge request', merge_request_path(@merge_request, merge_request: {state_event: :reopen }), method: :put, class: "btn btn-nr btn-comment btn-reopen reopen-mr-link js-note-target-reopen", title: "Reopen merge request", data: {original_text: "Reopen merge request", alternative_text: "Comment & reopen merge request"}
= submit_tag 'Comment & resolve discussion', class: "btn btn-nr btn-create append-right-10 comment-btn js-comment-resolve-button", data: { namespace: "#{@merge_request.project.namespace.path}/#{@merge_request.project.path}" }
= submit_tag 'Comment & resolve discussion', class: "btn btn-nr btn-create append-right-10 comment-btn js-comment-resolve-button", data: { namespace_path: "#{@merge_request.project.namespace.path}", project_path: "#{@merge_request.project.path}" }
#notes= render "projects/notes/notes_with_form"
......@@ -5,6 +5,7 @@
= f.hidden_field :commit_id
= f.hidden_field :line_code
= f.hidden_field :noteable_id
= hidden_field_tag :noteable_iid, @note.noteable.iid
= f.hidden_field :noteable_type
= f.hidden_field :type
= f.hidden_field :position
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册