diff --git a/admin/app/components/solidus_admin/roles/edit/component.html.erb b/admin/app/components/solidus_admin/roles/edit/component.html.erb index 9e6b674eb48..bf3ee61cb62 100644 --- a/admin/app/components/solidus_admin/roles/edit/component.html.erb +++ b/admin/app/components/solidus_admin/roles/edit/component.html.erb @@ -29,5 +29,3 @@ <% end %> <% end %> <% end %> - -<%= render component("roles/index").new(page: @page) %> diff --git a/admin/app/components/solidus_admin/roles/edit/component.rb b/admin/app/components/solidus_admin/roles/edit/component.rb index 67b1f47659f..cad11f9a258 100644 --- a/admin/app/components/solidus_admin/roles/edit/component.rb +++ b/admin/app/components/solidus_admin/roles/edit/component.rb @@ -3,8 +3,7 @@ class SolidusAdmin::Roles::Edit::Component < SolidusAdmin::BaseComponent include SolidusAdmin::PermissionSetsHelper - def initialize(page:, role:) - @page = page + def initialize(role:) @role = role end diff --git a/admin/app/components/solidus_admin/roles/index/component.rb b/admin/app/components/solidus_admin/roles/index/component.rb index c5c4e92e297..1b9195f62ab 100644 --- a/admin/app/components/solidus_admin/roles/index/component.rb +++ b/admin/app/components/solidus_admin/roles/index/component.rb @@ -13,15 +13,18 @@ def search_url solidus_admin.roles_path end - def row_url(role) - solidus_admin.edit_role_path(role, _turbo_frame: :edit_role_modal) + def edit_path(role) + solidus_admin.edit_role_path(role) end def page_actions render component("ui/button").new( tag: :a, text: t('.add'), - href: solidus_admin.new_role_path, data: { turbo_frame: :new_role_modal }, + href: solidus_admin.new_role_path, data: { + turbo_frame: :new_role_modal, + turbo_prefetch: false, + }, icon: "add-line", ) end @@ -59,11 +62,19 @@ def columns [ { header: :role, - data: :name, + data: ->(role) do + link_to role.name, edit_path(role), + data: { turbo_frame: :edit_role_modal, turbo_prefetch: false }, + class: "body-link" + end, }, { header: :description, - data: :description, + data: ->(role) do + link_to_if role.description, role.description, edit_path(role), + data: { turbo_frame: :edit_role_modal, turbo_prefetch: false }, + class: "body-link" + end } ] end diff --git a/admin/app/components/solidus_admin/roles/new/component.html.erb b/admin/app/components/solidus_admin/roles/new/component.html.erb index 92d44cd2d76..5bb47301b52 100644 --- a/admin/app/components/solidus_admin/roles/new/component.html.erb +++ b/admin/app/components/solidus_admin/roles/new/component.html.erb @@ -29,5 +29,3 @@ <% end %> <% end %> <% end %> - -<%= render component("roles/index").new(page: @page) %> diff --git a/admin/app/components/solidus_admin/roles/new/component.rb b/admin/app/components/solidus_admin/roles/new/component.rb index 3619452722e..cc328f1ba4d 100644 --- a/admin/app/components/solidus_admin/roles/new/component.rb +++ b/admin/app/components/solidus_admin/roles/new/component.rb @@ -3,8 +3,7 @@ class SolidusAdmin::Roles::New::Component < SolidusAdmin::BaseComponent include SolidusAdmin::PermissionSetsHelper - def initialize(page:, role:) - @page = page + def initialize(role:) @role = role end diff --git a/admin/app/controllers/solidus_admin/roles_controller.rb b/admin/app/controllers/solidus_admin/roles_controller.rb index fea6e2f5b0f..0067e06e4f6 100644 --- a/admin/app/controllers/solidus_admin/roles_controller.rb +++ b/admin/app/controllers/solidus_admin/roles_controller.rb @@ -20,10 +20,8 @@ def index def new @role = Spree::Role.new - set_index_page - respond_to do |format| - format.html { render component('roles/new').new(page: @page, role: @role) } + format.html { render component('roles/new').new(role: @role) } end end @@ -43,11 +41,9 @@ def create end end else - set_index_page - respond_to do |format| format.html do - page_component = component('roles/new').new(page: @page, role: @role) + page_component = component('roles/new').new(role: @role) render page_component, status: :unprocessable_entity end end @@ -55,10 +51,8 @@ def create end def edit - set_index_page - respond_to do |format| - format.html { render component('roles/edit').new(page: @page, role: @role) } + format.html { render component('roles/edit').new(role: @role) } end end @@ -76,11 +70,9 @@ def update end end else - set_index_page - respond_to do |format| format.html do - page_component = component('roles/edit').new(page: @page, role: @role) + page_component = component('roles/edit').new(role: @role) render page_component, status: :unprocessable_entity end end diff --git a/admin/spec/features/roles_spec.rb b/admin/spec/features/roles_spec.rb index 625d048e2a9..84eb98f0dc2 100644 --- a/admin/spec/features/roles_spec.rb +++ b/admin/spec/features/roles_spec.rb @@ -120,7 +120,7 @@ before do Spree::Role.create(name: "Reviewer", permission_sets: [settings_edit_permission]) visit "/admin/roles#{query}" - find_row("Reviewer").click + click_on "Reviewer" expect(page).to have_selector("dialog", wait: 5) expect(page).to have_content("Edit Role") expect(page).to be_axe_clean