Class: RailsOnboarding::TooltipsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- RailsOnboarding::TooltipsController
- Includes:
- RateLimitable
- Defined in:
- app/controllers/rails_onboarding/tooltips_controller.rb
Instance Method Summary collapse
-
#dismiss ⇒ Object
POST /tooltips/dismiss.
-
#mark_shown ⇒ Object
Legacy action - kept for backward compatibility.
-
#reset ⇒ Object
POST /tooltips/reset.
-
#show ⇒ Object
POST /tooltips/show.
-
#status ⇒ Object
GET /tooltips/status.
Instance Method Details
#dismiss ⇒ Object
POST /tooltips/dismiss
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/rails_onboarding/tooltips_controller.rb', line 8 def dismiss tooltip_id = params[:tooltip_id] if tooltip_id.blank? render json: { success: false, message: "tooltip_id is required" }, status: :bad_request return end # For dismiss, we mark as shown and track as dismissed if current_user.respond_to?(:dismiss_tooltip) current_user.dismiss_tooltip(tooltip_id) render json: { success: true } elsif current_user.respond_to?(:mark_tooltip_shown!) # Fallback: manually mark and track tooltips = current_user.feature_tooltips_shown || {} tooltips[tooltip_id.to_s] = Time.current.iso8601 current_user.update!(feature_tooltips_shown: tooltips) # Track dismissal event if current_user.respond_to?(:track_tooltip_interaction!) current_user.track_tooltip_interaction!(tooltip_id, "dismissed") end render json: { success: true } else render json: { success: false, message: "User does not support tooltips" }, status: :unprocessable_entity end end |
#mark_shown ⇒ Object
Legacy action - kept for backward compatibility
71 72 73 74 75 76 77 78 79 80 |
# File 'app/controllers/rails_onboarding/tooltips_controller.rb', line 71 def mark_shown feature = params[:feature] if feature.present? && current_user.respond_to?(:mark_tooltip_shown!) current_user.mark_tooltip_shown!(feature) render json: { status: "success", feature: feature } else render json: { status: "error", message: "Invalid feature or user" }, status: :unprocessable_entity end end |
#reset ⇒ Object
POST /tooltips/reset
49 50 51 52 53 54 55 56 |
# File 'app/controllers/rails_onboarding/tooltips_controller.rb', line 49 def reset if current_user.respond_to?(:reset_tooltips!) current_user.reset_tooltips! render json: { success: true } else render json: { success: false, message: "User does not support tooltips" }, status: :unprocessable_entity end end |
#show ⇒ Object
POST /tooltips/show
37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/rails_onboarding/tooltips_controller.rb', line 37 def show tooltip_id = params[:tooltip_id] if tooltip_id.present? && current_user.respond_to?(:mark_tooltip_shown!) current_user.mark_tooltip_shown!(tooltip_id) render json: { success: true } else render json: { success: false, message: "Invalid tooltip_id or user" }, status: :unprocessable_entity end end |
#status ⇒ Object
GET /tooltips/status
59 60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/rails_onboarding/tooltips_controller.rb', line 59 def status tooltip_id = params[:tooltip_id] if tooltip_id.present? && current_user.respond_to?(:show_feature_tooltip?) shown = !current_user.show_feature_tooltip?(tooltip_id) render json: { shown: shown, tooltip_id: tooltip_id } else render json: { shown: false, message: "Invalid tooltip_id or user" }, status: :unprocessable_entity end end |