@@ -25,7 +25,8 @@ import { Button, EmptyMessage, Storage24Icon } from '@oxide/ui'
2525import { DiskStatusBadge } from 'app/components/StatusBadge'
2626import AttachDiskSideModalForm from 'app/forms/disk-attach'
2727import { CreateDiskSideModalForm } from 'app/forms/disk-create'
28- import { getInstanceSelector , useInstanceSelector , useToast } from 'app/hooks'
28+ import { getInstanceSelector , useInstanceSelector } from 'app/hooks'
29+ import { addToast } from 'app/stores/toast'
2930
3031import { fancifyStates } from './common'
3132
@@ -53,19 +54,37 @@ export function StorageTab() {
5354 const [ showDiskCreate , setShowDiskCreate ] = useState ( false )
5455 const [ showDiskAttach , setShowDiskAttach ] = useState ( false )
5556
56- const addToast = useToast ( )
5757 const queryClient = useApiQueryClient ( )
5858 const { instance : instanceName , project } = useInstanceSelector ( )
5959 const instancePathQuery = useMemo (
6060 ( ) => ( { path : { instance : instanceName } , query : { project } } ) ,
6161 [ instanceName , project ]
6262 )
6363
64- const detachDisk = useApiMutation ( 'instanceDiskDetach' , { } )
64+ const detachDisk = useApiMutation ( 'instanceDiskDetach' , {
65+ onSuccess ( ) {
66+ queryClient . invalidateQueries ( 'instanceDiskList' )
67+ addToast ( { content : 'Disk detached' } )
68+ } ,
69+ onError ( err ) {
70+ addToast ( {
71+ title : 'Failed to detach disk' ,
72+ content : err . message ,
73+ variant : 'error' ,
74+ } )
75+ } ,
76+ } )
6577 const createSnapshot = useApiMutation ( 'snapshotCreate' , {
6678 onSuccess ( ) {
6779 queryClient . invalidateQueries ( 'snapshotList' )
68- addToast ( { content : 'Snapshot successfully created' } )
80+ addToast ( { content : 'Snapshot created' } )
81+ } ,
82+ onError ( err ) {
83+ addToast ( {
84+ title : 'Failed to create snapshot' ,
85+ content : err . message ,
86+ variant : 'error' ,
87+ } )
6988 } ,
7089 } )
7190
@@ -97,18 +116,11 @@ export function StorageTab() {
97116 < > Instance must be in state { detachableStates } before disk can be detached</ >
98117 ) ,
99118 onActivate ( ) {
100- detachDisk . mutate (
101- { body : { disk : disk . name } , ...instancePathQuery } ,
102- {
103- onSuccess : ( ) => {
104- queryClient . invalidateQueries ( 'instanceDiskList' )
105- } ,
106- }
107- )
119+ detachDisk . mutate ( { body : { disk : disk . name } , ...instancePathQuery } )
108120 } ,
109121 } ,
110122 ] ,
111- [ detachDisk , instance , queryClient , instancePathQuery , createSnapshot , project ]
123+ [ detachDisk , instance , instancePathQuery , createSnapshot , project ]
112124 )
113125
114126 const attachDisk = useApiMutation ( 'instanceDiskAttach' , {
0 commit comments