Skip to content

Solidus Deprecation Warning for MenuItem: Passing sections to MenuItem is deprecated. Please pass a label instead. #294

@erwin

Description

@erwin

When starting Solidus with the solidus_subscriptions gem, we get a deprecation warning:

DEPRECATION WARNING: Passing sections to Spree::BackendConfiguration::MenuItem is deprecated. Please pass a label instead. (called from new at /home/erwin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/bundler/gems/solidus_subscriptions-1149f416b1be/lib/solidus_subscriptions/engine.rb:43)
DEPRECATION WARNING: Passing icon to Spree::BackendConfiguration::MenuItem is deprecated. Please use the keyword argument instead. (called from new at /home/erwin/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/bundler/gems/solidus_subscriptions-1149f416b1be/lib/solidus_subscriptions/engine.rb:43)

Looks like this comes from:

config.menu_items << config.class::MenuItem.new(

Per the Solidus documentation, seems the format has changed to:

https://guides.solidus.io/customization/customizing-the-backend#adding-new-menu-items

  # ...
  config.menu_items << config.class::MenuItem.new(
    label: :rejected_orders,
    icon: 'ban',
    url: '/admin/orders?q[rejected_eq]=true' )

Solidus Version:
4.2.3

Additional context
Not a major issue. Just would be a better experience for new developers and existing developers to update this and clear the warning on rails server startup.

Fix
I think if you just change the structure to the following, it should work and clear the deprecation notice:

        config.menu_items << config.class::MenuItem.new(
          label: :subscriptions,
          icon: 'repeat',
          url: :admin_subscriptions_path,
          condition: ->{ can?(:admin, SolidusSubscriptions::Subscription) },
          match_path: '/subscriptions'
        )

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugDescribes or fixes a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions