Skip to content

Commit

Permalink
Add nesting for "Users and Roles" admin component
Browse files Browse the repository at this point in the history
Now instead of a top level Users component, the main landing page is
"Users and Roles" (with the users page being the pre-selected tab, so
the only visual change is a new page header and a new tab component to
swap between "Users" and "Roles".
  • Loading branch information
MadelineCollier committed Aug 19, 2024
1 parent b766363 commit eb6f734
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class SolidusAdmin::Users::Index::Component < SolidusAdmin::UI::Pages::Index::Component
class SolidusAdmin::Users::Index::Component < SolidusAdmin::UsersAndRoles::Component
def model_class
Spree.user_class
end
Expand Down
19 changes: 19 additions & 0 deletions admin/app/components/solidus_admin/users_and_roles/component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

class SolidusAdmin::UsersAndRoles::Component < SolidusAdmin::UI::Pages::Index::Component
def title
page_header_title safe_join([
tag.div(t(".title")),
])
end

def tabs
[
{
text: Spree.user_class.model_name.human(count: 2),
href: solidus_admin.users_path,
current: model_class == Spree.user_class,
},
]
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
en:
title: "Users and Roles"
1 change: 1 addition & 0 deletions admin/spec/features/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
create(:user, :with_orders, email: "customer-with-order@example.com")

visit "/admin/users"
expect(page).to have_content("Users and Roles")
expect(page).to have_content("customer@example.com")
expect(page).not_to have_content("admin-2@example.com")
click_on "Admins"
Expand Down

0 comments on commit eb6f734

Please sign in to comment.