SUSE/hackweek

View on GitHub
app/views/layouts/_notification_tab.html.haml

Summary

Maintainability
Test Coverage
%ul.navbar-notifications.nav.navbar-nav.navbar-right.hidden-xs
  %li.dropdown
    - if @notifications.any?
      = link_to mark_as_read_notifications_path(), id: 'notification-dropdown-activator', method: :post, data: { 'toggle': 'dropdown', 'behavior': 'notifications' }, remote: true do
        %i.fa.fa-bell
        %span#notification-count.new.badge
          = @notifications.length
        %b.caret
    - else
      %a.dropdown-toggle.nav-link{ 'data-toggle': 'dropdown', href: '#', id: 'notification-dropdown-activator', 'data-behavior': 'notifications' }
        %i.fa.fa-bell
        %span#notification-count.new.badge
        %b.caret
    .dropdown-menu
      %h5 Notifications
      %hr
      %ul#notification-dropdown
        -if @notifications.any?
          - @notifications.each do |notification|
            %li{ 'data-behavior':'notifications-link' }
              = link_to project_path(notification.notifiable) do
                - if notification.notifiable.avatar.attached?
                  = image_tag url_for(notification.notifiable.avatar)
                %p
                  #{notification.actor.name} #{notification.action}
            %hr
        - else
          %li.dropdown-item{ 'data-behavior': 'notifications-link' } No New Notifications
        = link_to notifications_path do
          %li{ 'data-behavior': 'notifications-link' } Older Notification