@@ -10,6 +10,8 @@ import { useNavigate } from 'react-router-dom'
10
10
11
11
import { instanceCan , useApiMutation , type Instance } from '@oxide/api'
12
12
13
+ import { HL } from '~/components/HL'
14
+ import { confirmAction } from '~/stores/confirm-action'
13
15
import { confirmDelete } from '~/stores/confirm-delete'
14
16
import { addToast } from '~/stores/toast'
15
17
import type { MakeActions } from '~/table/columns/action-col'
@@ -65,14 +67,28 @@ export const useMakeInstanceActions = (
65
67
{
66
68
label : 'Stop' ,
67
69
onActivate ( ) {
68
- stopInstance . mutate ( instanceParams , {
69
- onSuccess : ( ) => addToast ( { title : `Stopping instance '${ instance . name } '` } ) ,
70
- onError : ( error ) =>
71
- addToast ( {
72
- variant : 'error' ,
73
- title : `Error stopping instance '${ instance . name } '` ,
74
- content : error . message ,
70
+ confirmAction ( {
71
+ actionType : 'danger' ,
72
+ doAction : async ( ) =>
73
+ stopInstance . mutate ( instanceParams , {
74
+ onSuccess : ( ) =>
75
+ addToast ( { title : `Stopping instance '${ instance . name } '` } ) ,
76
+ onError : ( error ) =>
77
+ addToast ( {
78
+ variant : 'error' ,
79
+ title : `Error stopping instance '${ instance . name } '` ,
80
+ content : error . message ,
81
+ } ) ,
75
82
} ) ,
83
+ modalTitle : 'Confirm stop instance' ,
84
+ modalContent : (
85
+ < p >
86
+ Are you sure you want to stop < HL > { instance . name } </ HL > ? Stopped instances
87
+ retain attached disks and IP addresses, but allocated CPU and memory are
88
+ freed.
89
+ </ p >
90
+ ) ,
91
+ errorTitle : `Could not stop ${ instance . name } ` ,
76
92
} )
77
93
} ,
78
94
disabled : ! instanceCan . stop ( instance ) && (
@@ -113,6 +129,7 @@ export const useMakeInstanceActions = (
113
129
} ,
114
130
} ) ,
115
131
label : instance . name ,
132
+ resourceKind : 'instance' ,
116
133
} ) ,
117
134
disabled : ! instanceCan . delete ( instance ) && (
118
135
< > Only { fancifyStates ( instanceCan . delete . states ) } instances can be deleted</ >
0 commit comments