From 3ca2eae5f6f47fdd777d425a26e36f6dcd6c1673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Pereira=20de=20Lucena?= Date: Mon, 18 Dec 2023 08:53:03 +0100 Subject: [PATCH] Add Metadecidim menu in breadcrumb and footer (#122) * Add Metadecidim menu in breadcrumb and footer * Remove Home link in the home content block menu * Fix missing translations in the 'Start here' link * Add specs * Remove Meetings from the footer and the breadcrumb menu It's already there in the two cases * Lock ChromeDriver to 119.0.6045.105 --- config/initializers/metadecidim_menu.rb | 76 ++++++++++++++++++++++--- config/locales/ca.yml | 2 +- config/locales/es.yml | 2 +- spec/features/menu_spec.rb | 50 +++++++++++++++- 4 files changed, 119 insertions(+), 11 deletions(-) diff --git a/config/initializers/metadecidim_menu.rb b/config/initializers/metadecidim_menu.rb index b7085b4..5b34186 100644 --- a/config/initializers/metadecidim_menu.rb +++ b/config/initializers/metadecidim_menu.rb @@ -1,12 +1,6 @@ # frozen_string_literal: true -Decidim.menu :metadecidim_menu do |menu| - menu.add_item :root, - I18n.t("menu.home", scope: "decidim"), - decidim.root_path, - position: 1, - active: :exclusive - +Decidim.menu :metadecidim_home_content_block_menu do |menu| start_here_path = Decidim::ParticipatoryProcesses::Engine.routes.url_helpers.participatory_process_path("Welcome") menu.add_item :start_here, I18n.t("menu.start_here", scope: "decidim"), @@ -50,11 +44,54 @@ active: :false end +Decidim.menu :metadecidim_menu do |menu| + menu.add_item :root, + I18n.t("menu.home", scope: "decidim"), + decidim.root_path, + position: 1, + active: :exclusive + + start_here_path = Decidim::ParticipatoryProcesses::Engine.routes.url_helpers.participatory_process_path("Welcome") + menu.add_item :start_here, + I18n.t("menu.start_here", scope: "decidim"), + start_here_path, + position: 10, + active: :inclusive + + participate_path = Decidim::ParticipatoryProcesses::Engine.routes.url_helpers.participatory_process_group_path(76) + menu.add_item :participate, + I18n.t("menu.participate", scope: "decidim"), + participate_path, + position: 20, + active: :inclusive + + governance_path = Decidim::Assemblies::Engine.routes.url_helpers.assembly_path("our-governance") + menu.add_item :governance, + I18n.t("menu.governance", scope: "decidim"), + governance_path, + position: 40, + active: :inclusive + + news_path = Decidim::ParticipatoryProcesses::Engine.routes.url_helpers.decidim_participatory_process_blogs_path("news", 1719) + menu.add_item :news, + I18n.t("menu.news", scope: "decidim"), + news_path, + position: 50, + active: :inclusive + + chat_url = "http://chat.decidim.org" + menu.add_item :chat, + I18n.t("menu.chat", scope: "decidim"), + chat_url, + position: 60, + active: :false +end + # Monkey patch MenuHelper to have a custom menu Rails.application.config.to_prepare do Decidim::MenuHelper.module_eval do def home_content_block_menu - menu_name = current_organization.name == "Metadecidim" ? :metadecidim_menu : :home_content_block_menu + menu_name = current_organization.name == "Metadecidim" ? :metadecidim_home_content_block_menu : :home_content_block_menu @home_content_block_menu ||= ::Decidim::MenuPresenter.new( menu_name, @@ -64,5 +101,28 @@ def home_content_block_menu label: t("layouts.decidim.header.main_menu") ) end + + def breadcrumb_root_menu + menu_name = current_organization.name == "Metadecidim" ? :metadecidim_menu : :menu + + @breadcrumb_root_menu ||= ::Decidim::BreadcrumbRootMenuPresenter.new( + menu_name, + self, + container_options: { class: "menu-bar__main-dropdown__menu" } + ) + end + + def footer_menu + menu_name = current_organization.name == "Metadecidim" ? :metadecidim_menu : :menu + + @footer_menu ||= ::Decidim::FooterMenuPresenter.new( + menu_name, + self, + element_class: "font-semibold underline", + active_class: "is-active", + container_options: { class: "space-y-4 break-inside-avoid" }, + label: t("layouts.decidim.footer.decidim_title") + ) + end end end diff --git a/config/locales/ca.yml b/config/locales/ca.yml index a9811af..77e7db8 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -7,6 +7,6 @@ ca: meetings: Trobades news: Notícies participate: Participa - welcome: Benvinguda + start_here: Comença aquí sms: text: "El teu codi per verificar-te a Metadecidim és: %{code}" diff --git a/config/locales/es.yml b/config/locales/es.yml index 26a7fbf..4d85159 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -7,6 +7,6 @@ es: meetings: Encuentros news: Noticias participate: Participa - welcome: Bienvenida + start_here: Comienza aquí sms: text: "Tu código para verificarte en Metadecidim es: %{code}" diff --git a/spec/features/menu_spec.rb b/spec/features/menu_spec.rb index e226203..e9c7b89 100644 --- a/spec/features/menu_spec.rb +++ b/spec/features/menu_spec.rb @@ -38,7 +38,6 @@ visit decidim.root_path within "#home__menu" do - expect(page).to have_content("Home") expect(page).to have_content("Start here") expect(page).to have_content("Participate") expect(page).to have_content("Meetings") @@ -47,5 +46,54 @@ expect(page).to have_content("Chat") end end + + it "the footer menu has the Metadecidim elements" do + visit decidim.root_path + + within ".main-footer" do + expect(page).to have_content("Home") + expect(page).to have_content("Start here") + expect(page).to have_content("Participate") + expect(page).to have_content("Our governance") + expect(page).to have_content("News") + expect(page).to have_content("Chat") + end + end + + it "the breadcrumb menu has the Metadecidim elements" do + visit decidim.pages_path + + find("a.menu-bar__breadcrumb-desktop__dropdown-trigger").sibling("button[data-component='dropdown']").hover + + within "#breadcrumb-main-dropdown-desktop" do + expect(page).to have_content("Home") + expect(page).to have_content("Start here") + expect(page).to have_content("Participate") + expect(page).to have_content("Our governance") + expect(page).to have_content("News") + expect(page).to have_content("Chat") + end + end + + context "with another locale" do + before do + visit decidim.root_path + + within_language_menu do + click_link "Català" + end + end + + specify "the menu is translated" do + within "#home__menu" do + expect(page).to have_content("Comença aquí") + expect(page).to have_content("Participa") + expect(page).to have_content("Trobades") + expect(page).to have_content("Com ens organitzem") + expect(page).to have_content("Notícies") + expect(page).to have_content("Xat") + end + end + end end end