Skip to content

Commit

Permalink
Add Metadecidim menu in breadcrumb and footer (#122)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
andreslucena authored Dec 18, 2023
1 parent c19d6ab commit 3ca2eae
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 11 deletions.
76 changes: 68 additions & 8 deletions config/initializers/metadecidim_menu.rb
Original file line number Diff line number Diff line change
@@ -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"),
Expand Down Expand Up @@ -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,
Expand All @@ -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
2 changes: 1 addition & 1 deletion config/locales/ca.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
2 changes: 1 addition & 1 deletion config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
50 changes: 49 additions & 1 deletion spec/features/menu_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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

0 comments on commit 3ca2eae

Please sign in to comment.