diff --git a/backend/app/views/spree/admin/shared/_tabs.html.erb b/backend/app/views/spree/admin/shared/_tabs.html.erb index 8eb120a7590..fcb87e3d17e 100644 --- a/backend/app/views/spree/admin/shared/_tabs.html.erb +++ b/backend/app/views/spree/admin/shared/_tabs.html.erb @@ -1,4 +1,4 @@ -<% Spree::Backend::Config.menu_items.sort_by { |item| item.position || Float::INFINITY }.each do |menu_item| %> +<% Spree::Backend::Config.menu_items.each do |menu_item| %> <% if menu_item.render_in?(self) %> <%= tab( diff --git a/backend/lib/spree/backend_configuration.rb b/backend/lib/spree/backend_configuration.rb index 5983a25b070..82327787a6a 100644 --- a/backend/lib/spree/backend_configuration.rb +++ b/backend/lib/spree/backend_configuration.rb @@ -58,11 +58,6 @@ def theme_path(user_theme = nil) # # @!attribute menu_items # @return [Array] - # - # Positioning can be determined by setting the position attribute to - # an Integer or nil. Menu Items will be rendered with smaller lower values - # first and higher values last. A position value of nil will cause the menu - # item to be rendered at the end of the list. attr_writer :menu_items # Return the menu items which should be drawn in the menu @@ -86,14 +81,12 @@ def menu_items return_authorizations| shipments )}x, - position: 0 ), MenuItem.new( label: :products, icon: 'th-large', condition: -> { can?(:admin, Spree::Product) }, partial: 'spree/admin/shared/product_sub_menu', - position: 1, data_hook: :admin_product_sub_tabs, children: [ MenuItem.new( @@ -129,7 +122,6 @@ def menu_items condition: -> { can?(:admin, Spree::Promotion) }, url: :admin_promotions_path, data_hook: :admin_promotion_sub_tabs, - position: 2, children: [ MenuItem.new( label: :promotions, @@ -147,7 +139,6 @@ def menu_items match_path: %r{/(stock_items)}, condition: -> { can?(:admin, Spree::StockItem) }, url: :admin_stock_items_path, - position: 3, ), MenuItem.new( label: :users, @@ -155,7 +146,6 @@ def menu_items match_path: %r{/(users|store_credits)}, condition: -> { Spree.user_class && can?(:admin, Spree.user_class) }, url: :admin_users_path, - position: 4, ), MenuItem.new( label: :settings, @@ -164,7 +154,6 @@ def menu_items partial: 'spree/admin/shared/settings_sub_menu', condition: -> { can? :admin, Spree::Store }, url: :admin_stores_path, - position: 5, children: [ MenuItem.new( label: :stores, diff --git a/backend/lib/spree/backend_configuration/menu_item.rb b/backend/lib/spree/backend_configuration/menu_item.rb index 6f5f1184b7a..32fd6122df2 100644 --- a/backend/lib/spree/backend_configuration/menu_item.rb +++ b/backend/lib/spree/backend_configuration/menu_item.rb @@ -11,7 +11,9 @@ def sections # rubocop:disable Style/TrivialAccessors end deprecate sections: :label, deprecator: Spree::Deprecation - attr_accessor :position + attr_accessor :position # rubocop:disable Layout/EmptyLinesAroundAttributeAccessor + deprecate position: nil, deprecator: Spree::Deprecation + deprecate "position=": nil, deprecator: Spree::Deprecation # @param icon [String] The icon to draw for this menu item # @param condition [Proc] A proc which returns true if this menu item @@ -21,8 +23,6 @@ def sections # rubocop:disable Style/TrivialAccessors # menu item. # @param children [Array] An array # @param url [String|Symbol] A url where this link should send the user to or a Symbol representing a route name - # @param position [Integer] The position in which the menu item should render - # nil will cause the item to render last # @param match_path [String, Regexp, callable] (nil) If the {url} to determine the active tab is ambigous # you can pass a String, Regexp or callable to identify this menu item. The callable # accepts a request object and returns a Boolean value. @@ -60,9 +60,10 @@ def initialize( @partial = partial @children = children @url = url - @position = position @data_hook = data_hook @match_path = match_path + + self.position = position if position # Use the setter to deprecate end def render_in?(view_context)