Skip to content

Conversation

@dougfabris
Copy link
Member

@dougfabris dougfabris commented Oct 9, 2025

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Further comments

SUP-856

Summary by CodeRabbit

  • New Features
    • Users-in-Role page: client-side pagination with remote loading and a remove-user flow with confirmation and success/error feedback.
  • Refactor
    • Permissions and Users-in-Role tables now accept explicit paginationData and simplified, state-driven props; components no longer perform internal fetching.
  • Documentation
    • Storybook added/updated for PermissionsTable, UsersInRoleTable, and UsersTable covering default, loading, empty, and error states with pagination.
  • Tests
    • Added accessibility and snapshot tests for UsersInRoleTable; updated PermissionsTable tests to use mocked pagination and added a shared mock pagination helper.

@codecov
Copy link

codecov bot commented Oct 9, 2025

Codecov Report

❌ Patch coverage is 94.84979% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.54%. Comparing base (7a7d368) to head (4523860).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #37184      +/-   ##
===========================================
+ Coverage    66.00%   67.54%   +1.54%     
===========================================
  Files         3014     3295     +281     
  Lines       108199   112648    +4449     
  Branches     19476    20454     +978     
===========================================
+ Hits         71417    76091    +4674     
+ Misses       34402    33881     -521     
- Partials      2380     2676     +296     
Flag Coverage Δ
e2e 57.32% <88.09%> (+6.42%) ⬆️
unit 71.55% <96.44%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Oct 9, 2025

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is targeting the wrong base branch. It should target 7.12.0, but it targets 7.11.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Oct 9, 2025

⚠️ No Changeset found

Latest commit: 4523860

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 14, 2025

Walkthrough

Propagates unified pagination state (paginationData) across permissions and users tables, moves UsersInRole data fetching to the page with useQuery and usePagination, extracts removal flow into useRemoveUserFromRole, converts UsersInRoleTable to presentational, and updates stories/tests to use createMockedPagination.

Changes

Cohort / File(s) Summary
Pagination hook & note
apps/meteor/client/components/GenericTable/hooks/usePagination.ts
File-level TODO added to move usePagination outside GenericTable; no runtime or signature changes.
Permissions page & table
apps/meteor/client/views/admin/permissions/PermissionsPage.tsx, apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.tsx, apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.spec.tsx, apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.stories.tsx
Replaced paginationProps prop with paginationData; pass current/itemsPerPage and setters from paginationData into hooks/components; tests and stories updated to provide paginationData via createMockedPagination and stories refactored to use a shared Template.
UsersInRole page: fetch + pagination
apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRolePage.tsx
Adds client-side fetching using useQuery and usePagination, memoized query args, integrates useRemoveUserFromRole, and passes loading/error/success, data, total, refetch and paginationData into the table.
UsersInRoleTable: presentational refactor
apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.tsx, apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTableRow.tsx
Removed internal fetching and modal logic; component now accepts explicit UI/state props (isLoading, isError, isSuccess, total, users), onRemove, refetch, and paginationData; row prop typed as Serialized<IUserInRole>.
Remove-user hook
apps/meteor/client/views/admin/permissions/UsersInRole/hooks/useRemoveUserFromRole.tsx
New exported hook useRemoveUserFromRole that opens a confirmation modal, calls POST /v1/roles.removeUserFromRole, shows toasts, invalidates getUsersInRole query, and closes the modal; returns handleRemove(username).
UsersInRoleTable stories & tests
apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.stories.tsx, apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.spec.tsx
New Storybook stories (Default, withLoading, withNoResults, withError) using createMockedPagination; adds snapshot and jest-axe accessibility tests for stories.
UsersTable stories update
apps/meteor/client/views/admin/users/UsersTable/UsersTable.stories.tsx
Replaced inline mocked pagination with createMockedPagination helper and updated stories to use it.
Test helpers
apps/meteor/tests/mocks/data.ts
Added createMockedPagination(results?, total?) test helper returning paginationData-shaped mock used by stories/tests.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Admin as Admin User
  participant Page as UsersInRolePage
  participant Pag as usePagination
  participant Query as useQuery(getUsersInRole)
  participant API as /v1/roles.getUsersInRole

  Admin->>Page: Open "Users in Role" page
  Page->>Pag: init(current, itemsPerPage)
  Page->>Query: fetch({ role, scope, count, offset })
  Query->>API: GET users { role, scope, count, offset }
  API-->>Query: { users, total }
  Query-->>Page: data, isLoading/isError/isSuccess
  Page->>Admin: Render UsersInRoleTable(users, total, paginationData)
  Admin->>Pag: Change page or per-page
  Pag-->>Page: update current/itemsPerPage
  Page->>Query: refetch with new count/offset
Loading
sequenceDiagram
  autonumber
  actor Admin as Admin User
  participant Table as UsersInRoleTable
  participant Hook as useRemoveUserFromRole
  participant Modal as GenericModal
  participant API as /v1/roles.removeUserFromRole
  participant QC as QueryClient

  Admin->>Table: Click "Remove" on a user
  Table->>Hook: handleRemove(username)
  Hook->>Modal: open confirm (danger)
  Admin->>Modal: Confirm
  Modal->>API: POST removeUserFromRole { roleId, username, scope }
  API-->>Modal: 200 OK
  Modal->>QC: invalidate getUsersInRole
  Modal->>Hook: close modal
  Hook->>Table: (toast shown) refetch()
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • MartinSchoeler
  • tassoevan
  • lucas-a-pelegrino

Poem

Thump-thump, I hop and tidy code tonight,
Pages fetch and paginate just right,
A modal warns, then usernames part,
Stories mock, tests assert their heart.
Hooray for tidy hops and CI light! 🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning This PR introduces substantial changes outside the scope of SUP-856’s pagination requirement, including modifications to PermissionsPage, PermissionsTable and its related stories/tests, generic hook comments, UsersTable stories, and a new test mock helper. These alterations are unrelated to adding pagination for users in role and expand the PR beyond its stated objective. Please isolate the UsersInRole pagination changes into a dedicated PR and move the unrelated updates to permissions tables, story files, test mocks, and generic hook comments into separate, appropriately scoped PRs.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly summarizes the core refactor of moving user data handling out of the UsersInRole table layout and into the page, reflecting the primary change made in this PR without extraneous details. It follows conventional formatting and is clear enough for a reviewer to understand the main purpose at a glance.
Linked Issues Check ✅ Passed The changes implement server-driven pagination for the UsersInRole view in compliance with SUP-856 by introducing usePagination in UsersInRolePage, adjusting the query to use offset and count parameters, and passing paginationData to UsersInRoleTable which now consumes current, itemsPerPage, and setter callbacks. Corresponding updates to tests and stories ensure the new pagination flow is covered and behaves as expected.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/usersInRole-table

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dougfabris dougfabris force-pushed the refactor/usersInRole-table branch 2 times, most recently from 3565f34 to d90d92a Compare October 14, 2025 12:40
@dougfabris dougfabris added this to the 7.12.0 milestone Oct 14, 2025
@dougfabris dougfabris force-pushed the refactor/usersInRole-table branch from d90d92a to ba85c24 Compare October 14, 2025 18:18
@dougfabris dougfabris force-pushed the refactor/usersInRole-table branch from ba85c24 to 9b04d42 Compare October 14, 2025 19:14
@dougfabris dougfabris changed the title refactor: UsersInRoleTable refactor: Decouple users in role table data from layout Oct 15, 2025
@dougfabris dougfabris marked this pull request as ready for review October 15, 2025 12:02
@dougfabris dougfabris requested a review from a team as a code owner October 15, 2025 12:02
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.tsx (1)

50-69: Consider removing unnecessary optional chaining on the map key.

The rendering logic and pagination integration are correct. However, on line 56, user?._id uses optional chaining even though the users type is Serialized<IUserInRole>[], which doesn't permit undefined elements. This suggests either:

  1. The optional chaining is defensive but unnecessary, or
  2. There's a type mismatch where users could contain undefined elements

If the type accurately reflects the data, consider simplifying to user._id for consistency with the type contract.

Apply this diff if the type contract is accurate:

-							{users.map((user) => (
-								<UsersInRoleTableRow key={user?._id} user={user} onRemove={onRemove} />
-							))}
+							{users.map((user) => (
+								<UsersInRoleTableRow key={user._id} user={user} onRemove={onRemove} />
+							))}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6d605e6 and 9b04d42.

⛔ Files ignored due to path filters (2)
  • apps/meteor/client/views/admin/permissions/PermissionsTable/__snapshots__/PermissionsTable.spec.tsx.snap is excluded by !**/*.snap
  • apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/__snapshots__/UsersInRoleTable.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (12)
  • apps/meteor/client/components/GenericTable/hooks/usePagination.ts (1 hunks)
  • apps/meteor/client/views/admin/permissions/PermissionsPage.tsx (2 hunks)
  • apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.spec.tsx (3 hunks)
  • apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.stories.tsx (2 hunks)
  • apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.tsx (2 hunks)
  • apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRolePage.tsx (4 hunks)
  • apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.spec.tsx (1 hunks)
  • apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.stories.tsx (1 hunks)
  • apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.tsx (4 hunks)
  • apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTableRow.tsx (2 hunks)
  • apps/meteor/client/views/admin/permissions/UsersInRole/hooks/useRemoveUserFromRole.tsx (1 hunks)
  • apps/meteor/client/views/admin/users/UsersTable/UsersTable.stories.tsx (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-16T22:08:51.490Z
Learnt from: CR
PR: RocketChat/Rocket.Chat#0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-09-16T22:08:51.490Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Use descriptive test names that clearly communicate expected behavior

Applied to files:

  • apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.spec.tsx
🧬 Code graph analysis (11)
apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.tsx (1)
apps/meteor/client/components/GenericTable/hooks/usePagination.ts (1)
  • usePagination (20-49)
apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.stories.tsx (1)
apps/meteor/client/components/GenericTable/hooks/usePagination.ts (1)
  • createMockedPagination (8-15)
apps/meteor/client/views/admin/users/UsersTable/UsersTable.stories.tsx (1)
apps/meteor/client/components/GenericTable/hooks/usePagination.ts (1)
  • createMockedPagination (8-15)
apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.stories.tsx (3)
apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.stories.tsx (2)
  • Default (36-36)
  • Empty (60-60)
apps/meteor/client/views/admin/users/UsersTable/UsersTable.stories.tsx (1)
  • Default (13-13)
apps/meteor/client/components/GenericTable/hooks/usePagination.ts (1)
  • createMockedPagination (8-15)
apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.tsx (2)
packages/core-typings/src/IUser.ts (1)
  • IUserInRole (295-298)
apps/meteor/client/components/GenericTable/hooks/usePagination.ts (1)
  • usePagination (20-49)
apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.spec.tsx (1)
packages/mock-providers/src/index.ts (1)
  • mockAppRoot (3-3)
apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.spec.tsx (3)
packages/apps-engine/src/server/permissions/AppPermissions.ts (1)
  • defaultPermissions (133-164)
apps/meteor/client/components/GenericTable/hooks/usePagination.ts (1)
  • createMockedPagination (8-15)
packages/mock-providers/src/index.ts (1)
  • mockAppRoot (3-3)
apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRolePage.tsx (2)
apps/meteor/client/components/GenericTable/hooks/usePagination.ts (1)
  • usePagination (20-49)
apps/meteor/client/views/admin/permissions/UsersInRole/hooks/useRemoveUserFromRole.tsx (1)
  • useRemoveUserFromRole (8-52)
apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTableRow.tsx (1)
packages/core-typings/src/IUser.ts (1)
  • IUserInRole (295-298)
apps/meteor/client/views/admin/permissions/UsersInRole/hooks/useRemoveUserFromRole.tsx (3)
packages/core-typings/src/IRoom.ts (1)
  • IRoom (21-95)
packages/ui-contexts/src/index.ts (2)
  • useSetModal (68-68)
  • useToastMessageDispatch (75-75)
packages/core-typings/src/IUser.ts (1)
  • IUserInRole (295-298)
apps/meteor/client/views/admin/permissions/PermissionsPage.tsx (2)
apps/meteor/client/components/GenericTable/hooks/usePagination.ts (1)
  • usePagination (20-49)
apps/meteor/client/views/admin/permissions/hooks/usePermissionsAndRoles.ts (1)
  • usePermissionsAndRoles (10-35)
🪛 Biome (2.1.2)
apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.stories.tsx

[error] 72-72: Do not shadow the global "Error" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

🔇 Additional comments (9)
apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.stories.tsx (3)

6-6: LGTM!

The import is correctly added and properly scoped for the mocked pagination helper.


102-111: LGTM! Template pattern and realistic pagination testing.

The Template pattern follows Storybook best practices. The configuration with total: 10 and permissions.length (4 items) creates a realistic pagination scenario where the UI displays "Showing results 1 - 4 of 10", effectively testing the pagination component behavior when there are more total items than currently displayed.


113-120: LGTM!

The Empty story correctly configures the empty state with appropriate zero-count pagination data.

apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.tsx (6)

1-1: LGTM!

The addition of IUserInRole and Serialized types properly supports the refactored props interface.


15-15: LGTM!

The type import for usePagination correctly supports the paginationData prop typing.


17-26: LGTM! Excellent separation of concerns.

The refactored props interface properly decouples data fetching from presentation. The component is now purely presentational, receiving all state and callbacks externally. The use of Serialized<IUserInRole>[] correctly handles API response data types.


30-30: LGTM!

The destructuring pattern correctly extracts specific pagination properties while spreading the remaining helpers (itemsPerPageLabel, showingResultsLabel) to the Pagination component.


32-48: LGTM!

The header structure correctly includes three columns (Name, Email, Actions), and the loading state properly reflects this with headerCells={3}. The fixed width for the Actions column (w='x80') provides appropriate sizing for action buttons.


71-72: LGTM! Proper empty and error state handling.

The component correctly displays GenericNoResults for empty datasets and GenericError with a retry callback for error states. Note that users?.length (line 71) uses optional chaining consistent with line 50, though the type contract suggests users is always defined (non-optional prop).

Copy link
Member

@MartinSchoeler MartinSchoeler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's move this to a dedicated file

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
apps/meteor/client/components/GenericTable/hooks/usePagination.ts (1)

8-10: LGTM! Consider making the TODO more actionable.

The TODO appropriately tracks technical debt for relocating this hook, given its broader usage across the codebase.

To improve clarity, consider specifying a destination folder (e.g., client/hooks/ or client/lib/hooks/) or linking to a tracking issue:

 /**
- * TODO: Move `usePagination` outside from `GenericTable` folder
+ * TODO: Move `usePagination` to `client/hooks/` for broader reusability
  */
apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.stories.tsx (1)

48-82: Stories correctly demonstrate different UI states; consider consistent naming.

The three stories properly configure state flags and data for loading, no results, and error scenarios. The previous shadowing issue with the Error export has been resolved.

However, consider using PascalCase for all story exports to maintain consistency within the file and align with the codebase convention observed in PermissionsTable.stories.tsx and UsersTable.stories.tsx.

Apply this diff to align naming conventions:

-export const withLoading = Template.bind({});
-withLoading.args = {
+export const WithLoading = Template.bind({});
+WithLoading.args = {
   total: 0,
   isLoading: true,
   isError: false,
   isSuccess: false,
   users: [],
   onRemove: () => undefined,
   refetch: () => undefined,
   paginationData: createMockedPagination(),
 };
 
-export const withNoResults = Template.bind({});
-withNoResults.args = {
+export const WithNoResults = Template.bind({});
+WithNoResults.args = {
   total: 0,
   isLoading: false,
   isError: false,
   isSuccess: true,
   users: [],
   onRemove: () => undefined,
   refetch: () => undefined,
   paginationData: createMockedPagination(),
 };
 
-export const withError = Template.bind({});
-withError.args = {
+export const WithError = Template.bind({});
+WithError.args = {
   total: 0,
   isLoading: false,
   isError: true,
   isSuccess: false,
   users: [],
   onRemove: () => undefined,
   refetch: () => undefined,
   paginationData: createMockedPagination(),
 };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9b04d42 and 859ce49.

⛔ Files ignored due to path filters (1)
  • apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/__snapshots__/UsersInRoleTable.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (5)
  • apps/meteor/client/components/GenericTable/hooks/usePagination.ts (1 hunks)
  • apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.spec.tsx (3 hunks)
  • apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.stories.tsx (2 hunks)
  • apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.stories.tsx (1 hunks)
  • apps/meteor/client/views/admin/users/UsersTable/UsersTable.stories.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/meteor/client/views/admin/users/UsersTable/UsersTable.stories.tsx
🧰 Additional context used
🧬 Code graph analysis (2)
apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.stories.tsx (2)
apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.stories.tsx (1)
  • Default (36-36)
apps/meteor/client/views/admin/users/UsersTable/UsersTable.stories.tsx (1)
  • Default (13-13)
apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.stories.tsx (2)
apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.stories.tsx (1)
  • Default (104-104)
apps/meteor/client/views/admin/users/UsersTable/UsersTable.stories.tsx (1)
  • Default (13-13)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🔇 Additional comments (10)
apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.stories.tsx (3)

1-17: LGTM! Well-structured story setup.

The imports, meta configuration, and decorator setup follow Storybook best practices. The satisfies keyword ensures type safety, and the PageContent decorator provides consistent layout across all stories.


19-32: LGTM! Mock data generator works correctly.

The generateMockedUsers function appropriately creates test data with varied properties. The roles assignment logic ensures the first 5 users receive admin roles, which aligns with the current usage.


34-46: LGTM! Default story demonstrates pagination correctly.

The Template and Default story implementation is clean. The pagination setup (5 users displayed out of 30 total) effectively demonstrates the table's pagination behavior.

apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.spec.tsx (3)

10-10: LGTM!

The import of createMockedPagination correctly provides the mock pagination data needed for the updated component API.


54-65: LGTM!

The test correctly adapts to the new paginationData prop while maintaining its original logic. The multi-line formatting improves readability.


80-91: LGTM!

The test update is consistent with the first test and correctly provides the required paginationData prop.

apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.stories.tsx (4)

6-6: LGTM!

The import of createMockedPagination is necessary for the pagination refactor and consistent with the test file.


102-103: LGTM!

The Template pattern is a Storybook best practice and aligns with patterns used elsewhere in the codebase.


104-111: Verify the total and permissions.length mismatch.

The permissions array contains 4 items, but total is set to 10, and createMockedPagination(permissions.length, 10) is called with arguments 4 and 10.

This could be intentional to demonstrate pagination (showing page 1 with 4 items from a total of 10), but it creates an inconsistency where the rendered data (4 permissions) doesn't match the declared total (10).

Please confirm whether this is intentional or if total should be permissions.length for internal consistency.


113-120: LGTM!

The Empty story correctly adopts the Template pattern and maintains internal consistency with total: 0 and empty data arrays.

@dougfabris dougfabris force-pushed the refactor/usersInRole-table branch from 859ce49 to a8a3062 Compare October 15, 2025 15:09
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.stories.tsx (1)

72-82: Past issue resolved: export no longer shadows global Error.

The story is now correctly named withError instead of Error, resolving the noShadowRestrictedNames lint violation from the previous review.

🧹 Nitpick comments (1)
apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.stories.tsx (1)

1-82: LGTM! Well-structured story file with consistent patterns.

The new story file follows Storybook best practices:

  • Template pattern for story reuse
  • Consistent use of createMockedPagination across all stories
  • Clear separation of loading, error, and success states
  • Local generateMockedUsers helper appropriately scoped to this file

If the generateMockedUsers helper is needed in other test files, consider moving it to tests/mocks/data.ts alongside createMockedPagination to reduce duplication.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 859ce49 and a8a3062.

⛔ Files ignored due to path filters (1)
  • apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/__snapshots__/UsersInRoleTable.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (6)
  • apps/meteor/client/components/GenericTable/hooks/usePagination.ts (1 hunks)
  • apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.spec.tsx (3 hunks)
  • apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.stories.tsx (2 hunks)
  • apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.stories.tsx (1 hunks)
  • apps/meteor/client/views/admin/users/UsersTable/UsersTable.stories.tsx (3 hunks)
  • apps/meteor/tests/mocks/data.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.spec.tsx
  • apps/meteor/client/components/GenericTable/hooks/usePagination.ts
🧰 Additional context used
🧬 Code graph analysis (3)
apps/meteor/client/views/admin/users/UsersTable/UsersTable.stories.tsx (1)
apps/meteor/tests/mocks/data.ts (1)
  • createMockedPagination (457-464)
apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.stories.tsx (1)
apps/meteor/tests/mocks/data.ts (1)
  • createMockedPagination (457-464)
apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.stories.tsx (1)
apps/meteor/tests/mocks/data.ts (1)
  • createMockedPagination (457-464)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: CodeQL-Build
  • GitHub Check: Builds matrix rust bindings against alpine
  • GitHub Check: CodeQL-Build
🔇 Additional comments (3)
apps/meteor/client/views/admin/users/UsersTable/UsersTable.stories.tsx (1)

5-5: LGTM! Consistent use of shared pagination mock.

The migration to createMockedPagination improves consistency across story files and centralizes the pagination mock logic.

Also applies to: 71-71, 77-77, 87-87

apps/meteor/tests/mocks/data.ts (1)

457-464: LGTM! Well-designed pagination mock helper.

The createMockedPagination utility provides a clean abstraction for pagination state in tests and stories, improving maintainability across the codebase.

apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.stories.tsx (1)

6-6: LGTM! Proper Template pattern and pagination mock usage.

The introduction of the Template pattern and migration to createMockedPagination aligns with Storybook best practices and maintains consistency across the codebase.

Also applies to: 102-120

MartinSchoeler
MartinSchoeler previously approved these changes Oct 15, 2025
@dougfabris dougfabris added the stat: QA assured Means it has been tested and approved by a company insider label Oct 15, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Oct 15, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a8a3062 and 033b403.

📒 Files selected for processing (4)
  • apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.spec.tsx (4 hunks)
  • apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.stories.tsx (2 hunks)
  • apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.stories.tsx (1 hunks)
  • apps/meteor/client/views/admin/users/UsersTable/UsersTable.stories.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.spec.tsx
  • apps/meteor/client/views/admin/permissions/PermissionsTable/PermissionsTable.stories.tsx
  • apps/meteor/client/views/admin/permissions/UsersInRole/UsersInRoleTable/UsersInRoleTable.stories.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
apps/meteor/client/views/admin/users/UsersTable/UsersTable.stories.tsx (1)
apps/meteor/tests/mocks/data.ts (1)
  • createMockedPagination (457-464)
🔇 Additional comments (1)
apps/meteor/client/views/admin/users/UsersTable/UsersTable.stories.tsx (1)

13-64: LGTM! Well-structured mock data.

The mock users array provides good coverage of different user states, statuses, and role combinations for visual testing.

@kodiakhq kodiakhq bot merged commit 9d20655 into develop Oct 15, 2025
49 checks passed
@kodiakhq kodiakhq bot deleted the refactor/usersInRole-table branch October 15, 2025 19:29
antm-rp pushed a commit to antm-rp/Rocket.Chat that referenced this pull request Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants