Skip to content

Commit

Permalink
Properly support match_path when importing menu items
Browse files Browse the repository at this point in the history
  • Loading branch information
elia committed Nov 30, 2023
1 parent db06f7b commit 124d5bb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion admin/lib/solidus_admin/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,15 @@ def import_menu_items_from_backend!
raise ArgumentError, "Unknown url type #{item.url.class}"
end

match_path =
case item.match_path
when Regexp then -> { _1 =~ item.match_path }
when Proc then item.match_path
when String then -> { _1.start_with?("/admin#{item.match_path}") }
when nil then -> { _1.start_with?(route.call) }
else raise ArgumentError, "Unknown match_path type #{item.match_path.class}"
end

icon =
case item.icon
when /^ri-/
Expand All @@ -214,7 +223,8 @@ def import_menu_items_from_backend!
key: item.label,
icon: icon,
route: route,
children: item.children.map.with_index(&menu_item_to_hash)
children: item.children.map.with_index(&menu_item_to_hash),
match_path: match_path,
}
end

Expand Down

0 comments on commit 124d5bb

Please sign in to comment.