-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5309 from solidusio/elia/menu-items-cleanup
[Backend] cleanup `MenuItems` generation
- Loading branch information
Showing
13 changed files
with
410 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 7 additions & 5 deletions
12
backend/app/views/spree/admin/shared/_product_sub_menu.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
<% Spree::Deprecation.warn "Using the #{@virtual_path.inspect} partial is deprecated, please use MenuItem#children instead." %> | ||
|
||
<ul class="admin-subnav" data-hook="admin_product_sub_tabs"> | ||
<% if can? :admin, Spree::Product %> | ||
<%= tab :products, match_path: '/products' %> | ||
<%= tab label: :products, match_path: '/products' %> | ||
<% end %> | ||
<% if can? :admin, Spree::OptionType %> | ||
<%= tab :option_types, match_path: '/option_types' %> | ||
<%= tab label: :option_types, match_path: '/option_types' %> | ||
<% end %> | ||
<% if can? :admin, Spree::Property %> | ||
<%= tab :properties %> | ||
<%= tab label: :properties %> | ||
<% end %> | ||
<% if can? :admin, Spree::Taxonomy %> | ||
<%= tab :taxonomies %> | ||
<%= tab label: :taxonomies %> | ||
<% end %> | ||
<% if can? :admin, Spree::Taxon %> | ||
<%= tab :taxons, label: :display_order, match_path: '/taxons' %> | ||
<%= tab url: spree.admin_taxons_path, label: :display_order, match_path: '/taxons' %> | ||
<% end %> | ||
</ul> |
6 changes: 4 additions & 2 deletions
6
backend/app/views/spree/admin/shared/_promotion_sub_menu.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
<% Spree::Deprecation.warn "Using the #{@virtual_path.inspect} partial is deprecated, please use MenuItem#children instead." %> | ||
|
||
<ul class="admin-subnav" data-hook="admin_promotion_sub_tabs"> | ||
<% if can? :admin, Spree::Promotion %> | ||
<%= tab :promotions %> | ||
<%= tab label: :promotions %> | ||
<% end %> | ||
<% if can? :admin, Spree::PromotionCategory %> | ||
<%= tab :promotion_categories %> | ||
<%= tab label: :promotion_categories %> | ||
<% end %> | ||
</ul> |
14 changes: 8 additions & 6 deletions
14
backend/app/views/spree/admin/shared/_settings_sub_menu.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
<% Spree::Deprecation.warn "Using the #{@virtual_path.inspect} partial is deprecated, please use MenuItem#children instead." %> | ||
|
||
<ul class="admin-subnav" data-hook="admin_settings_sub_tabs"> | ||
<% if can?(:admin, Spree::Store) %> | ||
<%= tab :stores, label: :stores, url: spree.admin_stores_path %> | ||
<%= tab label: :stores, url: spree.admin_stores_path %> | ||
<% end %> | ||
|
||
<% if can?(:admin, Spree::PaymentMethod) %> | ||
<%= tab :payments, url: spree.admin_payment_methods_path %> | ||
<%= tab label: :payments, url: spree.admin_payment_methods_path %> | ||
<% end %> | ||
|
||
<% if can?(:admin, Spree::TaxCategory) || can?(:admin, Spree::TaxRate) %> | ||
<%= tab :taxes, url: spree.admin_tax_categories_path, match_path: %r(tax_categories|tax_rates) %> | ||
<%= tab label: :taxes, url: spree.admin_tax_categories_path, match_path: %r(tax_categories|tax_rates) %> | ||
<% end %> | ||
|
||
<% if can?(:admin, Spree::RefundReason) || can?(:admin, Spree::ReimbursementType) || | ||
can?(:show, Spree::ReturnReason) || can?(:show, Spree::AdjustmentReason) %> | ||
<%= tab :checkout, url: spree.admin_refund_reasons_path, match_path: %r(refund_reasons|reimbursement_types|return_reasons|adjustment_reasons|store_credit_reasons) %> | ||
<%= tab label: :checkout, url: spree.admin_refund_reasons_path, match_path: %r(refund_reasons|reimbursement_types|return_reasons|adjustment_reasons|store_credit_reasons) %> | ||
<% end %> | ||
|
||
<% if can?(:admin, Spree::ShippingMethod) || can?(:admin, Spree::ShippingCategory) || can?(:admin, Spree::StockLocation) %> | ||
<%= tab :shipping, url: spree.admin_shipping_methods_path, match_path: %r(shipping_methods|shipping_categories|stock_locations) %> | ||
<%= tab label: :shipping, url: spree.admin_shipping_methods_path, match_path: %r(shipping_methods|shipping_categories|stock_locations) %> | ||
<% end %> | ||
|
||
<% if can?(:admin, Spree::Zone) %> | ||
<%= tab :zones, url: spree.admin_zones_path %> | ||
<%= tab label: :zones, url: spree.admin_zones_path %> | ||
<% end %> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,27 @@ | ||
<% Spree::Backend::Config.menu_items.sort_by { |item| item.position || Float::INFINITY }.each do |menu_item| %> | ||
<% if instance_exec(&menu_item.condition) %> | ||
<% Spree::Backend::Config.menu_items.each do |menu_item| %> | ||
<% if menu_item.render_in?(self) %> | ||
<%= | ||
tab( | ||
*menu_item.sections, | ||
icon: menu_item.icon, | ||
label: menu_item.label, | ||
url: menu_item.url.is_a?(Symbol) ? spree.public_send(menu_item.url) : menu_item.url, | ||
match_path: menu_item.match_path, | ||
url: menu_item.url, | ||
selected: menu_item.match_path?(request) || menu_item.children.any? { _1.match_path?(request) }, | ||
) do | ||
%> | ||
<%- render partial: menu_item.partial if menu_item.partial %> | ||
<% if menu_item.render_partial? %> | ||
<%- render partial: menu_item.partial %> | ||
<% elsif menu_item.children.present? %> | ||
<ul class="admin-subnav" data-hook="<%= menu_item.data_hook %>"> | ||
<%- menu_item.children.each do |child| %> | ||
<%= tab( | ||
icon: child.icon, | ||
label: child.label, | ||
url: child.url, | ||
selected: child.match_path?(request), | ||
) if child.render_in?(self) %> | ||
<% end %> | ||
</ul> | ||
<% end %> | ||
<%- end %> | ||
<% end %> | ||
<% end %> |
Oops, something went wrong.