diff --git a/app/components/admin/menu_component.html.erb b/app/components/admin/menu_component.html.erb index 8e70d9cb7..5b4a80597 100644 --- a/app/components/admin/menu_component.html.erb +++ b/app/components/admin/menu_component.html.erb @@ -1,135 +1 @@ - +<%= link_list(*links, id: "admin_menu", data: { "accordion-menu": true, "multi-open": true }) %> diff --git a/app/components/admin/menu_component.rb b/app/components/admin/menu_component.rb index 9fc4c5319..d14fcbb1c 100644 --- a/app/components/admin/menu_component.rb +++ b/app/components/admin/menu_component.rb @@ -2,6 +2,27 @@ class Admin::MenuComponent < ApplicationComponent include LinkListHelper delegate :can?, to: :helpers + def links + [ + (proposals_link if feature?(:proposals)), + (debates_link if feature?(:debates)), + comments_link, + (polls_link if feature?(:polls)), + (legislation_link if feature?(:legislation)), + (budgets_link if feature?(:budgets)), + booths_links, + (signature_sheets_link if feature?(:signature_sheets)), + messages_links, + site_customization_links, + moderated_content_links, + profiles_links, + stats_link, + settings_links, + dashboard_links, + (machine_learning_link if ::MachineLearning.enabled?) + ] + end + private def moderated_content? @@ -77,6 +98,71 @@ class Admin::MenuComponent < ApplicationComponent controller_name == "managers" && controller.class.module_parent == Admin end + def proposals_link + [ + t("admin.menu.proposals"), + admin_proposals_path, + controller_name == "proposals", + class: "proposals-link" + ] + end + + def debates_link + [ + t("admin.menu.debates"), + admin_debates_path, + controller_name == "debates", + class: "debates-link" + ] + end + + def polls_link + [ + t("admin.menu.polls"), + admin_polls_path, + polls?, + class: "polls-link" + ] + end + + def comments_link + [ + t("admin.menu.comments"), + admin_comments_path, + controller_name == "comments", + class: "comments-link" + ] + end + + def legislation_link + [ + t("admin.menu.legislation"), + admin_legislation_processes_path, + controller.class.module_parent == Admin::Legislation, + class: "legislation-link" + ] + end + + def budgets_link + [ + t("admin.menu.budgets"), + admin_budgets_path, + budgets?, + class: "budgets-link" + ] + end + + def booths_links + link_to(t("admin.menu.title_booths"), "#", class: "booths-link") + + link_list( + officers_link, + booths_link, + booth_assignments_link, + shifts_link, + id: "booths_menu", class: ("is-active" if booths?) + ) + end + def officers_link [ t("admin.menu.poll_officers"), @@ -109,6 +195,26 @@ class Admin::MenuComponent < ApplicationComponent ] end + def signature_sheets_link + [ + t("admin.menu.signature_sheets"), + admin_signature_sheets_path, + controller_name == "signature_sheets", + class: "signature-sheets-link" + ] + end + + def messages_links + link_to(t("admin.menu.messaging_users"), "#", class: "messages-link") + + link_list( + newsletters_link, + admin_notifications_link, + system_emails_link, + emails_download_link, + id: "messaging_users_menu", class: ("is-active" if messages_menu_active?) + ) + end + def newsletters_link [ t("admin.menu.newsletters"), @@ -141,6 +247,18 @@ class Admin::MenuComponent < ApplicationComponent ] end + def site_customization_links + link_to(t("admin.menu.title_site_customization"), "#", class: "site-customization-link") + + link_list( + homepage_link, + pages_link, + banners_link, + information_texts_link, + documents_link, + class: ("is-active" if customization? && controller.class.module_parent != Admin::Poll::Questions::Answers) + ) + end + def homepage_link [ t("admin.menu.site_customization.homepage"), @@ -181,6 +299,20 @@ class Admin::MenuComponent < ApplicationComponent ] end + def moderated_content_links + link_to(t("admin.menu.title_moderated_content"), "#", class: "moderated-content-link") + + link_list( + (hidden_proposals_link if feature?(:proposals)), + (hidden_debates_link if feature?(:debates)), + (hidden_budget_investments_link if feature?(:budgets)), + hidden_comments_link, + hidden_proposal_notifications_link, + hidden_users_link, + activity_link, + class: ("is-active" if moderated_content?) + ) + end + def hidden_proposals_link [ t("admin.menu.hidden_proposals"), @@ -237,6 +369,21 @@ class Admin::MenuComponent < ApplicationComponent ] end + def profiles_links + link_to(t("admin.menu.title_profiles"), "#", class: "profiles-link") + + link_list( + administrators_link, + organizations_link, + officials_link, + moderators_link, + valuators_link, + managers_link, + (sdg_managers_link if feature?(:sdg)), + users_link, + class: ("is-active" if profiles?) + ) + end + def administrators_link [ t("admin.menu.administrators"), @@ -293,6 +440,29 @@ class Admin::MenuComponent < ApplicationComponent ] end + def stats_link + [ + t("admin.menu.stats"), + admin_stats_path, + controller_name == "stats", + class: "stats-link" + ] + end + + def settings_links + link_to(t("admin.menu.title_settings"), "#", class: "settings-link") + + link_list( + settings_link, + tenants_link, + tags_link, + geozones_link, + images_link, + content_blocks_link, + local_census_records_link, + class: ("is-active" if settings?) + ) + end + def settings_link [ t("admin.menu.settings"), @@ -351,6 +521,24 @@ class Admin::MenuComponent < ApplicationComponent ] end + def dashboard_links + link_to(t("admin.menu.dashboard"), "#", class: "dashboard-link") + + link_list( + dashboard_actions_link, + administrator_tasks_link, + class: ("is-active" if dashboard?) + ) + end + + def machine_learning_link + [ + t("admin.menu.machine_learning"), + admin_machine_learning_path, + controller_name == "machine_learning", + class: "ml-link" + ] + end + def administrator_tasks_link [ t("admin.menu.administrator_tasks"), diff --git a/spec/system/admin/budgets_wizard/groups_spec.rb b/spec/system/admin/budgets_wizard/groups_spec.rb index 47e8581ed..7611ba2b4 100644 --- a/spec/system/admin/budgets_wizard/groups_spec.rb +++ b/spec/system/admin/budgets_wizard/groups_spec.rb @@ -8,7 +8,7 @@ describe "Budgets wizard, groups step", :admin do visit admin_budgets_wizard_budget_groups_path(budget) within "#side_menu" do - expect(page).to have_css ".is-active", exact_text: "Participatory budgets" + expect(page).to have_css "[aria-current]", exact_text: "Participatory budgets" end expect(page).to have_content "Continue to headings" diff --git a/spec/system/admin/budgets_wizard/headings_spec.rb b/spec/system/admin/budgets_wizard/headings_spec.rb index 28d6c1657..de50af030 100644 --- a/spec/system/admin/budgets_wizard/headings_spec.rb +++ b/spec/system/admin/budgets_wizard/headings_spec.rb @@ -9,7 +9,7 @@ describe "Budgets wizard, headings step", :admin do visit admin_budgets_wizard_budget_group_headings_path(budget, group) within "#side_menu" do - expect(page).to have_css ".is-active", exact_text: "Participatory budgets" + expect(page).to have_css "[aria-current]", exact_text: "Participatory budgets" end click_link "Go back to groups" diff --git a/spec/system/admin/budgets_wizard/phases_spec.rb b/spec/system/admin/budgets_wizard/phases_spec.rb index c5a19fa5a..57c9e5eea 100644 --- a/spec/system/admin/budgets_wizard/phases_spec.rb +++ b/spec/system/admin/budgets_wizard/phases_spec.rb @@ -11,7 +11,7 @@ describe "Budgets wizard, phases step", :admin do visit admin_budgets_wizard_budget_budget_phases_path(budget) within "#side_menu" do - expect(page).to have_css ".is-active", exact_text: "Participatory budgets" + expect(page).to have_css "[aria-current]", exact_text: "Participatory budgets" end click_link "Go back to headings"