8000 feat: add count endpoint for users, enabling better pagination by presleyp · Pull Request #4848 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: add count endpoint for users, enabling better pagination #4848

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

Merged
merged 18 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Format
  • Loading branch information
presleyp committed Nov 2, 2022
commit 424358ef15d90f37c3343c38953ae43298a8d505
5 changes: 3 additions & 2 deletions site/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ export const getUser = async (): Promise<TypesGen.User> => {
return response.data
}


export const getAuthMethods = async (): Promise<TypesGen.AuthMethods> => {
const response = await axios.get<TypesGen.AuthMethods>(
"/api/v2/users/authmethods",
Expand Down Expand Up @@ -140,7 +139,9 @@ export const getUsers = async (
return response.data
}

export const getUserCount = async (options: TypesGen.UserCountRequest): Promise<TypesGen.UserCountResponse> => {
export const getUserCount = async (
options: TypesGen.UserCountRequest,
): Promise<TypesGen.UserCountResponse> => {
const url = getURLWithSearchParams("/api/v2/users/count", options)
const response = await axios.get(url.toString())
return response.data
Expand Down
4 changes: 3 additions & 1 deletion site/src/pages/UsersPage/UsersPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ describe("UsersPage", () => {
expect(API.getUsers).toBeCalledWith({ offset: 0, limit: 25, q: "" }),
)

const pageButtons = await container.querySelectorAll(`button[name="Page button"]`)
const pageButtons = await container.querySelectorAll(
`button[name="Page button"]`,
)
// count handler says there are 2 pages of results
expect(pageButtons.length).toBe(2)
})
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/UsersPage/UsersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const UsersPage: FC<{ children?: ReactNode }> = () => {
userIdToResetPassword,
newUserPassword,
paginationRef,
count
count,
} = usersState.context

const { updateUsers: canEditUsers } = usePermissions()
Expand Down
2 changes: 1 addition & 1 deletion site/src/testHelpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const MockUser: TypesGen.User = {
}

export const MockUserCountResponse: TypesGen.UserCountResponse = {
count: 26
count: 26,
}

export const MockUserAdmin: TypesGen.User = {
Expand Down
Loading
0