Skip to content

Commit

Permalink
Add submenus for menu hacks
Browse files Browse the repository at this point in the history
  • Loading branch information
entantoencuanto committed Dec 4, 2023
1 parent 9433930 commit 9b55a36
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/decidim/decidim_awesome/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class Engine < ::Rails::Engine
end

initializer "decidim_decidim_awesome.awesome_admin_menu" do
Decidim::DecidimAwesome::Menu.register_menu_hacks_submenu!
Decidim::DecidimAwesome::Menu.register_awesome_admin_menu!
end
end
Expand Down
25 changes: 22 additions & 3 deletions lib/decidim/decidim_awesome/menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ def self.register_awesome_admin_menu!

menu.add_item :menu_hacks,
I18n.t("menu.menu_hacks", scope: "decidim.decidim_awesome.admin"),
decidim_admin_decidim_awesome.menu_hacks_path,
decidim_admin_decidim_awesome.menu_hacks_path(menus[:menu_hacks_menu] ? :menu : :home_content_block_menu),
position: 7,
icon_name: "menu-line",
if: menus[:menu_hacks]
if: menus[:menu_hacks],
submenu: { target_menu: :menu_hacks_submenu }

menu.add_item :custom_redirects,
I18n.t("menu.custom_redirects", scope: "decidim.decidim_awesome.admin"),
Expand All @@ -76,6 +77,22 @@ def self.register_awesome_admin_menu!
end
end

def self.register_menu_hacks_submenu!
Decidim.menu :menu_hacks_submenu do |menu|
menu.add_item :main_menu,
I18n.t("menu.title", scope: "decidim.decidim_awesome.admin.menu_hacks.index"),
decidim_admin_decidim_awesome.menu_hacks_path(:menu),
position: 7.1,
if: menus[:menu_hacks_menu]

menu.add_item :main_menu,
I18n.t("home_content_block_menu.title", scope: "decidim.decidim_awesome.admin.menu_hacks.index"),
decidim_admin_decidim_awesome.menu_hacks_path(:home_content_block_menu),
position: 7.2,
if: menus[:menu_hacks_home_content_block_menu]
end
end

def self.menus
@menus ||= {
editors: config_enabled?([:allow_images_in_full_editor, :allow_images_in_small_editor, :use_markdown_editor, :allow_images_in_markdown_editor]),
Expand All @@ -92,7 +109,9 @@ def self.menus
styles: config_enabled?(:scoped_styles),
proposal_custom_fields: config_enabled?(:proposal_custom_fields),
admins: config_enabled?(:scoped_admins),
menu_hacks: config_enabled?(:menu),
menu_hacks: config_enabled?([:menu, :home_content_block_menu]),
menu_hacks_menu: config_enabled?(:menu),
menu_hacks_home_content_block_menu: config_enabled?(:home_content_block_menu),
custom_redirects: config_enabled?(:custom_redirects),
livechat: config_enabled?([:intergram_for_admins, :intergram_for_public])
}
Expand Down

0 comments on commit 9b55a36

Please sign in to comment.