Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide old products screen when admin_style_v3 enabled #11660

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/admin/products_v3/_table.html.haml
Original file line number Diff line number Diff line change
@@ -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" }
Expand Down
5 changes: 1 addition & 4 deletions app/views/spree/admin/shared/_product_sub_menu.html.haml
Original file line number Diff line number Diff line change
@@ -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'
2 changes: 1 addition & 1 deletion config/routes/admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
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
Expand Down
13 changes: 11 additions & 2 deletions config/routes/spree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@

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
Expand All @@ -78,6 +84,9 @@
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
Expand Down
2 changes: 1 addition & 1 deletion spec/reflexes/products_reflex_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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
Expand Down
16 changes: 8 additions & 8 deletions spec/system/admin/products_v3/products_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
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

Expand All @@ -28,7 +28,7 @@
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
Expand All @@ -44,7 +44,7 @@

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
Expand Down Expand Up @@ -76,7 +76,7 @@
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
Expand Down Expand Up @@ -128,7 +128,7 @@
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"

Expand All @@ -145,7 +145,7 @@
}

it "can search for a product" do
visit admin_products_v3_index_url
visit admin_products_url

search_by_category "Category 1"

Expand All @@ -168,7 +168,7 @@
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
Expand Down Expand Up @@ -198,7 +198,7 @@
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
Expand Down