Skip to content

Commit 8b8e83d

Browse files
authored
Fix some missing limit: ALL_ISH (#3360)
Closes #3359 First commit fixes the narrow issue reported with the list of projects on image demote. Second commit fixes other spots found by the 🤖.
1 parent 46f3fd8 commit 8b8e83d

10 files changed

Lines changed: 47 additions & 26 deletions

File tree

‎.oxlintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,5 @@
154154
}
155155
}
156156
],
157-
"ignorePatterns": ["dist/", "node_modules/"]
157+
"ignorePatterns": ["dist/", "node_modules/", ".claude/"]
158158
}

‎app/api/roles.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import { useMemo } from 'react'
1515
import * as R from 'remeda'
1616

17+
import { ALL_ISH } from '~/util/consts'
18+
1719
import type { FleetRole, IdentityType, ProjectRole, SiloRole } from './__generated__/Api'
1820
import { api, q, usePrefetchedQuery } from './client'
1921

@@ -111,8 +113,10 @@ export function useUserRows<Role extends RoleKey = RoleKey>(
111113
): UserAccessRow<Role>[] {
112114
// HACK: because the policy has no names, we are fetching ~all the users,
113115
// putting them in a dictionary, and adding the names to the rows
114-
const { data: users } = usePrefetchedQuery(q(api.userList, {}))
115-
const { data: groups } = usePrefetchedQuery(q(api.groupList, {}))
116+
const { data: users } = usePrefetchedQuery(q(api.userList, { query: { limit: ALL_ISH } }))
117+
const { data: groups } = usePrefetchedQuery(
118+
q(api.groupList, { query: { limit: ALL_ISH } })
119+
)
116120
return useMemo(() => {
117121
const userItems = users?.items || []
118122
const groupItems = groups?.items || []
@@ -156,8 +160,10 @@ export type Actor = {
156160
export function useActorsNotInPolicy<Role extends RoleKey = RoleKey>(
157161
policy: Policy<Role>
158162
): Actor[] {
159-
const { data: users } = usePrefetchedQuery(q(api.userList, {}))
160-
const { data: groups } = usePrefetchedQuery(q(api.groupList, {}))
163+
const { data: users } = usePrefetchedQuery(q(api.userList, { query: { limit: ALL_ISH } }))
164+
const { data: groups } = usePrefetchedQuery(
165+
q(api.groupList, { query: { limit: ALL_ISH } })
166+
)
161167
return useMemo(() => {
162168
// IDs are UUIDs, so no need to include identity type in set value to disambiguate
163169
const actorsInPolicy = new Set(policy?.roleAssignments.map((ra) => ra.identityId) || [])

‎app/components/form/fields/SshKeysField.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { FieldLabel } from '~/ui/lib/FieldLabel'
2121
import { Message } from '~/ui/lib/Message'
2222
import { TextInputHint } from '~/ui/lib/TextInput'
2323
import { isSubset } from '~/util/array'
24+
import { ALL_ISH } from '~/util/consts'
2425

2526
import { CheckboxField } from './CheckboxField'
2627
import { ErrorMessage } from './ErrorMessage'
@@ -56,7 +57,9 @@ export function SshKeysField({
5657
control: Control<InstanceCreateInput>
5758
isSubmitting: boolean
5859
}) {
59-
const allKeys = usePrefetchedQuery(q(api.currentUserSshKeyList, {})).data.items
60+
const allKeys = usePrefetchedQuery(
61+
q(api.currentUserSshKeyList, { query: { limit: ALL_ISH } })
62+
).data.items
6063
const [showAddSshKey, setShowAddSshKey] = useState(false)
6164

6265
const {

‎app/forms/disk-create.tsx‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { Radio } from '~/ui/lib/Radio'
4040
import { RadioGroup } from '~/ui/lib/RadioGroup'
4141
import { Slash } from '~/ui/lib/Slash'
4242
import { TipIcon } from '~/ui/lib/TipIcon'
43+
import { ALL_ISH } from '~/util/consts'
4344
import { toLocaleDateString } from '~/util/date'
4445
import { docLinks } from '~/util/links'
4546
import { diskSizeNearest10 } from '~/util/math'
@@ -109,8 +110,8 @@ export function CreateDiskSideModalForm({
109110

110111
const form = useForm({ defaultValues })
111112
const { project } = useProjectSelector()
112-
const projectImages = useQuery(q(api.imageList, { query: { project } }))
113-
const siloImages = useQuery(q(api.imageList, {}))
113+
const projectImages = useQuery(q(api.imageList, { query: { project, limit: ALL_ISH } }))
114+
const siloImages = useQuery(q(api.imageList, { query: { limit: ALL_ISH } }))
114115

115116
// put project images first because if there are any, there probably aren't
116117
// very many and they're probably relevant
@@ -120,7 +121,9 @@ export function CreateDiskSideModalForm({
120121
)
121122
const areImagesLoading = projectImages.isPending || siloImages.isPending
122123

123-
const snapshotsQuery = useQuery(q(api.snapshotList, { query: { project } }))
124+
const snapshotsQuery = useQuery(
125+
q(api.snapshotList, { query: { project, limit: ALL_ISH } })
126+
)
124127
const snapshots = snapshotsQuery.data?.items || []
125128

126129
// validate disk source size
@@ -404,7 +407,9 @@ const DiskNameFromId = ({ disk }: { disk: string }) => {
404407

405408
const SnapshotSelectField = ({ control }: { control: Control<DiskCreateForm> }) => {
406409
const { project } = useProjectSelector()
407-
const snapshotsQuery = useQuery(q(api.snapshotList, { query: { project } }))
410+
const snapshotsQuery = useQuery(
411+
q(api.snapshotList, { query: { project, limit: ALL_ISH } })
412+
)
408413

409414
const snapshots = snapshotsQuery.data?.items || []
410415
const diskSizeField = useController({ control, name: 'size' }).field

‎app/forms/instance-create.tsx‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,10 @@ export async function clientLoader({ params }: LoaderFunctionArgs) {
236236
const { project } = getProjectSelector(params)
237237
await Promise.all([
238238
// fetch both project and silo images
239-
queryClient.prefetchQuery(q(api.imageList, { query: { project } })),
240-
queryClient.prefetchQuery(q(api.imageList, {})),
239+
queryClient.prefetchQuery(q(api.imageList, { query: { project, limit: ALL_ISH } })),
240+
queryClient.prefetchQuery(q(api.imageList, { query: { limit: ALL_ISH } })),
241241
queryClient.prefetchQuery(q(api.diskList, { query: { project, limit: ALL_ISH } })),
242-
queryClient.prefetchQuery(q(api.currentUserSshKeyList, {})),
242+
queryClient.prefetchQuery(q(api.currentUserSshKeyList, { query: { limit: ALL_ISH } })),
243243
queryClient.prefetchQuery(q(api.ipPoolList, { query: { limit: ALL_ISH } })),
244244
queryClient.prefetchQuery(
245245
q(api.floatingIpList, { query: { project, limit: ALL_ISH } })
@@ -378,9 +378,11 @@ export default function CreateInstanceForm() {
378378
},
379379
})
380380

381-
const siloImages = usePrefetchedQuery(q(api.imageList, {})).data.items
382-
const projectImages = usePrefetchedQuery(q(api.imageList, { query: { project } })).data
383-
.items
381+
const siloImages = usePrefetchedQuery(q(api.imageList, { query: { limit: ALL_ISH } }))
382+
.data.items
383+
const projectImages = usePrefetchedQuery(
384+
q(api.imageList, { query: { project, limit: ALL_ISH } })
385+
).data.items
384386
const allImages = [...siloImages, ...projectImages]
385387

386388
const defaultImage = allImages[0]
@@ -390,7 +392,9 @@ export default function CreateInstanceForm() {
390392
).data.items
391393
const disks = useMemo(() => toComboboxItems(allDisks.filter(diskCan.attach)), [allDisks])
392394

393-
const { data: sshKeys } = usePrefetchedQuery(q(api.currentUserSshKeyList, {}))
395+
const { data: sshKeys } = usePrefetchedQuery(
396+
q(api.currentUserSshKeyList, { query: { limit: ALL_ISH } })
397+
)
394398
const allKeys = useMemo(() => sshKeys.items.map((key) => key.id), [sshKeys])
395399

396400
// ipPoolList fetches the pools linked to the current silo

‎app/pages/SiloAccessPage.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { PageHeader, PageTitle } from '~/ui/lib/PageHeader'
4141
import { TableActions, TableEmptyBox } from '~/ui/lib/Table'
4242
import { identityTypeLabel, roleColor } from '~/util/access'
4343
import { groupBy } from '~/util/array'
44+
import { ALL_ISH } from '~/util/consts'
4445
import { docLinks } from '~/util/links'
4546

4647
const EmptyState = ({ onClick }: { onClick: () => void }) => (
@@ -56,8 +57,8 @@ const EmptyState = ({ onClick }: { onClick: () => void }) => (
5657
)
5758

5859
const policyView = q(api.policyView, {})
59-
const userList = q(api.userList, {})
60-
const groupList = q(api.groupList, {})
60+
const userList = q(api.userList, { query: { limit: ALL_ISH } })
61+
const groupList = q(api.groupList, { query: { limit: ALL_ISH } })
6162

6263
export async function clientLoader() {
6364
await Promise.all([

‎app/pages/SiloImagesPage.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ const PromoteImageModal = ({ onDismiss }: { onDismiss: () => void }) => {
170170
},
171171
})
172172

173-
const projects = useQuery(q(api.projectList, {}))
173+
const projects = useQuery(q(api.projectList, { query: { limit: ALL_ISH } }))
174174
const projectItems = useMemo(() => toComboboxItems(projects.data?.items), [projects.data])
175175
const selectedProject = form.watch('project')
176176

@@ -268,7 +268,7 @@ const DemoteImageModal = ({
268268
},
269269
})
270270

271-
const projects = useQuery(q(api.projectList, {}))
271+
const projects = useQuery(q(api.projectList, { query: { limit: ALL_ISH } }))
272272
const projectItems = useMemo(() => toComboboxItems(projects.data?.items), [projects.data])
273273

274274
return (

‎app/pages/SiloUtilizationPage.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ import { useCurrentUser } from '~/hooks/use-current-user'
2121
import { Divider } from '~/ui/lib/Divider'
2222
import { Listbox } from '~/ui/lib/Listbox'
2323
import { PageHeader, PageTitle } from '~/ui/lib/PageHeader'
24+
import { ALL_ISH } from '~/util/consts'
2425
import { docLinks } from '~/util/links'
2526
import { bytesToGiB, bytesToTiB } from '~/util/units'
2627

2728
const toListboxItem = (x: { name: string; id: string }) => ({ label: x.name, value: x.id })
2829

29-
const projectList = q(api.projectList, {})
30+
const projectList = q(api.projectList, { query: { limit: ALL_ISH } })
3031
const utilizationView = q(api.utilizationView, {})
3132

3233
export const handle = { crumb: 'Utilization' }

‎app/pages/project/access/ProjectAccessPage.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,15 @@ import { TableActions, TableEmptyBox } from '~/ui/lib/Table'
4747
import { TipIcon } from '~/ui/lib/TipIcon'
4848
import { identityTypeLabel, roleColor } from '~/util/access'
4949
import { groupBy } from '~/util/array'
50+
import { ALL_ISH } from '~/util/consts'
5051
import { docLinks } from '~/util/links'
5152
import type * as PP from '~/util/path-params'
5253

5354
const policyView = q(api.policyView, {})
5455
const projectPolicyView = ({ project }: PP.Project) =>
5556
q(api.projectPolicyView, { path: { project } })
56-
const userList = q(api.userList, {})
57-
const groupList = q(api.groupList, {})
57+
const userList = q(api.userList, { query: { limit: ALL_ISH } })
58+
const groupList = q(api.groupList, { query: { limit: ALL_ISH } })
5859

5960
const EmptyState = ({ onClick }: { onClick: () => void }) => (
6061
<TableEmptyBox>

‎app/pages/system/FleetAccessPage.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ const EmptyState = ({ onClick }: { onClick: () => void }) => (
6464
)
6565

6666
const systemPolicyView = q(api.systemPolicyView, {})
67-
const userList = q(api.userList, {})
68-
const groupList = q(api.groupList, {})
67+
const userList = q(api.userList, { query: { limit: ALL_ISH } })
68+
const groupList = q(api.groupList, { query: { limit: ALL_ISH } })
6969
const siloList = q(api.siloList, { query: { limit: ALL_ISH } })
7070

7171
export async function clientLoader() {

0 commit comments

Comments
 (0)