File tree Expand file tree Collapse file tree 3 files changed +17
-13
lines changed Expand file tree Collapse file tree 3 files changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -326,14 +326,21 @@ export function ProjectPicker({ project }: { project?: Project }) {
326
326
export function InstancePicker ( ) {
327
327
// picker only shows up when an instance is in scope
328
328
const instanceSelector = useInstanceSelector ( )
329
- const { instance } = instanceSelector
330
-
329
+ const { project, instance } = instanceSelector
330
+ const { data : instances } = useApiQuery ( 'instanceList' , {
331
+ query : { project, limit : PAGE_SIZE } ,
332
+ } )
333
+ const items = ( instances ?. items || [ ] ) . map ( ( { name } ) => ( {
334
+ label : name ,
335
+ to : pb . instance ( { project, instance : name } ) ,
336
+ } ) )
331
337
return (
332
338
< TopBarPicker
333
339
aria-label = "Switch instance"
334
340
category = "Instance"
335
341
current = { instance }
336
- to = { pb . instanceStorage ( instanceSelector ) }
342
+ to = { pb . instance ( { project, instance } ) }
343
+ items = { items }
337
344
noItemsText = "No instances found"
338
345
/>
339
346
)
Original file line number Diff line number Diff line change @@ -10,12 +10,7 @@ import { filesize } from 'filesize'
10
10
import { useMemo } from 'react'
11
11
import { useNavigate , type LoaderFunctionArgs } from 'react-router-dom'
12
12
13
- import {
14
- apiQueryClient ,
15
- useApiQueryClient ,
16
- usePrefetchedApiQuery ,
17
- type Instance ,
18
- } from '@oxide/api'
13
+ import { apiQueryClient , usePrefetchedApiQuery , type Instance } from '@oxide/api'
19
14
import { Instances16Icon , Instances24Icon } from '@oxide/design-system/icons/react'
20
15
21
16
import { DocsPopover } from '~/components/DocsPopover'
@@ -55,12 +50,11 @@ InstancesPage.loader = async ({ params }: LoaderFunctionArgs) => {
55
50
return null
56
51
}
57
52
53
+ const refetchInstances = ( ) => apiQueryClient . invalidateQueries ( 'instanceList' )
54
+
58
55
export function InstancesPage ( ) {
59
56
const { project } = useProjectSelector ( )
60
57
61
- const queryClient = useApiQueryClient ( )
62
- const refetchInstances = ( ) => queryClient . invalidateQueries ( 'instanceList' )
63
-
64
58
const makeActions = useMakeInstanceActions (
65
59
{ project } ,
66
60
{ onSuccess : refetchInstances , onDelete : refetchInstances }
Original file line number Diff line number Diff line change @@ -94,7 +94,10 @@ export function InstancePage() {
94
94
const makeActions = useMakeInstanceActions ( instanceSelector , {
95
95
onSuccess : refreshData ,
96
96
// go to project instances list since there's no more instance
97
- onDelete : ( ) => navigate ( pb . instances ( instanceSelector ) ) ,
97
+ onDelete : ( ) => {
98
+ apiQueryClient . invalidateQueries ( 'instanceList' )
99
+ navigate ( pb . instances ( instanceSelector ) )
100
+ } ,
98
101
} )
99
102
100
103
const { data : instance } = usePrefetchedApiQuery (
You can’t perform that action at this time.
0 commit comments