summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-01-26 22:13:54 +0100
committerMatija Čupić <matteeyah@gmail.com>2018-01-26 23:24:26 +0100
commitc4667f87037150a408da5c133e573714807e17b3 (patch)
treef23d797d22f450d2f0e08acafa504dde945a2da4
parent0dab083702ff4364bc25ea29812a4305c58e5a4f (diff)
downloadgitlab-ce-c4667f87037150a408da5c133e573714807e17b3.tar.gz
Implement Callouts controller
-rw-r--r--app/controllers/callouts_controller.rb27
-rw-r--r--config/routes.rb5
2 files changed, 32 insertions, 0 deletions
diff --git a/app/controllers/callouts_controller.rb b/app/controllers/callouts_controller.rb
new file mode 100644
index 00000000000..a7bccfcce78
--- /dev/null
+++ b/app/controllers/callouts_controller.rb
@@ -0,0 +1,27 @@
+class CalloutsController < ApplicationController
+ before_action :callout, only: [:dismiss]
+
+ def dismiss
+ respond_to do |format|
+ format.json do
+ if @callout
+ @callout.update(dismissed_state: true)
+ else
+ Callout.create(feature_name: callout_param, dismissed_state: true, user: current_user)
+ end
+
+ head :ok
+ end
+ end
+ end
+
+ private
+
+ def callout
+ @callout = Callout.find_by(user: current_user, feature_name: callout_param)
+ end
+
+ def callout_param
+ params.require(:feature_name)
+ end
+end
diff --git a/config/routes.rb b/config/routes.rb
index f162043dd5e..f768bcebc7e 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -90,6 +90,11 @@ Rails.application.routes.draw do
# Notification settings
resources :notification_settings, only: [:create, :update]
+ # Callouts
+ namespace :callouts do
+ post :dismiss
+ end
+
draw :google_api
draw :import
draw :uploads