We only want to render the account link and login items in the header. And we want only render the Multitenancy and Administrators sections in the admin sidebar. We include the administrators management so it's possible to give permissions to other users to manage tenants. In order to restrict access to other sections by typing the URL or following a link, we're only enabling the rest of the routes when we aren't in the multitenancy management mode.
30 lines
581 B
Ruby
30 lines
581 B
Ruby
class Layout::NotificationItemComponent < ApplicationComponent
|
|
attr_reader :user
|
|
|
|
def initialize(user)
|
|
@user = user
|
|
end
|
|
|
|
def render?
|
|
user.present? && !Rails.application.multitenancy_management_mode?
|
|
end
|
|
|
|
private
|
|
|
|
def text
|
|
t("layouts.header.notification_item.new_notifications", count: unread_notifications.count)
|
|
end
|
|
|
|
def notifications_class
|
|
if unread_notifications.count > 0
|
|
"unread-notifications"
|
|
else
|
|
"no-notifications"
|
|
end
|
|
end
|
|
|
|
def unread_notifications
|
|
user.notifications.unread
|
|
end
|
|
end
|