Move notifications to tray controller

This commit is contained in:
Kevin McConnell
2025-01-16 15:07:47 +00:00
parent 6f8c929898
commit c4f50fa634
6 changed files with 12 additions and 10 deletions
@@ -1,5 +1,5 @@
class NotificationsController < ApplicationController
def index
class Notifications::TraysController < ApplicationController
def show
@notifications = Current.user.notifications.unread.ordered.limit(20)
end
end
+1 -1
View File
@@ -1,5 +1,5 @@
<%= turbo_stream_from Current.user, :notifications %>
<%= tag.div id: "notification-tray", class: "notification-tray flex flex-column gap", data: { turbo_permanent: true } do %>
<%= turbo_frame_tag("notifications", src: notifications_path) %>
<%= turbo_frame_tag("notifications", src: notifications_tray_path) %>
<% end %>
-3
View File
@@ -1,3 +0,0 @@
<%= turbo_frame_tag "notifications" do %>
<%= render @notifications %>
<% end %>
@@ -0,0 +1,3 @@
<%= turbo_frame_tag "notifications" do %>
<%= render collection: @notifications, partial: "notifications/notification" %>
<% end %>
+3 -1
View File
@@ -18,7 +18,9 @@ Rails.application.routes.draw do
end
resources :bubbles
resources :notifications
namespace :notifications do
resource :tray
end
resources :buckets do
resources :bubbles do
@@ -1,12 +1,12 @@
require "test_helper"
class NotificationsControllerTest < ActionDispatch::IntegrationTest
class Notifications::TraysControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "index" do
get notifications_url
test "show" do
get notifications_tray_url
assert_response :success
assert_select "div", text: /Layout is broken/