Extract methods to render management menu links

So this is similar to what we're doing in the `Admin::MenuComponent`
class.
This commit is contained in:
Javi Martín
2024-04-11 23:06:28 +02:00
parent 37bc39e1c6
commit 6da2d98b78
2 changed files with 37 additions and 19 deletions

View File

@@ -1,6 +1,15 @@
class Management::MenuComponent < ApplicationComponent
use_helpers :managed_user, :link_list
def links
[
user_links,
(print_investments_link if Setting["process.budgets"]),
print_proposals_link,
user_invites_link
]
end
private
def user_links
@@ -73,6 +82,33 @@ class Management::MenuComponent < ApplicationComponent
]
end
def print_investments_link
[
t("management.menu.print_budget_investments"),
print_investments_management_budgets_path,
print_investments?,
class: "print-investments-link"
]
end
def print_proposals_link
[
t("management.menu.print_proposals"),
print_management_proposals_path,
print_proposals?,
class: "print-proposals-link"
]
end
def user_invites_link
[
t("management.menu.user_invites"),
new_management_user_invite_path,
user_invites?,
class: "invitations-link"
]
end
def users?
["users", "email_verifications", "document_verifications"].include?(controller_name)
end