Skip to content

Commit 57db405

Browse files
authored
Extract const for APPROXIMATELY_EVERYTHING (#2462)
* replace limit: 1000 with new APPROXIMATELY_EVERYTHING const * APPROXIMATELY_EVERYTHING → ALL_ISH * single-line queries with shorter const name
1 parent da7fe32 commit 57db405

File tree

14 files changed

+52
-36
lines changed

14 files changed

+52
-36
lines changed

app/api/window.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
// Here we add some handy stuff to window for use from the browser JS console.
1010
// requests will use the session cookie, same as normal API calls
1111

12+
import { ALL_ISH } from '~/util/consts'
13+
1214
import { type ApiResult } from './__generated__/http-client'
1315
import { api } from './client'
1416

@@ -58,7 +60,7 @@ if (typeof window !== 'undefined') {
5860
return data
5961
},
6062
schemas: async (search?: string) => {
61-
const result = await api.methods.timeseriesSchemaList({ query: { limit: 1000 } })
63+
const result = await api.methods.timeseriesSchemaList({ query: { limit: ALL_ISH } })
6264
const data = handleResult(result)
6365

6466
let filtered = data.items

app/components/AttachEphemeralIpModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ import { useInstanceSelector } from '~/hooks/use-params'
1515
import { addToast } from '~/stores/toast'
1616
import { Badge } from '~/ui/lib/Badge'
1717
import { Modal } from '~/ui/lib/Modal'
18+
import { ALL_ISH } from '~/util/consts'
1819

1920
export const AttachEphemeralIpModal = ({ onDismiss }: { onDismiss: () => void }) => {
2021
const queryClient = useApiQueryClient()
2122
const { project, instance } = useInstanceSelector()
2223
const { data: siloPools } = usePrefetchedApiQuery('projectIpPoolList', {
23-
query: { limit: 1000 },
24+
query: { limit: ALL_ISH },
2425
})
2526
const defaultPool = useMemo(
2627
() => siloPools?.items.find((pool) => pool.isDefault),

app/forms/disk-attach.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { useApiQuery, type ApiError } from '@oxide/api'
1212
import { ComboboxField } from '~/components/form/fields/ComboboxField'
1313
import { SideModalForm } from '~/components/form/SideModalForm'
1414
import { useProjectSelector } from '~/hooks/use-params'
15+
import { ALL_ISH } from '~/util/consts'
1516

1617
const defaultValues = { name: '' }
1718

@@ -37,7 +38,9 @@ export function AttachDiskSideModalForm({
3738
}: AttachDiskProps) {
3839
const { project } = useProjectSelector()
3940

40-
const { data } = useApiQuery('diskList', { query: { project, limit: 1000 } })
41+
const { data } = useApiQuery('diskList', {
42+
query: { project, limit: ALL_ISH },
43+
})
4144
const detachedDisks =
4245
data?.items.filter(
4346
(d) => d.state.state === 'detached' && !diskNamesToExclude.includes(d.name)

app/forms/firewall-rules-common.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { Message } from '~/ui/lib/Message'
3838
import * as MiniTable from '~/ui/lib/MiniTable'
3939
import { TextInputHint } from '~/ui/lib/TextInput'
4040
import { KEYS } from '~/ui/util/keys'
41+
import { ALL_ISH } from '~/util/consts'
4142
import { links } from '~/util/links'
4243
import { capitalize } from '~/util/str'
4344

@@ -243,14 +244,10 @@ export const CommonFields = ({ control, nameTaken, error }: CommonFieldsProps) =
243244
// prefetchedApiQueries below are prefetched in firewall-rules-create and -edit
244245
const {
245246
data: { items: instances },
246-
} = usePrefetchedApiQuery('instanceList', {
247-
query: { project, limit: 1000 },
248-
})
247+
} = usePrefetchedApiQuery('instanceList', { query: { project, limit: ALL_ISH } })
249248
const {
250249
data: { items: vpcs },
251-
} = usePrefetchedApiQuery('vpcList', {
252-
query: { project, limit: 1000 },
253-
})
250+
} = usePrefetchedApiQuery('vpcList', { query: { project, limit: ALL_ISH } })
254251
const {
255252
data: { items: vpcSubnets },
256253
} = usePrefetchedApiQuery('vpcSubnetList', { query: { project, vpc } })

app/forms/firewall-rules-create.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
import { SideModalForm } from '~/components/form/SideModalForm'
2121
import { getVpcSelector, useVpcSelector } from '~/hooks/use-params'
2222
import { addToast } from '~/stores/toast'
23+
import { ALL_ISH } from '~/util/consts'
2324
import { pb } from '~/util/path-builder'
2425

2526
import { CommonFields } from './firewall-rules-common'
@@ -57,8 +58,8 @@ CreateFirewallRuleForm.loader = async ({ params }: LoaderFunctionArgs) => {
5758
const { project, vpc } = getVpcSelector(params)
5859
await Promise.all([
5960
apiQueryClient.prefetchQuery('vpcFirewallRulesView', { query: { project, vpc } }),
60-
apiQueryClient.prefetchQuery('instanceList', { query: { project, limit: 1000 } }),
61-
apiQueryClient.prefetchQuery('vpcList', { query: { project, limit: 1000 } }),
61+
apiQueryClient.prefetchQuery('instanceList', { query: { project, limit: ALL_ISH } }),
62+
apiQueryClient.prefetchQuery('vpcList', { query: { project, limit: ALL_ISH } }),
6263
apiQueryClient.prefetchQuery('vpcSubnetList', { query: { project, vpc } }),
6364
])
6465

app/forms/firewall-rules-edit.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
useFirewallRuleSelector,
2424
useVpcSelector,
2525
} from '~/hooks/use-params'
26+
import { ALL_ISH } from '~/util/consts'
2627
import { invariant } from '~/util/invariant'
2728
import { pb } from '~/util/path-builder'
2829

@@ -34,8 +35,8 @@ EditFirewallRuleForm.loader = async ({ params }: LoaderFunctionArgs) => {
3435

3536
const [firewallRules] = await Promise.all([
3637
apiQueryClient.fetchQuery('vpcFirewallRulesView', { query: { project, vpc } }),
37-
apiQueryClient.prefetchQuery('instanceList', { query: { project, limit: 1000 } }),
38-
apiQueryClient.prefetchQuery('vpcList', { query: { project, limit: 1000 } }),
38+
apiQueryClient.prefetchQuery('instanceList', { query: { project, limit: ALL_ISH } }),
39+
apiQueryClient.prefetchQuery('vpcList', { query: { project, limit: ALL_ISH } }),
3940
apiQueryClient.prefetchQuery('vpcSubnetList', { query: { project, vpc } }),
4041
])
4142

app/forms/floating-ip-create.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { useProjectSelector } from '~/hooks/use-params'
2727
import { addToast } from '~/stores/toast'
2828
import { Badge } from '~/ui/lib/Badge'
2929
import { Message } from '~/ui/lib/Message'
30+
import { ALL_ISH } from '~/util/consts'
3031
import { pb } from '~/util/path-builder'
3132

3233
const toListboxItem = (p: SiloIpPool) => {
@@ -57,9 +58,7 @@ const defaultValues: Omit<FloatingIpCreate, 'ip'> = {
5758
export function CreateFloatingIpSideModalForm() {
5859
// Fetch 1000 to we can be sure to get them all. Don't bother prefetching
5960
// because the list is hidden under the Advanced accordion.
60-
const { data: allPools } = useApiQuery('projectIpPoolList', {
61-
query: { limit: 1000 },
62-
})
61+
const { data: allPools } = useApiQuery('projectIpPoolList', { query: { limit: ALL_ISH } })
6362

6463
const queryClient = useApiQueryClient()
6564
const projectSelector = useProjectSelector()

app/forms/instance-create.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import { Slash } from '~/ui/lib/Slash'
7272
import { Tabs } from '~/ui/lib/Tabs'
7373
import { TextInputHint } from '~/ui/lib/TextInput'
7474
import { TipIcon } from '~/ui/lib/TipIcon'
75+
import { ALL_ISH } from '~/util/consts'
7576
import { readBlobAsBase64 } from '~/util/file'
7677
import { docLinks, links } from '~/util/links'
7778
import { nearest10 } from '~/util/math'
@@ -161,8 +162,8 @@ CreateInstanceForm.loader = async ({ params }: LoaderFunctionArgs) => {
161162
query: { project, limit: DISK_FETCH_LIMIT },
162163
}),
163164
apiQueryClient.prefetchQuery('currentUserSshKeyList', {}),
164-
apiQueryClient.prefetchQuery('projectIpPoolList', { query: { limit: 1000 } }),
165-
apiQueryClient.prefetchQuery('floatingIpList', { query: { project, limit: 1000 } }),
165+
apiQueryClient.prefetchQuery('projectIpPoolList', { query: { limit: ALL_ISH } }),
166+
apiQueryClient.prefetchQuery('floatingIpList', { query: { project, limit: ALL_ISH } }),
166167
])
167168
return null
168169
}
@@ -208,7 +209,7 @@ export function CreateInstanceForm() {
208209

209210
// projectIpPoolList fetches the pools linked to the current silo
210211
const { data: siloPools } = usePrefetchedApiQuery('projectIpPoolList', {
211-
query: { limit: 1000 },
212+
query: { limit: ALL_ISH },
212213
})
213214
const defaultPool = useMemo(
214215
() => (siloPools ? siloPools.items.find((p) => p.isDefault)?.name : undefined),
@@ -627,7 +628,7 @@ const AdvancedAccordion = ({
627628

628629
const { project } = useProjectSelector()
629630
const { data: floatingIpList } = usePrefetchedApiQuery('floatingIpList', {
630-
query: { project, limit: 1000 },
631+
query: { project, limit: ALL_ISH },
631632
})
632633

633634
// Filter out the IPs that are already attached to an instance

app/forms/snapshot-create.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ import { NameField } from '~/components/form/fields/NameField'
2323
import { SideModalForm } from '~/components/form/SideModalForm'
2424
import { useProjectSelector } from '~/hooks/use-params'
2525
import { addToast } from '~/stores/toast'
26+
import { ALL_ISH } from '~/util/consts'
2627
import { pb } from '~/util/path-builder'
2728

2829
const useSnapshotDiskItems = (projectSelector: PP.Project) => {
2930
const { data: disks } = useApiQuery('diskList', {
30-
query: { ...projectSelector, limit: 1000 },
31+
query: { ...projectSelector, limit: ALL_ISH },
3132
})
3233
return (
3334
disks?.items

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { Modal } from '~/ui/lib/Modal'
4040
import { PageHeader, PageTitle } from '~/ui/lib/PageHeader'
4141
import { TableActions } from '~/ui/lib/Table'
4242
import { Tooltip } from '~/ui/lib/Tooltip'
43+
import { ALL_ISH } from '~/util/consts'
4344
import { docLinks } from '~/util/links'
4445
import { pb } from '~/util/path-builder'
4546

@@ -63,7 +64,7 @@ FloatingIpsPage.loader = async ({ params }: LoaderFunctionArgs) => {
6364
query: { project },
6465
}),
6566
apiQueryClient
66-
.fetchQuery('projectIpPoolList', { query: { limit: 1000 } })
67+
.fetchQuery('projectIpPoolList', { query: { limit: ALL_ISH } })
6768
.then((pools) => {
6869
for (const pool of pools.items) {
6970
apiQueryClient.setQueryData(

0 commit comments

Comments
 (0)