From b550e6ee67ebfc1cfbbb7a77414f9fe05ffad419 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Mon, 4 Jul 2016 15:00:39 +0100 Subject: Posts to rails to update note eventually --- app/controllers/projects/notes_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/controllers/projects/notes_controller.rb') diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 766b7e9cf22..5ace460d02f 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -66,6 +66,11 @@ class Projects::NotesController < Projects::ApplicationController end end + def resolve + sleep 2 + render nothing: true, status: 200 + end + private def note -- cgit v1.2.1 From a55c1232b5922d20942669697c3ee0b5989e5c71 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 5 Jul 2016 17:27:07 +0100 Subject: Resolve all endpoint --- app/controllers/projects/notes_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/controllers/projects/notes_controller.rb') diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 5ace460d02f..c3237fd360e 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -71,6 +71,11 @@ class Projects::NotesController < Projects::ApplicationController render nothing: true, status: 200 end + def resolve_all + sleep 2 + render nothing: true, status: 200 + end + private def note -- cgit v1.2.1 From 4af0146fa54eb24c0d2a267887c892c33b9ebc53 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 13 Jul 2016 12:40:11 +0100 Subject: Assigns to variable rather than using VueJS method --- app/controllers/projects/notes_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/controllers/projects/notes_controller.rb') diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index c3237fd360e..0b93dc31ac7 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -68,12 +68,12 @@ class Projects::NotesController < Projects::ApplicationController def resolve sleep 2 - render nothing: true, status: 200 + head :ok end def resolve_all sleep 2 - render nothing: true, status: 200 + head :ok end private -- cgit v1.2.1 From eeb41c759e246bf96bda8d8f02478860cc6448bb Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 25 Jul 2016 22:43:47 -0600 Subject: Add endpoints to resolve diff notes and discussions --- app/controllers/projects/notes_controller.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'app/controllers/projects/notes_controller.rb') diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 0b93dc31ac7..fb9d027ce03 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -5,6 +5,7 @@ class Projects::NotesController < Projects::ApplicationController before_action :authorize_read_note! before_action :authorize_create_note!, only: [:create] before_action :authorize_admin_note!, only: [:update, :destroy] + before_action :authorize_resolve_note!, only: [:resolve] before_action :find_current_user_notes, only: [:index] def index @@ -67,12 +68,18 @@ class Projects::NotesController < Projects::ApplicationController end def resolve - sleep 2 + return render_404 unless note.resolvable? + + note.resolve!(current_user) + head :ok end - def resolve_all - sleep 2 + def unresolve + return render_404 unless note.resolvable? + + note.unresolve! + head :ok end @@ -185,6 +192,10 @@ class Projects::NotesController < Projects::ApplicationController return access_denied! unless can?(current_user, :admin_note, note) end + def authorize_resolve_note! + return access_denied! unless can?(current_user, :resolve_note, note) + end + def note_params params.require(:note).permit( :note, :noteable, :noteable_id, :noteable_type, :project_id, -- cgit v1.2.1 From a678fef83611ea873d252941586c18171cd6ba07 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 26 Jul 2016 15:47:19 +0100 Subject: Added resolved by users name into tooltip --- app/controllers/projects/notes_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/controllers/projects/notes_controller.rb') diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index fb9d027ce03..ad7376b8574 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -72,7 +72,9 @@ class Projects::NotesController < Projects::ApplicationController note.resolve!(current_user) - head :ok + render json: { + resolved_by: note.resolved_by.try(:name) + } end def unresolve -- cgit v1.2.1 From 2247d8a4fd7f77e1a4b8a50becdd08643435f19d Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 27 Jul 2016 18:34:04 +0100 Subject: Updates the text above discussions when resolving notes & discussions --- app/controllers/projects/notes_controller.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'app/controllers/projects/notes_controller.rb') diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index ad7376b8574..59b8e88c8d7 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -72,8 +72,11 @@ class Projects::NotesController < Projects::ApplicationController note.resolve!(current_user) + discussion = note.noteable.discussions.find { |d| d.id == note.discussion_id } || render_404 + render json: { - resolved_by: note.resolved_by.try(:name) + resolved_by: note.resolved_by.try(:name), + updated_html: view_to_html_string('discussions/_headline', discussion: discussion) } end @@ -82,7 +85,11 @@ class Projects::NotesController < Projects::ApplicationController note.unresolve! - head :ok + discussion = note.noteable.discussions.find { |d| d.id == note.discussion_id } || render_404 + + render json: { + updated_html: view_to_html_string('discussions/_headline', discussion: discussion) + } end private -- cgit v1.2.1 From 1c2eefef3f67d9d221b6465ec77907940732e789 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Thu, 28 Jul 2016 20:09:36 -0600 Subject: Backend tweaks --- app/controllers/projects/notes_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'app/controllers/projects/notes_controller.rb') diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 59b8e88c8d7..027a2d7dcb2 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -72,11 +72,11 @@ class Projects::NotesController < Projects::ApplicationController note.resolve!(current_user) - discussion = note.noteable.discussions.find { |d| d.id == note.discussion_id } || render_404 + discussion = note.discussion render json: { resolved_by: note.resolved_by.try(:name), - updated_html: view_to_html_string('discussions/_headline', discussion: discussion) + discussion_headline_html: (view_to_html_string('discussions/_headline', discussion: discussion) if discussion) } end @@ -85,10 +85,10 @@ class Projects::NotesController < Projects::ApplicationController note.unresolve! - discussion = note.noteable.discussions.find { |d| d.id == note.discussion_id } || render_404 + discussion = note.discussion render json: { - updated_html: view_to_html_string('discussions/_headline', discussion: discussion) + discussion_headline_html: (view_to_html_string('discussions/_headline', discussion: discussion) if discussion) } end @@ -164,7 +164,7 @@ class Projects::NotesController < Projects::ApplicationController } if note.diff_note? - discussion = Discussion.new([note]) + discussion = note.as_discussion attrs.merge!( diff_discussion_html: diff_discussion_html(discussion), -- cgit v1.2.1 From fa4a613517a4a236ea5e98a1964e52c8b4eef595 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Thu, 28 Jul 2016 20:39:35 -0600 Subject: Add 'Resolved all discussions' system note --- app/controllers/projects/notes_controller.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/controllers/projects/notes_controller.rb') diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 027a2d7dcb2..1849311d26d 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -72,6 +72,8 @@ class Projects::NotesController < Projects::ApplicationController note.resolve!(current_user) + MergeRequests::AllDiscussionsResolvedService.new(project, current_user).execute(note.noteable) + discussion = note.discussion render json: { -- cgit v1.2.1 From 1bee660b96d7a84cfcc4a274c68cbe0fba4b5fa5 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Thu, 28 Jul 2016 21:14:41 -0600 Subject: Don't send resolved notifications when deleting a note --- app/controllers/projects/notes_controller.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'app/controllers/projects/notes_controller.rb') diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 1849311d26d..027a2d7dcb2 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -72,8 +72,6 @@ class Projects::NotesController < Projects::ApplicationController note.resolve!(current_user) - MergeRequests::AllDiscussionsResolvedService.new(project, current_user).execute(note.noteable) - discussion = note.discussion render json: { -- cgit v1.2.1 From 9b115ce4d3ccdd03043f070935d3a25e96f537f4 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 3 Aug 2016 17:16:37 -0700 Subject: Actually don't send resolved notifications when deleting a note --- app/controllers/projects/notes_controller.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/controllers/projects/notes_controller.rb') diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 027a2d7dcb2..1849311d26d 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -72,6 +72,8 @@ class Projects::NotesController < Projects::ApplicationController note.resolve!(current_user) + MergeRequests::AllDiscussionsResolvedService.new(project, current_user).execute(note.noteable) + discussion = note.discussion render json: { -- cgit v1.2.1 From e25720045988e59f7ddfecebbc02e640dc2f8360 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Fri, 12 Aug 2016 16:24:09 -0500 Subject: Add specs for NotesController and DiscussionsController --- app/controllers/projects/notes_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers/projects/notes_controller.rb') diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 1849311d26d..934a7961a63 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -5,7 +5,7 @@ class Projects::NotesController < Projects::ApplicationController before_action :authorize_read_note! before_action :authorize_create_note!, only: [:create] before_action :authorize_admin_note!, only: [:update, :destroy] - before_action :authorize_resolve_note!, only: [:resolve] + before_action :authorize_resolve_note!, only: [:resolve, :unresolve] before_action :find_current_user_notes, only: [:index] def index -- cgit v1.2.1 From 41007f6d3c30a294bbf361ff900b3b19bb463291 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 15 Aug 2016 18:45:23 -0500 Subject: Address review feedback --- app/controllers/projects/notes_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/controllers/projects/notes_controller.rb') diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 934a7961a63..c16fc228f27 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -72,7 +72,7 @@ class Projects::NotesController < Projects::ApplicationController note.resolve!(current_user) - MergeRequests::AllDiscussionsResolvedService.new(project, current_user).execute(note.noteable) + MergeRequests::ResolvedDiscussionNotificationService.new(project, current_user).execute(note.noteable) discussion = note.discussion @@ -166,7 +166,7 @@ class Projects::NotesController < Projects::ApplicationController } if note.diff_note? - discussion = note.as_discussion + discussion = note.to_discussion attrs.merge!( diff_discussion_html: diff_discussion_html(discussion), -- cgit v1.2.1