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 { diff --git a/app/helpers/navbar_helper.rb b/app/helpers/navbar_helper.rb index 07265d5c6..85d0886dd 100644 --- a/app/helpers/navbar_helper.rb +++ b/app/helpers/navbar_helper.rb @@ -35,7 +35,17 @@ 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) } + }, + 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 @@ -45,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 diff --git a/app/views/layouts/_navbar.html.haml b/app/views/layouts/_navbar.html.haml index 1d44ddc05..2929f93c3 100644 --- a/app/views/layouts/_navbar.html.haml +++ b/app/views/layouts/_navbar.html.haml @@ -47,11 +47,62 @@ %sup Beta - if admin_nav? - = render partial: "layouts/nav/admin_nav" - - = render partial: "layouts/nav/notifications_list" - - = render partial: "layouts/nav/user_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 + %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 + + %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 + %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" + + %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} + %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/_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 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" 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