diff --git a/admin/app/components/solidus_admin/shipping_categories/edit/component.html.erb b/admin/app/components/solidus_admin/shipping_categories/edit/component.html.erb index 88185925b39..84c7a2aef54 100644 --- a/admin/app/components/solidus_admin/shipping_categories/edit/component.html.erb +++ b/admin/app/components/solidus_admin/shipping_categories/edit/component.html.erb @@ -13,4 +13,3 @@ <% end %> <% end %> <% end %> -<%= render component("shipping_categories/index").new(page: @page) %> diff --git a/admin/app/components/solidus_admin/shipping_categories/edit/component.rb b/admin/app/components/solidus_admin/shipping_categories/edit/component.rb index 6f2496e4af1..02ca53bfe93 100644 --- a/admin/app/components/solidus_admin/shipping_categories/edit/component.rb +++ b/admin/app/components/solidus_admin/shipping_categories/edit/component.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true class SolidusAdmin::ShippingCategories::Edit::Component < SolidusAdmin::ShippingCategories::Index::Component - def initialize(page:, shipping_category:) - @page = page + def initialize(shipping_category:) @shipping_category = shipping_category end diff --git a/admin/app/components/solidus_admin/shipping_categories/index/component.rb b/admin/app/components/solidus_admin/shipping_categories/index/component.rb index 4253dcec01c..8b75bca012d 100644 --- a/admin/app/components/solidus_admin/shipping_categories/index/component.rb +++ b/admin/app/components/solidus_admin/shipping_categories/index/component.rb @@ -5,21 +5,14 @@ def model_class Spree::ShippingCategory end - def actions - render component("ui/button").new( - tag: :a, - text: t('.add'), - href: spree.new_admin_shipping_category_path, - icon: "add-line", - class: "align-self-end w-full", - ) - end - def page_actions render component("ui/button").new( tag: :a, text: t('.add'), - href: solidus_admin.new_shipping_category_path, data: { turbo_frame: :new_shipping_category_modal }, + href: solidus_admin.new_shipping_category_path, data: { + turbo_frame: :new_shipping_category_modal, + turbo_prefetch: false, + }, icon: "add-line", class: "align-self-end w-full", ) @@ -32,8 +25,8 @@ def turbo_frames ] end - def row_url(shipping_category) - spree.edit_admin_shipping_category_path(shipping_category, _turbo_frame: :edit_shipping_category_modal) + def edit_url(shipping_category) + spree.edit_admin_shipping_category_path(shipping_category) end def search_key @@ -57,7 +50,14 @@ def batch_actions def columns [ - :name + { + header: :name, + data: ->(shipping_category) do + link_to shipping_category.name, edit_url(shipping_category), + data: { turbo_frame: :edit_shipping_category_modal, turbo_prefetch: false }, + class: "body-link" + end + }, ] end end diff --git a/admin/app/components/solidus_admin/shipping_categories/new/component.html.erb b/admin/app/components/solidus_admin/shipping_categories/new/component.html.erb index e3cf3a75937..19821f8c97f 100644 --- a/admin/app/components/solidus_admin/shipping_categories/new/component.html.erb +++ b/admin/app/components/solidus_admin/shipping_categories/new/component.html.erb @@ -13,5 +13,3 @@ <% end %> <% end %> <% end %> - -<%= render component("shipping_categories/index").new(page: @page) %> diff --git a/admin/app/components/solidus_admin/shipping_categories/new/component.rb b/admin/app/components/solidus_admin/shipping_categories/new/component.rb index ec46b93ae3d..bdaf700111d 100644 --- a/admin/app/components/solidus_admin/shipping_categories/new/component.rb +++ b/admin/app/components/solidus_admin/shipping_categories/new/component.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true class SolidusAdmin::ShippingCategories::New::Component < SolidusAdmin::ShippingCategories::Index::Component - def initialize(page:, shipping_category:) - @page = page + def initialize(shipping_category:) @shipping_category = shipping_category end diff --git a/admin/app/controllers/solidus_admin/shipping_categories_controller.rb b/admin/app/controllers/solidus_admin/shipping_categories_controller.rb index a7a58686da7..d78cdeda227 100644 --- a/admin/app/controllers/solidus_admin/shipping_categories_controller.rb +++ b/admin/app/controllers/solidus_admin/shipping_categories_controller.rb @@ -9,10 +9,8 @@ class ShippingCategoriesController < SolidusAdmin::BaseController def new @shipping_category = Spree::ShippingCategory.new - set_index_page - respond_to do |format| - format.html { render component('shipping_categories/new').new(page: @page, shipping_category: @shipping_category) } + format.html { render component('shipping_categories/new').new(shipping_category: @shipping_category) } end end @@ -34,11 +32,9 @@ def create end end else - set_index_page - respond_to do |format| format.html do - page_component = component('shipping_categories/new').new(page: @page, shipping_category: @shipping_category) + page_component = component('shipping_categories/new').new(shipping_category: @shipping_category) render page_component, status: :unprocessable_entity end end @@ -54,10 +50,8 @@ def index end def edit - set_index_page - respond_to do |format| - format.html { render component('shipping_categories/edit').new(page: @page, shipping_category: @shipping_category) } + format.html { render component('shipping_categories/edit').new(shipping_category: @shipping_category) } end end @@ -75,11 +69,9 @@ def update end end else - set_index_page - respond_to do |format| format.html do - page_component = component('shipping_categories/edit').new(page: @page, shipping_category: @shipping_category) + page_component = component('shipping_categories/edit').new(shipping_category: @shipping_category) render page_component, status: :unprocessable_entity end end diff --git a/admin/spec/features/shipping_categories_spec.rb b/admin/spec/features/shipping_categories_spec.rb index 09ad72338fd..e91cb913469 100644 --- a/admin/spec/features/shipping_categories_spec.rb +++ b/admin/spec/features/shipping_categories_spec.rb @@ -65,15 +65,15 @@ before do Spree::ShippingCategory.create(name: "Letter Mail") visit "/admin/shipping_categories#{query}" - find_row("Letter Mail").click - expect(page).to have_css("dialog", wait: 5) + click_on "Letter Mail" + expect(page).to have_css("dialog") expect(page).to have_content("Edit Shipping Category") expect(page).to be_axe_clean end it "closing the modal keeps query params" do within("dialog") { click_on "Cancel" } - expect(page).not_to have_selector("dialog", wait: 5) + expect(page).not_to have_selector("dialog") expect(page.current_url).to include(query) end