From 914a2a5cde93886ddaefd19e2afbd0f744966e20 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sat, 27 Dec 2025 00:40:27 +0900 Subject: [PATCH 1/8] Inline admin_nav --- app/views/layouts/_navbar.html.haml | 13 ++++++++++++- app/views/layouts/nav/_admin_nav.html.haml | 12 ------------ 2 files changed, 12 insertions(+), 13 deletions(-) delete mode 100644 app/views/layouts/nav/_admin_nav.html.haml diff --git a/app/views/layouts/_navbar.html.haml b/app/views/layouts/_navbar.html.haml index 1d44ddc05..1f041b7ef 100644 --- a/app/views/layouts/_navbar.html.haml +++ b/app/views/layouts/_navbar.html.haml @@ -47,7 +47,18 @@ %sup Beta - if admin_nav? - = render partial: "layouts/nav/admin_nav" + %li.nav-item.dropdown + %a.nav-link.dropdown-toggle{title: 'Admin Toggle', href: '#', role: 'button', data: {bs_toggle: 'dropdown'}, aria: {expanded: 'false'}} + Admin + %ul.dropdown-menu.dropdown-menu-end + %li + = link_to admin_users_path, class: "dropdown-item #{'active' if request.path == admin_users_path}" do + %i.bi.bi-people-fill + %span Users + %li + = link_to admin_events_path, class: "dropdown-item #{'active' if request.path == admin_events_path}" do + %i.bi.bi-calendar + %span Events = render partial: "layouts/nav/notifications_list" diff --git a/app/views/layouts/nav/_admin_nav.html.haml b/app/views/layouts/nav/_admin_nav.html.haml deleted file mode 100644 index b53f8f3b8..000000000 --- a/app/views/layouts/nav/_admin_nav.html.haml +++ /dev/null @@ -1,12 +0,0 @@ -%li.nav-item.dropdown - %a.nav-link.dropdown-toggle{title: 'Admin Toggle', href: '#', role: 'button', data: {bs_toggle: 'dropdown'}, aria: {expanded: 'false'}} - Admin - %ul.dropdown-menu.dropdown-menu-end - %li - = link_to admin_users_path, class: "dropdown-item #{'active' if request.path == admin_users_path}" do - %i.bi.bi-people-fill - %span Users - %li - = link_to admin_events_path, class: "dropdown-item #{'active' if request.path == admin_events_path}" do - %i.bi.bi-calendar - %span Events From 3222e8a3b193ed2dbeb6ba31e69563b8f3aa1c82 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sat, 27 Dec 2025 02:10:58 +0900 Subject: [PATCH 2/8] Activate :admin nav_item --- app/helpers/navbar_helper.rb | 4 ++++ app/views/layouts/_navbar.html.haml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/helpers/navbar_helper.rb b/app/helpers/navbar_helper.rb index 07265d5c6..6956a344e 100644 --- a/app/helpers/navbar_helper.rb +++ b/app/helpers/navbar_helper.rb @@ -35,6 +35,10 @@ def path_for(*args) event_website: { event_website_configuration: ->(p) { p.start_with?(path_for(current_event, :staff, :website)) }, event_pages: ->(p) { p == path_for(current_event, :staff, Page) } + }, + admin: { + admin_users: ->(p) { p == path_for(:admin, User) }, + admin_events: ->(p) { p == path_for(:admin, Event) } } }.freeze diff --git a/app/views/layouts/_navbar.html.haml b/app/views/layouts/_navbar.html.haml index 1f041b7ef..d93f5f2f6 100644 --- a/app/views/layouts/_navbar.html.haml +++ b/app/views/layouts/_navbar.html.haml @@ -47,7 +47,7 @@ %sup Beta - if admin_nav? - %li.nav-item.dropdown + %li.nav-item.dropdown{class: nav_item_class(:admin)} %a.nav-link.dropdown-toggle{title: 'Admin Toggle', href: '#', role: 'button', data: {bs_toggle: 'dropdown'}, aria: {expanded: 'false'}} Admin %ul.dropdown-menu.dropdown-menu-end From 27b60271bc75e931c24cf96d00d07d1a1e2426d4 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sat, 27 Dec 2025 02:17:01 +0900 Subject: [PATCH 3/8] Inline notifications_list nav --- app/views/layouts/_navbar.html.haml | 25 ++++++++++++++++++- .../layouts/nav/_notifications_list.html.haml | 24 ------------------ 2 files changed, 24 insertions(+), 25 deletions(-) delete mode 100644 app/views/layouts/nav/_notifications_list.html.haml diff --git a/app/views/layouts/_navbar.html.haml b/app/views/layouts/_navbar.html.haml index d93f5f2f6..185b3e88e 100644 --- a/app/views/layouts/_navbar.html.haml +++ b/app/views/layouts/_navbar.html.haml @@ -60,7 +60,30 @@ %i.bi.bi-calendar %span Events - = render partial: "layouts/nav/notifications_list" + %li.nav-item.dropdown + - unread_notifications = current_user.notifications.recent_unread.records + %a.nav-link.dropdown-toggle{title: 'Notifications Toggle', href: '#', role: 'button', data: {bs_toggle: 'dropdown'}, aria: {expanded: 'false'}} + %i.bi.bi-envelope-fill + %span.badge.bg-secondary= unread_notifications.length if unread_notifications.any? + + %ul.dropdown-menu.dropdown-menu-end + - if unread_notifications.any? + - unread_notifications.each do |notification| + %li + = link_to notification_path(notification), class: 'dropdown-item' do + %i.bi.bi-exclamation + %span= notification.short_message + %li + %hr.dropdown-divider + %li + = link_to mark_all_as_read_notifications_path, data: {turbo: true, turbo_method: :post}, class: 'dropdown-item text-primary' do + %i.bi.bi-check + Mark all as read + %li + = link_to notifications_path, class: 'dropdown-item' do + %i.bi.bi-eye + %span + = (more_unread_count = current_user.notifications.more_unread_count) > 0 ? "#{more_unread_count} More Unread" : "View all notifications" = render partial: "layouts/nav/user_dropdown" diff --git a/app/views/layouts/nav/_notifications_list.html.haml b/app/views/layouts/nav/_notifications_list.html.haml deleted file mode 100644 index 141419e69..000000000 --- a/app/views/layouts/nav/_notifications_list.html.haml +++ /dev/null @@ -1,24 +0,0 @@ -%li.nav-item.dropdown - - unread_notifications = current_user.notifications.recent_unread.records - %a.nav-link.dropdown-toggle{title: 'Notifications Toggle', href: '#', role: 'button', data: {bs_toggle: 'dropdown'}, aria: {expanded: 'false'}} - %i.bi.bi-envelope-fill - %span.badge.bg-secondary= unread_notifications.length if unread_notifications.any? - - %ul.dropdown-menu.dropdown-menu-end - - if unread_notifications.any? - - unread_notifications.each do |notification| - %li - = link_to notification_path(notification), class: 'dropdown-item' do - %i.bi.bi-exclamation - %span= notification.short_message - %li - %hr.dropdown-divider - %li - = link_to mark_all_as_read_notifications_path, data: {turbo: true, turbo_method: :post}, class: 'dropdown-item text-primary' do - %i.bi.bi-check - Mark all as read - %li - = link_to notifications_path, class: 'dropdown-item' do - %i.bi.bi-eye - %span - = (more_unread_count = current_user.notifications.more_unread_count) > 0 ? "#{more_unread_count} More Unread" : "View all notifications" From b0eb24415b9824a0037dc8a97a33acd1b2866a7f Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sat, 27 Dec 2025 02:20:16 +0900 Subject: [PATCH 4/8] Activate :notifications nav_item --- app/helpers/navbar_helper.rb | 3 ++- app/views/layouts/_navbar.html.haml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/navbar_helper.rb b/app/helpers/navbar_helper.rb index 6956a344e..0701e996e 100644 --- a/app/helpers/navbar_helper.rb +++ b/app/helpers/navbar_helper.rb @@ -39,7 +39,8 @@ def path_for(*args) admin: { admin_users: ->(p) { p == path_for(:admin, User) }, admin_events: ->(p) { p == path_for(:admin, Event) } - } + }, + notifications: ->(p) { p == path_for(Notification) } }.freeze private diff --git a/app/views/layouts/_navbar.html.haml b/app/views/layouts/_navbar.html.haml index 185b3e88e..6aa1ec85b 100644 --- a/app/views/layouts/_navbar.html.haml +++ b/app/views/layouts/_navbar.html.haml @@ -60,7 +60,7 @@ %i.bi.bi-calendar %span Events - %li.nav-item.dropdown + %li.nav-item.dropdown{class: nav_item_class(:notifications)} - unread_notifications = current_user.notifications.recent_unread.records %a.nav-link.dropdown-toggle{title: 'Notifications Toggle', href: '#', role: 'button', data: {bs_toggle: 'dropdown'}, aria: {expanded: 'false'}} %i.bi.bi-envelope-fill From f05f07f5d9311316160557b18b19c5cb67c71ac1 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sat, 27 Dec 2025 02:39:34 +0900 Subject: [PATCH 5/8] Inline user_dropdown nav --- app/views/layouts/_navbar.html.haml | 19 ++++++++++++++++++- .../layouts/nav/_user_dropdown.html.haml | 18 ------------------ 2 files changed, 18 insertions(+), 19 deletions(-) delete mode 100644 app/views/layouts/nav/_user_dropdown.html.haml diff --git a/app/views/layouts/_navbar.html.haml b/app/views/layouts/_navbar.html.haml index 6aa1ec85b..79aa208d3 100644 --- a/app/views/layouts/_navbar.html.haml +++ b/app/views/layouts/_navbar.html.haml @@ -85,7 +85,24 @@ %span = (more_unread_count = current_user.notifications.more_unread_count) > 0 ? "#{more_unread_count} More Unread" : "View all notifications" - = render partial: "layouts/nav/user_dropdown" + %li.nav-item.dropdown + %a.nav-link.dropdown-toggle.gravatar-container{href: '#', role: 'button', data: {bs_toggle: 'dropdown'}, aria: {expanded: 'false'}} + = image_tag("https://www.gravatar.com/avatar/#{current_user.gravatar_hash}?s=25", class: 'user-dropdown-gravatar', alt: '') +   #{current_user.name} + %ul.dropdown-menu.dropdown-menu-end + %li + = link_to edit_profile_path, class: 'dropdown-item' do + %i.bi.bi-person-fill + %span My Profile + - if current_user.teammates.loaded? ? current_user.teammates.any? : current_user.teammates.exists? + %li + = link_to notifications_profile_path, class: 'dropdown-item' do + %i.bi.bi-bell-fill + %span Notifications + %li + = link_to destroy_user_session_path, data: {turbo: true, turbo_method: :delete}, class: 'dropdown-item' do + %i.bi.bi-box-arrow-right + %span Sign Out - else %ul.navbar-nav.ms-auto diff --git a/app/views/layouts/nav/_user_dropdown.html.haml b/app/views/layouts/nav/_user_dropdown.html.haml deleted file mode 100644 index edf20995a..000000000 --- a/app/views/layouts/nav/_user_dropdown.html.haml +++ /dev/null @@ -1,18 +0,0 @@ -%li.nav-item.dropdown - %a.nav-link.dropdown-toggle.gravatar-container{href: '#', role: 'button', data: {bs_toggle: 'dropdown'}, aria: {expanded: 'false'}} - = image_tag("https://www.gravatar.com/avatar/#{current_user.gravatar_hash}?s=25", class: 'user-dropdown-gravatar', alt: '') -   #{current_user.name} - %ul.dropdown-menu.dropdown-menu-end - %li - = link_to edit_profile_path, class: 'dropdown-item' do - %i.bi.bi-person-fill - %span My Profile - - if current_user.teammates.loaded? ? current_user.teammates.any? : current_user.teammates.exists? - %li - = link_to notifications_profile_path, class: 'dropdown-item' do - %i.bi.bi-bell-fill - %span Notifications - %li - = link_to destroy_user_session_path, data: {turbo: true, turbo_method: :delete}, class: 'dropdown-item' do - %i.bi.bi-box-arrow-right - %span Sign Out From ffb089b39fcd70c3af212288753b7704a7363cd5 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sat, 27 Dec 2025 02:46:42 +0900 Subject: [PATCH 6/8] Activate :user nav_item --- app/helpers/navbar_helper.rb | 7 ++++++- app/views/layouts/_navbar.html.haml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/helpers/navbar_helper.rb b/app/helpers/navbar_helper.rb index 0701e996e..2c66c81e0 100644 --- a/app/helpers/navbar_helper.rb +++ b/app/helpers/navbar_helper.rb @@ -40,7 +40,12 @@ def path_for(*args) admin_users: ->(p) { p == path_for(:admin, User) }, admin_events: ->(p) { p == path_for(:admin, Event) } }, - notifications: ->(p) { p == path_for(Notification) } + notifications: ->(p) { p == path_for(Notification) }, + user: { + edit_profile: ->(p) { p == path_for(:edit, :profile) }, + merge_profile: ->(p) { p == path_for(:merge, :profile) }, + admin_events: ->(p) { p == path_for(:notifications, :profile) } + }, }.freeze private diff --git a/app/views/layouts/_navbar.html.haml b/app/views/layouts/_navbar.html.haml index 79aa208d3..2929f93c3 100644 --- a/app/views/layouts/_navbar.html.haml +++ b/app/views/layouts/_navbar.html.haml @@ -85,7 +85,7 @@ %span = (more_unread_count = current_user.notifications.more_unread_count) > 0 ? "#{more_unread_count} More Unread" : "View all notifications" - %li.nav-item.dropdown + %li.nav-item.dropdown{class: nav_item_class(:user)} %a.nav-link.dropdown-toggle.gravatar-container{href: '#', role: 'button', data: {bs_toggle: 'dropdown'}, aria: {expanded: 'false'}} = image_tag("https://www.gravatar.com/avatar/#{current_user.gravatar_hash}?s=25", class: 'user-dropdown-gravatar', alt: '')   #{current_user.name} From 3e45c874af3f88ad8fac9f3729d7cbc2e8336950 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sat, 27 Dec 2025 04:37:21 +0900 Subject: [PATCH 7/8] current_event may not exist, and so url_helper may fail --- app/helpers/navbar_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/navbar_helper.rb b/app/helpers/navbar_helper.rb index 2c66c81e0..85d0886dd 100644 --- a/app/helpers/navbar_helper.rb +++ b/app/helpers/navbar_helper.rb @@ -55,10 +55,10 @@ def nav_item_class(key) NAV_ITEM_MAP.find do |nav_key, nav_val| case nav_val when Proc - @active_nav_key = nav_key if instance_exec(request.path, &nav_val) + @active_nav_key = nav_key if instance_exec(request.path, &nav_val) rescue nil when Hash nav_val.find do |subnav_key, subnav_val| - @active_nav_key, @active_subnav_key = nav_key, subnav_key if instance_exec(request.path, &subnav_val) + @active_nav_key, @active_subnav_key = nav_key, subnav_key if instance_exec(request.path, &subnav_val) rescue nil end end end From 6e4911a13fa8b0d4c0618cd485c7811fb19d7b2e Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sat, 27 Dec 2025 03:09:03 +0900 Subject: [PATCH 8/8] Replace the negative margin hack with flexbox alignment This properly centers the gravatar vertically within the nav-link without causing the element to be displaced, so the active state background will now display at the same height as other nav items. --- app/assets/stylesheets/modules/navbar.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/modules/navbar.css b/app/assets/stylesheets/modules/navbar.css index c23e7d7aa..6cc7cd12c 100644 --- a/app/assets/stylesheets/modules/navbar.css +++ b/app/assets/stylesheets/modules/navbar.css @@ -1,5 +1,6 @@ .dropdown-toggle.gravatar-container { - margin-bottom: -5px; + display: flex; + align-items: center; } .navbar-nav {