Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: paginate workspaces page #4647

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 44 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
770e473
Start - still needs api call changes
presleyp Oct 14, 2022
13256ce
Some xservice changes
presleyp Oct 14, 2022
76071b9
Finish adding count to xservice
presleyp Oct 14, 2022
bdb0614
Mock out api call on frontend
presleyp Oct 14, 2022
86caa80
Handle errors
presleyp Oct 14, 2022
9317155
Doctor getWorkspaces
presleyp Oct 14, 2022
2a8c1b3
Add types, start writing count function
presleyp Oct 14, 2022
f501786
Hook up route
presleyp Oct 14, 2022
fbcfa36
Use empty page struct
presleyp Oct 17, 2022
939dcdc
Write interface and database fake
presleyp Oct 17, 2022
1b142b4
SQL query
presleyp Oct 17, 2022
ea9f240
Fix params type
presleyp Oct 17, 2022
09791c7
Missed a spot
presleyp Oct 17, 2022
32168a5
Space after alert banner
presleyp Oct 18, 2022
4d8e565
Fix model queries
presleyp Oct 18, 2022
5eea639
Unpack query correctly
presleyp Oct 18, 2022
ef7f59d
Fix filter-page interaction
presleyp Oct 18, 2022
eae13a2
Make mobile friendly
presleyp Oct 18, 2022
b1ab93f
Format
presleyp Oct 18, 2022
fdf74aa
Test backend
presleyp Oct 18, 2022
7b6e822
Fix key
presleyp Oct 18, 2022
644f305
Delete unnecessary conditional
presleyp Oct 18, 2022
8502b05
Add test helpers
presleyp Oct 19, 2022
d838789
Use limit constant
presleyp Oct 19, 2022
2efe49b
Show widget with no count
presleyp Oct 19, 2022
950ac50
Add test
presleyp Oct 19, 2022
296281d
Format
presleyp Oct 19, 2022
e091841
Merge branch 'main' into paginate-ws/presleyp
presleyp Oct 19, 2022
78c231d
make gen from garretts workspace idk why
f0ssel Oct 19, 2022
fc5df6c
fix authorize test'
f0ssel Oct 19, 2022
bb2f0f3
Hide widget with 0 records
presleyp Oct 19, 2022
6174b4f
Fix tests
presleyp Oct 19, 2022
3ab3505
Format
presleyp Oct 19, 2022
a20827c
Fix types generated
presleyp Oct 19, 2022
c06765b
Fix story
presleyp Oct 19, 2022
6bd9683
Add alert banner story
presleyp Oct 19, 2022
de2ed63
Format
presleyp Oct 19, 2022
ff8cb81
Fix import
presleyp Oct 19, 2022
e609e5a
Format
presleyp Oct 19, 2022
476019b
Try removing story
presleyp Oct 19, 2022
833c1af
Merge branch 'main' into paginate-ws/presleyp
presleyp Oct 20, 2022
1f62974
Revert "Fix story"
presleyp Oct 20, 2022
e182c19
Add counts to page view story
presleyp Oct 20, 2022
8bd9afa
Revert "Try removing story"
presleyp Oct 20, 2022
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
Fix tests
  • Loading branch information
presleyp committed Oct 19, 2022
commit 6174b4f10b3f476071e79db2ecb04676a849fa6d
2 changes: 1 addition & 1 deletion site/src/components/PaginationWidget/PaginationWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type PaginationWidgetProps = {
const range = (start: number, stop: number, step = 1) =>
Array.from({ length: (stop - start) / step + 1 }, (_, i) => start + i * step)

export const DEFAULT_RECORDS_PER_PAGE = 2
export const DEFAULT_RECORDS_PER_PAGE = 25
// Number of pages to the left or right of the current page selection.
const PAGE_NEIGHBORS = 1
// Number of pages displayed for cases where there are multiple ellipsis showing. This can be
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/WorkspacePage/WorkspacePage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ describe("WorkspacePage", () => {

await waitFor(() =>
expect(api.startWorkspace).toBeCalledWith(
"test-workspace",
"test-outdated-workspace",
"test-template-version",
),
)
Expand Down
25 changes: 11 additions & 14 deletions site/src/pages/WorkspacesPage/WorkspacesPage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { screen } from "@testing-library/react"
import userEvent from "@testing-library/user-event"
import { screen, waitFor } from "@testing-library/react"
import { rest } from "msw"
import * as CreateDayString from "util/createDayString"
import { Language as WorkspacesTableBodyLanguage } from "../../components/WorkspacesTable/WorkspacesTableBody"
Expand Down Expand Up @@ -35,21 +34,19 @@ describe("WorkspacesPage", () => {

it("renders a filled workspaces page", async () => {
// When
render(<WorkspacesPage />)
const { container } = render(<WorkspacesPage />)

// Then
await screen.findByText(MockWorkspace.name)
})

it("navigates to the next page of workspaces", async () => {
const user = userEvent.setup()
const { container } = render(<WorkspacesPage />)
const nextPage = await screen.findByRole("button", { name: "Next page" })
expect(nextPage).toBeEnabled()
await user.click(nextPage)
const pageButtons = await container.querySelectorAll(
`button[name="Page button"]`,
)
expect(pageButtons.length).toBe(2)
await waitFor(async () => {
const prevPage = await screen.findByRole("button", { name: "Previous page" })
expect(prevPage).toBeDisabled()
const pageButtons = await container.querySelectorAll(
`button[name="Page button"]`,
)
expect(pageButtons.length).toBe(2)
}, { timeout: 2000 })
await screen.findByText(MockWorkspace.name)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { createMachine, assign } from "xstate"
export const deploymentFlagsMachine = createMachine(
{
id: "deploymentFlagsMachine",
predictableActionArguments: true,
initial: "idle",
schema: {
context: {} as {
Expand Down