diff options
author | Clement Ho <clemmakesapps@gmail.com> | 2018-02-28 15:40:52 +0000 |
---|---|---|
committer | Clement Ho <clemmakesapps@gmail.com> | 2018-02-28 15:40:52 +0000 |
commit | b5b8dc83cc1bb271877c79532ecfb555540672a7 (patch) | |
tree | 190f6cd6991cbfbabbd670a7aac5ff36eb1a64bb /app/controllers/projects/notes_controller.rb | |
parent | deef09cd1f0dbe5cab5095ff02f19a5c3588cb91 (diff) | |
parent | ff2f57da791890957fe97efd46f5c34f270a0c46 (diff) | |
download | gitlab-ce-dispatcher-cycle-analytics.tar.gz |
Merge branch 'master' into 'dispatcher-cycle-analytics'dispatcher-cycle-analytics
# Conflicts:
# config/webpack.config.js
Diffstat (limited to 'app/controllers/projects/notes_controller.rb')
-rw-r--r-- | app/controllers/projects/notes_controller.rb | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 4f8978c93c3..dd41b9648e8 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -1,5 +1,6 @@ class Projects::NotesController < Projects::ApplicationController include NotesActions + include NotesHelper include ToggleAwardEmoji before_action :whitelist_query_limiting, only: [:create] @@ -38,10 +39,14 @@ class Projects::NotesController < Projects::ApplicationController discussion = note.discussion - render json: { - resolved_by: note.resolved_by.try(:name), - discussion_headline_html: (view_to_html_string('discussions/_headline', discussion: discussion) if discussion) - } + if serialize_notes? + render_json_with_notes_serializer + else + render json: { + resolved_by: note.resolved_by.try(:name), + discussion_headline_html: (view_to_html_string('discussions/_headline', discussion: discussion) if discussion) + } + end end def unresolve @@ -51,16 +56,27 @@ class Projects::NotesController < Projects::ApplicationController discussion = note.discussion - render json: { - discussion_headline_html: (view_to_html_string('discussions/_headline', discussion: discussion) if discussion) - } + if serialize_notes? + render_json_with_notes_serializer + else + render json: { + discussion_headline_html: (view_to_html_string('discussions/_headline', discussion: discussion) if discussion) + } + end end private + def render_json_with_notes_serializer + Notes::RenderService.new(current_user).execute([note], project) + + render json: note_serializer.represent(note) + end + def note @note ||= @project.notes.find(params[:id]) end + alias_method :awardable, :note def finder_params |