diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-10-01 17:10:01 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-10-01 17:10:52 -0400 |
commit | 8366ce364c3c777474adfdd3721976cb4c963030 (patch) | |
tree | 011dc497006c463c4fa0e5531dd09ff898e15346 | |
parent | 529cf138a18b33aea35aab5a7b72f705df5e2982 (diff) | |
parent | b35dd6b908c790d2724f0147d3af28dbae0a4a52 (diff) | |
download | gitlab-ce-8366ce364c3c777474adfdd3721976cb4c963030.tar.gz |
Merge branch 'rs-update-note' into 'master'
Ensure updated notes are syntax highlighted
See merge request !1444
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/assets/javascripts/notes.js.coffee | 16 | ||||
-rw-r--r-- | app/models/note.rb | 2 | ||||
-rw-r--r-- | app/views/projects/notes/_note.html.haml | 4 |
4 files changed, 14 insertions, 9 deletions
diff --git a/CHANGELOG b/CHANGELOG index 9a269652f66..a8b43dd4608 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -25,6 +25,7 @@ v 8.1.0 (unreleased) - Add support of multibyte characters in LDAP UID (Roman Petrov) - Show additions/deletions stats on merge request diff - Remove footer text in emails (Zeger-Jan van de Weg) + - Ensure code blocks are properly highlighted after a note is updated v 8.0.3 - Fix URL shown in Slack notifications diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee index ce638c2641b..4b9f0d68912 100644 --- a/app/assets/javascripts/notes.js.coffee +++ b/app/assets/javascripts/notes.js.coffee @@ -277,13 +277,15 @@ class @Notes Updates the current note field. ### - updateNote: (xhr, note, status) => - note_li = $(".note-row-" + note.id) - note_li.replaceWith(note.html) - note_li.find('.note-edit-form').hide() - note_li.find('.note-body > .note-text').show() - note_li.find('js-task-list-container').taskList('enable') - @enableTaskList() + updateNote: (_xhr, note, _status) => + # Convert returned HTML to a jQuery object so we can modify it further + $html = $(note.html) + $html.syntaxHighlight() + $html.find('.js-task-list-container').taskList('enable') + + # Find the note's `li` element by ID and replace it with the updated HTML + $note_li = $("#note_#{note.id}") + $note_li.replaceWith($html) ### Called in response to clicking the edit note link diff --git a/app/models/note.rb b/app/models/note.rb index 89d81ab1de2..de3b6df88f7 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -366,6 +366,6 @@ class Note < ActiveRecord::Base end def editable? - !read_attribute(:system) + !system? end end diff --git a/app/views/projects/notes/_note.html.haml b/app/views/projects/notes/_note.html.haml index 9bfbde02ca2..cf5d5d6d8ba 100644 --- a/app/views/projects/notes/_note.html.haml +++ b/app/views/projects/notes/_note.html.haml @@ -59,7 +59,9 @@ .note-text = preserve do = markdown(note.note, {no_header_anchors: true}) - = render 'projects/notes/edit_form', note: note + - unless note.system? + -# System notes can't be edited + = render 'projects/notes/edit_form', note: note - if note.attachment.url .note-attachment |