diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/application_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/concerns/toggle_award_emoji.rb | 10 | ||||
-rw-r--r-- | app/controllers/projects/notes_controller.rb | 44 |
3 files changed, 40 insertions, 22 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 62f63701799..713d552976c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -366,6 +366,14 @@ class ApplicationController < ActionController::Base request.base_url end + def require_feature!(feature) + if Gitlab::Feature.feature_enabled?(feature) + yield + else + head(:service_unavailable) + end + end + private def set_default_sort diff --git a/app/controllers/concerns/toggle_award_emoji.rb b/app/controllers/concerns/toggle_award_emoji.rb index 036777c80c1..13c3de4ddbb 100644 --- a/app/controllers/concerns/toggle_award_emoji.rb +++ b/app/controllers/concerns/toggle_award_emoji.rb @@ -6,12 +6,14 @@ module ToggleAwardEmoji end def toggle_award_emoji - name = params.require(:name) + require_feature!(:toggling_award_emoji) do + name = params.require(:name) - awardable.toggle_award_emoji(name, current_user) - TodoService.new.new_award_emoji(to_todoable(awardable), current_user) + awardable.toggle_award_emoji(name, current_user) + TodoService.new.new_award_emoji(to_todoable(awardable), current_user) - render json: { ok: true } + render json: { ok: true } + end end private diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 836f79ff080..db046aaa7a4 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -22,39 +22,47 @@ class Projects::NotesController < Projects::ApplicationController end def create - @note = Notes::CreateService.new(project, current_user, note_params).execute + require_feature!(:creating_notes) do + @note = Notes::CreateService.new(project, current_user, note_params).execute - respond_to do |format| - format.json { render json: note_json(@note) } - format.html { redirect_back_or_default } + respond_to do |format| + format.json { render json: note_json(@note) } + format.html { redirect_back_or_default } + end end end def update - @note = Notes::UpdateService.new(project, current_user, note_params).execute(note) + require_feature!(:updating_notes) do + @note = Notes::UpdateService.new(project, current_user, note_params).execute(note) - respond_to do |format| - format.json { render json: note_json(@note) } - format.html { redirect_back_or_default } + respond_to do |format| + format.json { render json: note_json(@note) } + format.html { redirect_back_or_default } + end end end def destroy - if note.editable? - Notes::DeleteService.new(project, current_user).execute(note) - end - - respond_to do |format| - format.js { head :ok } + require_feature!(:removing_notes) do + if note.editable? + Notes::DeleteService.new(project, current_user).execute(note) + end + + respond_to do |format| + format.js { head :ok } + end end end def delete_attachment - note.remove_attachment! - note.update_attribute(:attachment, nil) + require_feature!(:removing_note_attachments) do + note.remove_attachment! + note.update_attribute(:attachment, nil) - respond_to do |format| - format.js { head :ok } + respond_to do |format| + format.js { head :ok } + end end end |