Commit 33edde50 authored by Douwe Maan's avatar Douwe Maan

Don’t show “Resolve discussion” for non-author/members

parent c80f5e0a
......@@ -9,10 +9,8 @@
return CommentsStore.state[this.discussionId];
},
showButton: function () {
if (!this.discussion) {
return false;
} else {
return this.discussion.canResolve();
if (this.discussion) {
return this.discussion.isResolvable();
}
},
isDiscussionResolved: function () {
......
......@@ -8,6 +8,7 @@
mergeRequestId: Number,
namespacePath: String,
projectPath: String,
canResolve: Boolean,
},
data: function() {
return {
......@@ -18,6 +19,11 @@
discussion: function () {
return this.discussions[this.discussionId];
},
showButton: function () {
if (this.discussion) {
return this.discussion.isResolvable();
}
},
allResolved: function () {
if (this.discussion) {
return this.discussion.isResolved();
......@@ -40,6 +46,9 @@
resolve: function () {
ResolveService.toggleResolveForDiscussion(this.namespace, this.mergeRequestId, this.discussionId);
}
},
created: function () {
CommentsStore.createDiscussion(this.discussionId, this.canResolve);
}
});
})(window);
......@@ -3,6 +3,7 @@ class DiscussionModel {
this.id = discussionId;
this.notes = {};
this.loading = false;
this.canResolve = false;
}
createNote (noteId, canResolve, resolved, resolved_by) {
......@@ -68,7 +69,11 @@ class DiscussionModel {
}
}
canResolve () {
isResolvable () {
if (!this.canResolve) {
return false;
}
for (const noteId in this.notes) {
const note = this.notes[noteId];
......
......@@ -4,13 +4,22 @@
get: function (discussionId, noteId) {
return this.state[discussionId].getNote(noteId);
},
create: function (discussionId, noteId, canResolve, resolved, resolved_by) {
createDiscussion: function (discussionId, canResolve) {
let discussion = this.state[discussionId];
if (!this.state[discussionId]) {
discussion = new DiscussionModel(discussionId);
Vue.set(this.state, discussionId, discussion);
}
if (canResolve !== undefined) {
discussion.canResolve = canResolve;
}
return discussion;
},
create: function (discussionId, noteId, canResolve, resolved, resolved_by) {
const discussion = this.createDiscussion(discussionId);
discussion.createNote(noteId, canResolve, resolved, resolved_by);
},
update: function (discussionId, noteId, resolved, resolved_by) {
......
- if discussion.can_resolve?(current_user)
.btn-group{ role: "group" }
%resolve-discussion-btn{ ":namespace-path" => "'#{discussion.project.namespace.path}'",
":project-path" => "'#{discussion.project.path}'",
":discussion-id" => "'#{discussion.id}'",
":merge-request-id" => "#{discussion.noteable.iid}",
"inline-template" => true,
"v-cloak" => true }
- if discussion.for_merge_request?
%resolve-discussion-btn{ ":namespace-path" => "'#{discussion.project.namespace.path}'",
":project-path" => "'#{discussion.project.path}'",
":discussion-id" => "'#{discussion.id}'",
":merge-request-id" => discussion.noteable.iid,
":can-resolve" => discussion.can_resolve?(current_user),
"inline-template" => true }
.btn-group{ role: "group", "v-if" => "showButton" }
%button.btn.btn-default{ type: "button", "@click" => "resolve", ":disabled" => "loading" }
= icon("spinner spin", "v-show" => "loading")
{{ buttonText }}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment