Skip to content

Commit aa75f57

Browse files
authored
Import PAGE_SIZE constant from QueryTable for all list prefetches (#2160)
PAGE_SIZE constant. incredible
1 parent eeb32a7 commit aa75f57

File tree

21 files changed

+63
-58
lines changed

21 files changed

+63
-58
lines changed

app/components/TopBarPicker.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717

1818
import { useInstanceSelector, useIpPoolSelector, useSiloSelector } from '~/hooks'
1919
import { useCurrentUser } from '~/layouts/AuthenticatedLayout'
20+
import { PAGE_SIZE } from '~/table/QueryTable'
2021
import { Button } from '~/ui/lib/Button'
2122
import { DropdownMenu } from '~/ui/lib/DropdownMenu'
2223
import { Identicon } from '~/ui/lib/Identicon'
@@ -210,7 +211,7 @@ export function SiloSystemPicker({ value }: { value: 'silo' | 'system' }) {
210211
export function SiloPicker() {
211212
// picker only shows up when a silo is in scope
212213
const { silo: siloName } = useSiloSelector()
213-
const { data } = useApiQuery('siloList', { query: { limit: 25 } })
214+
const { data } = useApiQuery('siloList', { query: { limit: PAGE_SIZE } })
214215
const items = (data?.items || []).map((silo) => ({
215216
label: silo.name,
216217
to: pb.silo({ silo: silo.name }),

app/pages/ProjectsPage.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { confirmDelete } from '~/stores/confirm-delete'
2222
import { makeLinkCell } from '~/table/cells/LinkCell'
2323
import { useColsWithActions, type MenuAction } from '~/table/columns/action-col'
2424
import { Columns } from '~/table/columns/common'
25-
import { useQueryTable } from '~/table/QueryTable'
25+
import { PAGE_SIZE, useQueryTable } from '~/table/QueryTable'
2626
import { buttonStyle } from '~/ui/lib/Button'
2727
import { EmptyMessage } from '~/ui/lib/EmptyMessage'
2828
import { PageHeader, PageTitle } from '~/ui/lib/PageHeader'
@@ -42,7 +42,7 @@ const EmptyState = () => (
4242
)
4343

4444
ProjectsPage.loader = async () => {
45-
await apiQueryClient.prefetchQuery('projectList', { query: { limit: 25 } })
45+
await apiQueryClient.prefetchQuery('projectList', { query: { limit: PAGE_SIZE } })
4646
return null
4747
}
4848

@@ -61,7 +61,7 @@ export function ProjectsPage() {
6161
const queryClient = useApiQueryClient()
6262
const { Table } = useQueryTable('projectList', {})
6363
const { data: projects } = usePrefetchedApiQuery('projectList', {
64-
query: { limit: 25 }, // limit to match QueryTable
64+
query: { limit: PAGE_SIZE },
6565
})
6666

6767
const deleteProject = useApiMutation('projectDelete', {

app/pages/project/disks/DisksPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { addToast } from '~/stores/toast'
2626
import { InstanceLinkCell } from '~/table/cells/InstanceLinkCell'
2727
import { useColsWithActions, type MenuAction } from '~/table/columns/action-col'
2828
import { Columns } from '~/table/columns/common'
29-
import { useQueryTable } from '~/table/QueryTable'
29+
import { PAGE_SIZE, useQueryTable } from '~/table/QueryTable'
3030
import { buttonStyle } from '~/ui/lib/Button'
3131
import { EmptyMessage } from '~/ui/lib/EmptyMessage'
3232
import { PageHeader, PageTitle } from '~/ui/lib/PageHeader'
@@ -49,7 +49,7 @@ DisksPage.loader = async ({ params }: LoaderFunctionArgs) => {
4949
const { project } = getProjectSelector(params)
5050
await Promise.all([
5151
apiQueryClient.prefetchQuery('diskList', {
52-
query: { project, limit: 25 },
52+
query: { project, limit: PAGE_SIZE },
5353
}),
5454

5555
// fetch instances and preload into RQ cache so fetches by ID in

app/pages/project/floating-ips/FloatingIpsPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { addToast } from '~/stores/toast'
2929
import { InstanceLinkCell } from '~/table/cells/InstanceLinkCell'
3030
import { useColsWithActions, type MenuAction } from '~/table/columns/action-col'
3131
import { Columns } from '~/table/columns/common'
32-
import { useQueryTable } from '~/table/QueryTable'
32+
import { PAGE_SIZE, useQueryTable } from '~/table/QueryTable'
3333
import { EmptyMessage } from '~/ui/lib/EmptyMessage'
3434
import { Listbox } from '~/ui/lib/Listbox'
3535
import { Message } from '~/ui/lib/Message'
@@ -53,7 +53,7 @@ FloatingIpsPage.loader = async ({ params }: LoaderFunctionArgs) => {
5353
const { project } = getProjectSelector(params)
5454
await Promise.all([
5555
apiQueryClient.prefetchQuery('floatingIpList', {
56-
query: { project, limit: 25 },
56+
query: { project, limit: PAGE_SIZE },
5757
}),
5858
apiQueryClient.prefetchQuery('instanceList', {
5959
query: { project },

app/pages/project/images/ImagesPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { addToast } from '~/stores/toast'
1818
import { makeLinkCell } from '~/table/cells/LinkCell'
1919
import { getActionsCol, type MenuAction } from '~/table/columns/action-col'
2020
import { Columns } from '~/table/columns/common'
21-
import { useQueryTable } from '~/table/QueryTable'
21+
import { PAGE_SIZE, useQueryTable } from '~/table/QueryTable'
2222
import { buttonStyle } from '~/ui/lib/Button'
2323
import { EmptyMessage } from '~/ui/lib/EmptyMessage'
2424
import { Message } from '~/ui/lib/Message'
@@ -42,7 +42,7 @@ const colHelper = createColumnHelper<Image>()
4242
ImagesPage.loader = async ({ params }: LoaderFunctionArgs) => {
4343
const { project } = getProjectSelector(params)
4444
await apiQueryClient.prefetchQuery('imageList', {
45-
query: { project, limit: 25 },
45+
query: { project, limit: PAGE_SIZE },
4646
})
4747
return null
4848
}

app/pages/project/instances/InstancesPage.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { InstanceStatusCell } from '~/table/cells/InstanceStatusCell'
2323
import { makeLinkCell } from '~/table/cells/LinkCell'
2424
import { getActionsCol } from '~/table/columns/action-col'
2525
import { Columns } from '~/table/columns/common'
26-
import { useQueryTable } from '~/table/QueryTable'
26+
import { PAGE_SIZE, useQueryTable } from '~/table/QueryTable'
2727
import { Button, buttonStyle } from '~/ui/lib/Button'
2828
import { EmptyMessage } from '~/ui/lib/EmptyMessage'
2929
import { PageHeader, PageTitle } from '~/ui/lib/PageHeader'
@@ -46,7 +46,9 @@ const colHelper = createColumnHelper<Instance>()
4646

4747
InstancesPage.loader = async ({ params }: LoaderFunctionArgs) => {
4848
const { project } = getProjectSelector(params)
49-
await apiQueryClient.prefetchQuery('instanceList', { query: { project, limit: 25 } })
49+
await apiQueryClient.prefetchQuery('instanceList', {
50+
query: { project, limit: PAGE_SIZE },
51+
})
5052
return null
5153
}
5254

@@ -59,7 +61,7 @@ export function InstancesPage() {
5961
const makeActions = useMakeInstanceActions({ project }, { onSuccess: refetchInstances })
6062

6163
const { data: instances } = usePrefetchedApiQuery('instanceList', {
62-
query: { project, limit: 25 }, // to have same params as QueryTable
64+
query: { project, limit: PAGE_SIZE },
6365
})
6466

6567
const navigate = useNavigate()

app/pages/project/instances/instance/tabs/StorageTab.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { getInstanceSelector, useInstanceSelector } from '~/hooks'
2828
import { addToast } from '~/stores/toast'
2929
import { useColsWithActions, type MenuAction } from '~/table/columns/action-col'
3030
import { Columns } from '~/table/columns/common'
31-
import { useQueryTable } from '~/table/QueryTable'
31+
import { PAGE_SIZE, useQueryTable } from '~/table/QueryTable'
3232
import { Button } from '~/ui/lib/Button'
3333
import { EmptyMessage } from '~/ui/lib/EmptyMessage'
3434

@@ -39,7 +39,7 @@ StorageTab.loader = async ({ params }: LoaderFunctionArgs) => {
3939
await Promise.all([
4040
apiQueryClient.prefetchQuery('instanceDiskList', {
4141
path: { instance },
42-
query: { project, limit: 25 }, // querytable
42+
query: { project, limit: PAGE_SIZE },
4343
}),
4444
// This is covered by the InstancePage loader but there's no downside to
4545
// being redundant. If it were removed there, we'd still want it here.

app/pages/project/snapshots/SnapshotsPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { confirmDelete } from '~/stores/confirm-delete'
2424
import { SkeletonCell } from '~/table/cells/EmptyCell'
2525
import { useColsWithActions, type MenuAction } from '~/table/columns/action-col'
2626
import { Columns } from '~/table/columns/common'
27-
import { useQueryTable } from '~/table/QueryTable'
27+
import { PAGE_SIZE, useQueryTable } from '~/table/QueryTable'
2828
import { Badge } from '~/ui/lib/Badge'
2929
import { buttonStyle } from '~/ui/lib/Button'
3030
import { EmptyMessage } from '~/ui/lib/EmptyMessage'
@@ -54,7 +54,7 @@ SnapshotsPage.loader = async ({ params }: LoaderFunctionArgs) => {
5454
const { project } = getProjectSelector(params)
5555
await Promise.all([
5656
apiQueryClient.prefetchQuery('snapshotList', {
57-
query: { project, limit: 25 },
57+
query: { project, limit: PAGE_SIZE },
5858
}),
5959

6060
// Fetch disks and preload into RQ cache so fetches by ID in DiskNameFromId

app/pages/project/vpcs/VpcPage/VpcPage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { Networking24Icon } from '@oxide/design-system/icons/react'
1313
import { QueryParamTabs } from '~/components/QueryParamTabs'
1414
import { getVpcSelector, useVpcSelector } from '~/hooks'
1515
import { EmptyCell } from '~/table/cells/EmptyCell'
16+
import { PAGE_SIZE } from '~/table/QueryTable'
1617
import { DateTime } from '~/ui/lib/DateTime'
1718
import { PageHeader, PageTitle } from '~/ui/lib/PageHeader'
1819
import { PropertiesTable } from '~/ui/lib/PropertiesTable'
@@ -29,7 +30,7 @@ VpcPage.loader = async ({ params }: LoaderFunctionArgs) => {
2930
query: { project, vpc },
3031
}),
3132
apiQueryClient.prefetchQuery('vpcSubnetList', {
32-
query: { project, vpc, limit: 25 },
33+
query: { project, vpc, limit: PAGE_SIZE },
3334
}),
3435
])
3536
return null

app/pages/project/vpcs/VpcsPage.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { confirmDelete } from '~/stores/confirm-delete'
2323
import { makeLinkCell } from '~/table/cells/LinkCell'
2424
import { getActionsCol, type MenuAction } from '~/table/columns/action-col'
2525
import { Columns } from '~/table/columns/common'
26-
import { useQueryTable } from '~/table/QueryTable'
26+
import { PAGE_SIZE, useQueryTable } from '~/table/QueryTable'
2727
import { buttonStyle } from '~/ui/lib/Button'
2828
import { EmptyMessage } from '~/ui/lib/EmptyMessage'
2929
import { PageHeader, PageTitle } from '~/ui/lib/PageHeader'
@@ -42,19 +42,21 @@ const EmptyState = () => (
4242

4343
const colHelper = createColumnHelper<Vpc>()
4444

45-
// just as in the vpcList call for the quick actions menu, include limit: 25 to make
45+
// just as in the vpcList call for the quick actions menu, include limit to make
4646
// sure it matches the call in the QueryTable
4747
VpcsPage.loader = async ({ params }: LoaderFunctionArgs) => {
4848
const { project } = getProjectSelector(params)
49-
await apiQueryClient.prefetchQuery('vpcList', { query: { project, limit: 25 } })
49+
await apiQueryClient.prefetchQuery('vpcList', { query: { project, limit: PAGE_SIZE } })
5050
return null
5151
}
5252

5353
export function VpcsPage() {
5454
const queryClient = useApiQueryClient()
5555
const { project } = useProjectSelector()
5656
// to have same params as QueryTable
57-
const { data: vpcs } = usePrefetchedApiQuery('vpcList', { query: { project, limit: 25 } })
57+
const { data: vpcs } = usePrefetchedApiQuery('vpcList', {
58+
query: { project, limit: PAGE_SIZE },
59+
})
5860
const navigate = useNavigate()
5961

6062
const deleteVpc = useApiMutation('vpcDelete', {

0 commit comments

Comments
 (0)