Merge pull request #11660 from dacook/products_v3_path

Hide old products screen when admin_style_v3 enabled
This commit is contained in:
Rachel Arnould
2023-10-17 10:45:01 +02:00
committed by GitHub
6 changed files with 23 additions and 17 deletions

View File

@@ -1,4 +1,4 @@
= form_with url: bulk_update_admin_products_v3_index_path, method: :patch, id: "products-form",
= form_with url: bulk_update_admin_products_path, method: :patch, id: "products-form",
html: {'data-reflex-serialize-form': true, 'data-reflex': 'submit->products#bulk_update',
'data-controller': "bulk-form", 'data-bulk-form-disable-selector-value': "#sort,#filters"} do |form|
%fieldset.form-actions.hidden{ 'data-bulk-form-target': "actions" }

View File

@@ -1,9 +1,6 @@
- content_for :sub_menu do
%ul#sub_nav.inline-menu
- if feature?(:admin_style_v3, spree_current_user)
= tab :products_v3, url: main_app.admin_products_v3_index_path
- else
= tab :products
= tab :products
= tab :properties
= tab :variant_overrides, url: main_app.admin_inventory_path, match_path: '/inventory'
= tab :import, url: main_app.admin_product_import_path, match_path: '/product_import'

View File

@@ -68,7 +68,7 @@ Openfoodnetwork::Application.routes.draw do
post '/product_import/reset_absent', to: 'product_import#reset_absent_products', as: 'product_import_reset_async'
constraints FeatureToggleConstraint.new(:admin_style_v3) do
resources :products_v3, as: :products_v3, only: :index do
resources :products, to: 'products_v3#index', only: :index do
patch :bulk_update, on: :collection
end
end

View File

@@ -50,9 +50,15 @@ Spree::Core::Engine.routes.draw do
resources :users
resources :products do
post :bulk_update, :on => :collection, :as => :bulk_update
constraints FeatureToggleConstraint.new(:admin_style_v3, negate: true) do
# Show old bulk products screen
resources :products, :index do
post :bulk_update, :on => :collection, :as => :bulk_update
end
end
resources :products, except: :index do
member do
get :clone
get :group_buy_options
@@ -78,6 +84,9 @@ Spree::Core::Engine.routes.draw do
end
end
# duplicate old path for reference when admin_style_v3 enabled
resources :products_old, to: 'products#index', only: :index
get '/variants/search', :to => "variants#search", :as => :search_variants
resources :properties

View File

@@ -5,7 +5,7 @@ require "reflex_helper"
describe ProductsReflex, type: :reflex do
let(:current_user) { create(:admin_user) } # todo: set up an enterprise user to test permissions
let(:context) {
{ url: admin_products_v3_index_url, connection: { current_user: } }
{ url: admin_products_url, connection: { current_user: } }
}
before do

View File

@@ -19,7 +19,7 @@ describe 'As an admin, I can see the new product page' do
end
it "can see the new product page" do
visit admin_products_v3_index_url
visit admin_products_url
expect(page).to have_content "Bulk Edit Products"
end
@@ -28,7 +28,7 @@ describe 'As an admin, I can see the new product page' do
let!(:product_a) { create(:simple_product, name: "Apples") }
before do
visit admin_products_v3_index_url
visit admin_products_url
end
it "Should sort products alphabetically by default" do
@@ -44,7 +44,7 @@ describe 'As an admin, I can see the new product page' do
describe "pagination" do
before do
visit admin_products_v3_index_url
visit admin_products_url
end
it "has a pagination, has 15 products per page by default and can change the page" do
@@ -76,7 +76,7 @@ describe 'As an admin, I can see the new product page' do
let!(:product_by_name) { create(:simple_product, name: "searchable product") }
before do
visit admin_products_v3_index_url
visit admin_products_url
end
it "can search for a product" do
@@ -128,7 +128,7 @@ describe 'As an admin, I can see the new product page' do
let!(:product_by_supplier) { create(:simple_product, supplier: producer) }
it "can search for a product" do
visit admin_products_v3_index_url
visit admin_products_url
search_by_producer "Producer 1"
@@ -145,7 +145,7 @@ describe 'As an admin, I can see the new product page' do
}
it "can search for a product" do
visit admin_products_v3_index_url
visit admin_products_url
search_by_category "Category 1"
@@ -168,7 +168,7 @@ describe 'As an admin, I can see the new product page' do
let!(:product_a) { create(:simple_product, name: "Apples", sku: "APL-00") }
before do
visit admin_products_v3_index_url
visit admin_products_url
end
it "shows an actions memu with an edit link when clicking on icon for product" do
@@ -198,7 +198,7 @@ describe 'As an admin, I can see the new product page' do
let!(:product_a) { create(:simple_product, name: "Apples", sku: "APL-00") }
before do
visit admin_products_v3_index_url
visit admin_products_url
end
it "updates product and variant fields" do