diff --git a/Gemfile.lock b/Gemfile.lock index 83087755bd..3388119c47 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -326,7 +326,7 @@ GEM websocket-driver (>= 0.6, < 0.8) ffaker (2.23.0) ffi (1.16.3) - flipper (1.3.0) + flipper (1.3.6) concurrent-ruby (< 2) flipper-active_record (1.3.0) activerecord (>= 4.2, < 8) diff --git a/app/controllers/admin/product_import_controller.rb b/app/controllers/admin/product_import_controller.rb index f58f9268a3..3cc7e2b590 100644 --- a/app/controllers/admin/product_import_controller.rb +++ b/app/controllers/admin/product_import_controller.rb @@ -49,7 +49,7 @@ module Admin errors: @importer.errors.full_messages } - if helpers.feature?(:inventory, spree_current_user.enterprises) + if helpers.feature?(:inventory, *spree_current_user.enterprises) json[:results][:inventory_created] = @importer.inventory_created_count json[:results][:inventory_updated] = @importer.inventory_updated_count end @@ -175,7 +175,7 @@ module Admin # Return an error if trying to import into inventories when inventory is disable def can_import_into_inventories? - return true if helpers.feature?(:inventory, spree_current_user.enterprises) || + return true if helpers.feature?(:inventory, *spree_current_user.enterprises) || params.dig(:settings, "import_into") != 'inventories' redirect_to admin_product_import_url, notice: I18n.t(:product_import_inventory_disable) diff --git a/app/helpers/admin/enterprises_helper.rb b/app/helpers/admin/enterprises_helper.rb index f315f8acb4..e77ef85414 100644 --- a/app/helpers/admin/enterprises_helper.rb +++ b/app/helpers/admin/enterprises_helper.rb @@ -28,7 +28,7 @@ module Admin show_connected_apps = can?(:manage_connected_apps, enterprise) && (connected_apps_enabled(enterprise).present? || dfc_platforms_available?) - show_inventory_settings = feature?(:inventory, spree_current_user.enterprises) && is_shop + show_inventory_settings = feature?(:inventory, *spree_current_user.enterprises) && is_shop show_options = { show_properties:, diff --git a/app/models/product_import/product_importer.rb b/app/models/product_import/product_importer.rb index 6e54e17b59..ca933c37fe 100644 --- a/app/models/product_import/product_importer.rb +++ b/app/models/product_import/product_importer.rb @@ -193,7 +193,7 @@ module ProductImport order('is_primary_producer ASC, name'). map { |e| @editable_enterprises[e.name] = e.id } - return unless OpenFoodNetwork::FeatureToggle.enabled?(:inventory, @current_user.enterprises) + return unless OpenFoodNetwork::FeatureToggle.enabled?(:inventory, *@current_user.enterprises) @inventory_permissions = permissions.variant_override_enterprises_per_hub end diff --git a/app/models/spree/ability.rb b/app/models/spree/ability.rb index ea1c67f827..799d533910 100644 --- a/app/models/spree/ability.rb +++ b/app/models/spree/ability.rb @@ -213,7 +213,7 @@ module Spree managed_product_enterprises.include? variant.supplier end - if OpenFoodNetwork::FeatureToggle.enabled?(:inventory, user.enterprises) + if OpenFoodNetwork::FeatureToggle.enabled?(:inventory, *user.enterprises) can [:admin, :index, :read, :update, :bulk_update, :bulk_reset], VariantOverride do |vo| next false unless vo.hub.present? && vo.variant&.supplier.present? diff --git a/app/views/admin/product_import/_upload_form.html.haml b/app/views/admin/product_import/_upload_form.html.haml index 4ea7b64856..a8a853f556 100644 --- a/app/views/admin/product_import/_upload_form.html.haml +++ b/app/views/admin/product_import/_upload_form.html.haml @@ -5,7 +5,7 @@ %h6= t('admin.product_import.index.choose_import_type') %br - options = { "#{t('admin.product_import.index.product_list')}" => :product_list } - - options = options.merge("#{t('admin.product_import.index.inventories')}" => :inventories) if feature?(:inventory, spree_current_user.enterprises) + - options = options.merge("#{t('admin.product_import.index.inventories')}" => :inventories) if feature?(:inventory, *spree_current_user.enterprises) = select_tag "settings[import_into]", options_for_select(options), { "data-controller": "tom-select", class: "primary inline no-search", "ng-model": "settings.import_into" } diff --git a/app/views/admin/product_import/_upload_sidebar.html.haml b/app/views/admin/product_import/_upload_sidebar.html.haml index 41976277c5..fc0c22f7c4 100644 --- a/app/views/admin/product_import/_upload_sidebar.html.haml +++ b/app/views/admin/product_import/_upload_sidebar.html.haml @@ -5,7 +5,7 @@ %i.icon-external-link = t('admin.product_import.index.product_list_template') - - if feature?(:inventory, spree_current_user.enterprises) + - if feature?(:inventory, *spree_current_user.enterprises) %a.download{href: '/inventory_template.csv'} %i.icon-external-link = t('admin.product_import.index.inventory_template') diff --git a/app/views/spree/admin/shared/_product_sub_menu.html.haml b/app/views/spree/admin/shared/_product_sub_menu.html.haml index 7fe1ccc3ed..c24f0da781 100644 --- a/app/views/spree/admin/shared/_product_sub_menu.html.haml +++ b/app/views/spree/admin/shared/_product_sub_menu.html.haml @@ -2,5 +2,5 @@ %ul#sub_nav.inline-menu = tab :products, :products_v3, url: admin_products_path = tab :properties - = tab :variant_overrides, url: main_app.admin_inventory_path, match_path: '/inventory' if feature?(:inventory, spree_current_user.enterprises) + = tab :variant_overrides, url: main_app.admin_inventory_path, match_path: '/inventory' if feature?(:inventory, *spree_current_user.enterprises) = tab :import, url: main_app.admin_product_import_path, match_path: '/product_import'