Skip to content

Commit 953428b

Browse files
committed
Format
1 parent 2e249a0 commit 953428b

File tree

5 files changed

+37
-29
lines changed

5 files changed

+37
-29
lines changed

site/src/api/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ interface SearchParamOptions extends TypesGen.Pagination {
270270

271271
export const getURLWithSearchParams = (
272272
basePath: string,
273-
options?: SearchParamOptions
273+
options?: SearchParamOptions,
274274
): string => {
275275
if (options) {
276276
const searchParams = new URLSearchParams()

site/src/components/PaginationWidget/PaginationWidget.tsx

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ export const PaginationWidget = ({
3434
const currentPage = paginationState.context.page
3535
const numRecordsPerPage = paginationState.context.limit
3636

37-
const numPages = numRecords ? Math.ceil(numRecords / numRecordsPerPage) : undefined
37+
const numPages = numRecords
38+
? Math.ceil(numRecords / numRecordsPerPage)
39+
: undefined
3840
const firstPageActive = currentPage === 1 && numPages !== 0
3941
const lastPageActive = currentPage === numPages && numPages !== 0
4042

4143
// No need to display any pagination if we know the number of pages is 1 or 0
42-
if (numPages && numPages <= 1 || numRecords === 0) {
44+
if ((numPages && numPages <= 1) || numRecords === 0) {
4345
return null
4446
}
4547

@@ -64,24 +66,25 @@ export const PaginationWidget = ({
6466
/>
6567
</Cond>
6668
<Cond>
67-
{numPages && buildPagedList(numPages, currentPage).map((page) =>
68-
typeof page !== "number" ? (
69-
<PageButton
70-
key={`Page${page}`}
71-
activePage={currentPage}
72-
placeholder="..."
73-
disabled
74-
/>
75-
) : (
76-
<PageButton
77-
key={`Page${page}`}
78-
activePage={currentPage}
79-
page={page}
80-
numPages={numPages}
81-
onPageClick={() => send({ type: "GO_TO_PAGE", page })}
82-
/>
83-
),
84-
)}
69+
{numPages &&
70+
buildPagedList(numPages, currentPage).map((page) =>
71+
typeof page !== "number" ? (
72+
<PageButton
73+
key={`Page${page}`}
74+
activePage={currentPage}
75+
placeholder="..."
76+
disabled
77+
/>
78+
) : (
79+
<PageButton
80+
key={`Page${page}`}
81+
activePage={currentPage}
82+
page={page}
83+
numPages={numPages}
84+
onPageClick={() => send({ type: "GO_TO_PAGE", page })}
85+
/>
86+
),
87+
)}
8588
</Cond>
8689
</ChooseOne>
8790
</Maybe>

site/src/pages/UsersPage/UsersPage.test.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,6 @@ describe("UsersPage", () => {
197197
expect(users.length).toEqual(3)
198198
})
199199

200-
201-
202200
describe("suspend user", () => {
203201
describe("when it is success", () => {
204202
it("shows a success message and refresh the page", async () => {
@@ -252,13 +250,17 @@ describe("UsersPage", () => {
252250
const nextButton = await screen.findByLabelText("Next page")
253251
await user.click(nextButton)
254252

255-
await waitFor(() => expect(API.getUsers).toBeCalledWith({ offset: 25, limit: 25, q: "" }))
253+
await waitFor(() =>
254+
expect(API.getUsers).toBeCalledWith({ offset: 25, limit: 25, q: "" }),
255+
)
256256

257257
mock.mockClear()
258258
const previousButton = await screen.findByLabelText("Previous page")
259259
await user.click(previousButton)
260260

261-
await waitFor(() => expect(API.getUsers).toBeCalledWith({ offset: 0, limit: 25, q: "" }))
261+
await waitFor(() =>
262+
expect(API.getUsers).toBeCalledWith({ offset: 0, limit: 25, q: "" }),
263+
)
262264
})
263265
})
264266

site/src/pages/UsersPage/UsersPageView.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ export default {
1212
component: UsersPageView,
1313
argTypes: {
1414
paginationRef: {
15-
defaultValue: createPaginationRef({ page: 1, limit: 25 })
16-
}
17-
}
15+
defaultValue: createPaginationRef({ page: 1, limit: 25 }),
16+
},
17+
},
1818
} as ComponentMeta<typeof UsersPageView>
1919

2020
const Template: Story<UsersPageViewProps> = (args) => (

site/src/testHelpers/entities.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ export function assignableRole(
6161
}
6262

6363
export const MockSiteRoles = [MockUserAdminRole, MockAuditorRole]
64-
export const MockAssignableSiteRoles = [assignableRole(MockUserAdminRole, true), assignableRole(MockAuditorRole, true)]
64+
export const MockAssignableSiteRoles = [
65+
assignableRole(MockUserAdminRole, true),
66+
assignableRole(MockAuditorRole, true),
67+
]
6568

6669
export const MockMemberPermissions = {
6770
viewAuditLog: false,

0 commit comments

Comments
 (0)