summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz.bizon@ntsn.pl>2015-12-02 10:51:46 +0100
committerGrzegorz Bizon <grzegorz.bizon@ntsn.pl>2015-12-03 13:38:59 +0100
commita527f5c27ff92d2ee7e2d5e78dc20b6d1d982aa0 (patch)
tree760d930d886e90c1b8702427d00cbdba44251887
parentbfce5d716835f07b98b6d26ccc121d3ac8322aa9 (diff)
downloadgitlab-ce-a527f5c27ff92d2ee7e2d5e78dc20b6d1d982aa0.tar.gz
Notify user when award-emoji comment is invalid
-rw-r--r--app/assets/javascripts/notes.js.coffee4
-rw-r--r--app/controllers/projects/notes_controller.rb7
2 files changed, 10 insertions, 1 deletions
diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee
index 797234e6d9c..af0d62c8495 100644
--- a/app/assets/javascripts/notes.js.coffee
+++ b/app/assets/javascripts/notes.js.coffee
@@ -111,6 +111,10 @@ class @Notes
Note: for rendering inline notes use renderDiscussionNote
###
renderNote: (note) ->
+ unless note.valid
+ alert('You have already used this award emoji !') if note.award
+ return
+
# render note if it not present in loaded list
# or skip if rendered
if @isNewNote(note) && !note.award
diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb
index a7ff5fcd09a..88b949a27ab 100644
--- a/app/controllers/projects/notes_controller.rb
+++ b/app/controllers/projects/notes_controller.rb
@@ -133,6 +133,7 @@ class Projects::NotesController < Projects::ApplicationController
def render_note_json(note)
if note.valid?
render json: {
+ valid: true,
id: note.id,
discussion_id: note.discussion_id,
html: note_to_html(note),
@@ -143,7 +144,11 @@ class Projects::NotesController < Projects::ApplicationController
discussion_with_diff_html: note_to_discussion_with_diff_html(note)
}
else
- render json: { invalid: true, errors: note.errors }
+ render json: {
+ valid: false,
+ award: note.is_award,
+ errors: note.errors
+ }
end
end