Files
grecia/app/components/layout/admin_login_items_component.rb
taitus a5911f5c6a Modify admin layout to only manage tenants and admins
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.
2024-11-06 11:17:53 +01:00

50 lines
1.3 KiB
Ruby

class Layout::AdminLoginItemsComponent < ApplicationComponent
attr_reader :user
use_helpers :link_list, :show_admin_menu?
def initialize(user)
@user = user
end
def render?
show_admin_menu?(user) && !Rails.application.multitenancy_management_mode?
end
private
def admin_links
[
(admin_link if user.administrator?),
(moderation_link if user.administrator? || user.moderator?),
(valuation_link if feature?(:budgets) && (user.administrator? || user.valuator?)),
(management_link if user.administrator? || user.manager?),
(officing_link if user.poll_officer?),
(sdg_management_link if feature?(:sdg) && (user.administrator? || user.sdg_manager?))
]
end
def admin_link
[t("layouts.header.administration"), admin_root_path]
end
def moderation_link
[t("layouts.header.moderation"), moderation_root_path]
end
def valuation_link
[t("layouts.header.valuation"), valuation_root_path]
end
def management_link
[t("layouts.header.management"), management_sign_in_path]
end
def officing_link
[t("layouts.header.officing"), officing_root_path]
end
def sdg_management_link
[t("sdg_management.header.title"), sdg_management_root_path]
end
end