Files
grecia/app/components/layout/notification_item_component.rb
Javi Martín 4c289f2489 Simplify notification item HTML
Other than simplifying the view, we can write tests using `click_link`,
which makes the tests more robust. Clicking the `.icon-notification`
element was causing some tests to fail when defining a window height of
750 pixels in the `admin_budgets` branch.
2021-02-16 23:21:51 +01:00

30 lines
607 B
Ruby

class Layout::NotificationItemComponent < ApplicationComponent
attr_reader :user
def initialize(user)
@user = user
end
private
def text
if unread_notifications?
t("layouts.header.notification_item.new_notifications", count: user.notifications_count)
else
t("layouts.header.notification_item.no_notifications")
end
end
def notifications_class
if unread_notifications?
"unread-notifications"
else
"no-notifications"
end
end
def unread_notifications?
user.notifications.unread.count > 0
end
end