diff options
| author | Clement Ho <clemmakesapps@gmail.com> | 2018-03-01 22:33:29 +0000 |
|---|---|---|
| committer | Clement Ho <clemmakesapps@gmail.com> | 2018-03-01 22:33:29 +0000 |
| commit | b112a33b98c657b1d2838c14d598a291a14565e0 (patch) | |
| tree | a37cc22491baf419a15b81918ee07c2fd0d8f2da /app/controllers/projects/notes_controller.rb | |
| parent | 4441ca4ba7bf6c4a68574d018d2bf48e45326654 (diff) | |
| parent | 5c4eace67f188da436b3b380a0125d053b29422a (diff) | |
| download | gitlab-ce-sentiment-analysis.tar.gz | |
Merge branch 'master' into 'sentiment-analysis'sentiment-analysis
# Conflicts:
# app/assets/javascripts/notes/components/comment_form.vue
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 |
