Sha256: f46d85ec86cf10a156418804aa7532c331b597992d5499eca2e514938a637ab5

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

Rails.application.config.to_prepare do
  Spree::Backend::Config.configure do |config|
    config.menu_items = config.menu_items.map do |item|
      if item.label.to_sym == :settings
        # The API of the MenuItem class changes in Solidus 4.2.0
        if item.respond_to?(:children)
          item.children << Spree::BackendConfiguration::MenuItem.new(
            label: :reviews,
            condition: -> { can?(:admin, Spree::ReviewsConfiguration) },
            url: -> { Spree::Core::Engine.routes.url_helpers.edit_admin_review_settings_path },
            match_path: /review_settings/
          )
        else
          item.sections << :reviews
        end
      elsif item.label.to_sym == :products
        if item.respond_to?(:children)
          item.children << Spree::BackendConfiguration::MenuItem.new(
            label: :reviews,
            condition: -> { can?(:admin, Spree::Review) },
            url: -> { Spree::Core::Engine.routes.url_helpers.admin_reviews_path },
            match_path: /reviews/
          )
        else
          item.sections << :reviews
        end
      end
      item
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_reviews-1.7.0 config/initializers/add_spree_reviews_to_menu.rb