@@ -12,14 +12,14 @@ import { Link, useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
1212import {
1313 apiQueryClient ,
1414 useApiQuery ,
15- useApiQueryClient ,
1615 usePrefetchedApiQuery ,
1716 type InstanceNetworkInterface ,
1817} from '@oxide/api'
1918import { Instances24Icon } from '@oxide/design-system/icons/react'
2019
2120import { ExternalIps } from '~/components/ExternalIps'
2221import { MoreActionsMenu } from '~/components/MoreActionsMenu'
22+ import { RefreshButton } from '~/components/RefreshButton'
2323import { RouteTabs , Tab } from '~/components/RouteTabs'
2424import { InstanceStatusBadge } from '~/components/StatusBadge'
2525import { getInstanceSelector , useInstanceSelector , useQuickActions } from '~/hooks'
@@ -37,6 +37,15 @@ function getPrimaryVpcId(nics: InstanceNetworkInterface[]) {
3737 return nic ? nic . vpcId : undefined
3838}
3939
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+
4049InstancePage . loader = async ( { params } : LoaderFunctionArgs ) => {
4150 const { project, instance } = getInstanceSelector ( params )
4251 await Promise . all ( [
@@ -75,11 +84,8 @@ export function InstancePage() {
7584 const instanceSelector = useInstanceSelector ( )
7685
7786 const navigate = useNavigate ( )
78- const queryClient = useApiQueryClient ( )
7987 const makeActions = useMakeInstanceActions ( instanceSelector , {
80- onSuccess : ( ) => {
81- queryClient . invalidateQueries ( 'instanceView' )
82- } ,
88+ onSuccess : refreshData ,
8389 // go to project instances list since there's no more instance
8490 onDelete : ( ) => navigate ( pb . instances ( instanceSelector ) ) ,
8591 } )
@@ -137,7 +143,10 @@ export function InstancePage() {
137143 < >
138144 < PageHeader >
139145 < 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 >
141150 </ PageHeader >
142151 < PropertiesTable . Group className = "-mt-8 mb-16" >
143152 < PropertiesTable >
0 commit comments