@@ -12,14 +12,14 @@ import { Link, useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
12
12
import {
13
13
apiQueryClient ,
14
14
useApiQuery ,
15
- useApiQueryClient ,
16
15
usePrefetchedApiQuery ,
17
16
type InstanceNetworkInterface ,
18
17
} from '@oxide/api'
19
18
import { Instances24Icon } from '@oxide/design-system/icons/react'
20
19
21
20
import { ExternalIps } from '~/components/ExternalIps'
22
21
import { MoreActionsMenu } from '~/components/MoreActionsMenu'
22
+ import { RefreshButton } from '~/components/RefreshButton'
23
23
import { RouteTabs , Tab } from '~/components/RouteTabs'
24
24
import { InstanceStatusBadge } from '~/components/StatusBadge'
25
25
import { getInstanceSelector , useInstanceSelector , useQuickActions } from '~/hooks'
@@ -37,6 +37,15 @@ function getPrimaryVpcId(nics: InstanceNetworkInterface[]) {
37
37
return nic ? nic . vpcId : undefined
38
38
}
39
39
40
+ // this is meant to cover everything that we fetch in the page
41
+ function refreshData ( ) {
42
+ apiQueryClient . invalidateQueries ( 'instanceView' )
43
+ apiQueryClient . invalidateQueries ( 'instanceExternalIpList' )
44
+ apiQueryClient . invalidateQueries ( 'instanceNetworkInterfaceList' )
45
+ apiQueryClient . invalidateQueries ( 'instanceDiskList' ) // storage tab
46
+ apiQueryClient . invalidateQueries ( 'diskMetricsList' ) // metrics tab
47
+ }
48
+
40
49
InstancePage . loader = async ( { params } : LoaderFunctionArgs ) => {
41
50
const { project, instance } = getInstanceSelector ( params )
42
51
await Promise . all ( [
@@ -75,11 +84,8 @@ export function InstancePage() {
75
84
const instanceSelector = useInstanceSelector ( )
76
85
77
86
const navigate = useNavigate ( )
78
- const queryClient = useApiQueryClient ( )
79
87
const makeActions = useMakeInstanceActions ( instanceSelector , {
80
- onSuccess : ( ) => {
81
- queryClient . invalidateQueries ( 'instanceView' )
82
- } ,
88
+ onSuccess : refreshData ,
83
89
// go to project instances list since there's no more instance
84
90
onDelete : ( ) => navigate ( pb . instances ( instanceSelector ) ) ,
85
91
} )
@@ -137,7 +143,10 @@ export function InstancePage() {
137
143
< >
138
144
< PageHeader >
139
145
< PageTitle icon = { < Instances24Icon /> } > { instance . name } </ PageTitle >
140
- < MoreActionsMenu label = "Instance actions" actions = { actions } />
146
+ < div className = "inline-flex gap-2" >
147
+ < RefreshButton onClick = { refreshData } />
148
+ < MoreActionsMenu label = "Instance actions" actions = { actions } />
149
+ </ div >
141
150
</ PageHeader >
142
151
< PropertiesTable . Group className = "-mt-8 mb-16" >
143
152
< PropertiesTable >
0 commit comments