Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/assets/stylesheets/modules/navbar.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.dropdown-toggle.gravatar-container {
margin-bottom: -5px;
display: flex;
align-items: center;
}

.navbar-nav {
Expand Down
16 changes: 13 additions & 3 deletions app/helpers/navbar_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
61 changes: 56 additions & 5 deletions app/views/layouts/_navbar.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 0 additions & 12 deletions app/views/layouts/nav/_admin_nav.html.haml

This file was deleted.

24 changes: 0 additions & 24 deletions app/views/layouts/nav/_notifications_list.html.haml

This file was deleted.

18 changes: 0 additions & 18 deletions app/views/layouts/nav/_user_dropdown.html.haml

This file was deleted.