@@ -133,6 +133,31 @@ const staticCols = [
133
133
134
134
const updateNicStates = fancifyStates ( instanceCan . updateNic . states )
135
135
136
+ const ipColHelper = createColumnHelper < ExternalIp > ( )
137
+ const staticIpCols = [
138
+ ipColHelper . accessor ( 'ip' , {
139
+ cell : ( info ) => < CopyableIp ip = { info . getValue ( ) } /> ,
140
+ } ) ,
141
+ ipColHelper . accessor ( 'kind' , {
142
+ header : ( ) => (
143
+ < >
144
+ Kind
145
+ < TipIcon className = "ml-2" >
146
+ Floating IPs can be detached from this instance and attached to another.
147
+ </ TipIcon >
148
+ </ >
149
+ ) ,
150
+ cell : ( info ) => < Badge color = "neutral" > { info . getValue ( ) } </ Badge > ,
151
+ } ) ,
152
+ ipColHelper . accessor ( 'name' , {
153
+ cell : ( info ) => ( info . getValue ( ) ? info . getValue ( ) : < EmptyCell /> ) ,
154
+ } ) ,
155
+ ipColHelper . accessor ( ( row ) => ( 'description' in row ? row . description : undefined ) , {
156
+ header : 'description' ,
157
+ cell : ( info ) => < DescriptionCell text = { info . getValue ( ) } /> ,
158
+ } ) ,
159
+ ]
160
+
136
161
export function NetworkingTab ( ) {
137
162
const instanceSelector = useInstanceSelector ( )
138
163
const { instance : instanceName , project } = instanceSelector
@@ -157,13 +182,13 @@ export function NetworkingTab() {
157
182
setCreateModalOpen ( false )
158
183
} ,
159
184
} )
160
- const deleteNic = useApiMutation ( 'instanceNetworkInterfaceDelete' , {
185
+ const { mutateAsync : deleteNic } = useApiMutation ( 'instanceNetworkInterfaceDelete' , {
161
186
onSuccess ( ) {
162
187
queryClient . invalidateQueries ( 'instanceNetworkInterfaceList' )
163
188
addToast ( { content : 'Network interface deleted' } )
164
189
} ,
165
190
} )
166
- const editNic = useApiMutation ( 'instanceNetworkInterfaceUpdate' , {
191
+ const { mutate : editNic } = useApiMutation ( 'instanceNetworkInterfaceUpdate' , {
167
192
onSuccess ( ) {
168
193
queryClient . invalidateQueries ( 'instanceNetworkInterfaceList' )
169
194
} ,
@@ -180,7 +205,7 @@ export function NetworkingTab() {
180
205
{
181
206
label : 'Make primary' ,
182
207
onActivate ( ) {
183
- editNic . mutate ( {
208
+ editNic ( {
184
209
path : { interface : nic . name } ,
185
210
query : instanceSelector ,
186
211
body : { ...nic , primary : true } ,
@@ -211,7 +236,7 @@ export function NetworkingTab() {
211
236
label : 'Delete' ,
212
237
onActivate : confirmDelete ( {
213
238
doDelete : ( ) =>
214
- deleteNic . mutateAsync ( {
239
+ deleteNic ( {
215
240
path : { interface : nic . name } ,
216
241
query : instanceSelector ,
217
242
} ) ,
@@ -243,32 +268,7 @@ export function NetworkingTab() {
243
268
query : { project } ,
244
269
} )
245
270
246
- const ipColHelper = createColumnHelper < ExternalIp > ( )
247
- const staticIpCols = [
248
- ipColHelper . accessor ( 'ip' , {
249
- cell : ( info ) => < CopyableIp ip = { info . getValue ( ) } /> ,
250
- } ) ,
251
- ipColHelper . accessor ( 'kind' , {
252
- header : ( ) => (
253
- < >
254
- Kind
255
- < TipIcon className = "ml-2" >
256
- Floating IPs can be detached from this instance and attached to another.
257
- </ TipIcon >
258
- </ >
259
- ) ,
260
- cell : ( info ) => < Badge color = "neutral" > { info . getValue ( ) } </ Badge > ,
261
- } ) ,
262
- ipColHelper . accessor ( 'name' , {
263
- cell : ( info ) => ( info . getValue ( ) ? info . getValue ( ) : < EmptyCell /> ) ,
264
- } ) ,
265
- ipColHelper . accessor ( ( row ) => ( 'description' in row ? row . description : undefined ) , {
266
- header : 'description' ,
267
- cell : ( info ) => < DescriptionCell text = { info . getValue ( ) } /> ,
268
- } ) ,
269
- ]
270
-
271
- const ephemeralIpDetach = useApiMutation ( 'instanceEphemeralIpDetach' , {
271
+ const { mutateAsync : ephemeralIpDetach } = useApiMutation ( 'instanceEphemeralIpDetach' , {
272
272
onSuccess ( ) {
273
273
queryClient . invalidateQueries ( 'instanceExternalIpList' )
274
274
addToast ( { content : 'Your ephemeral IP has been detached' } )
@@ -278,7 +278,7 @@ export function NetworkingTab() {
278
278
} ,
279
279
} )
280
280
281
- const floatingIpDetach = useApiMutation ( 'floatingIpDetach' , {
281
+ const { mutateAsync : floatingIpDetach } = useApiMutation ( 'floatingIpDetach' , {
282
282
onSuccess ( ) {
283
283
queryClient . invalidateQueries ( 'floatingIpList' )
284
284
queryClient . invalidateQueries ( 'instanceExternalIpList' )
@@ -301,12 +301,12 @@ export function NetworkingTab() {
301
301
const doAction =
302
302
externalIp . kind === 'floating'
303
303
? ( ) =>
304
- floatingIpDetach . mutateAsync ( {
304
+ floatingIpDetach ( {
305
305
path : { floatingIp : externalIp . name } ,
306
306
query : { project } ,
307
307
} )
308
308
: ( ) =>
309
- ephemeralIpDetach . mutateAsync ( {
309
+ ephemeralIpDetach ( {
310
310
path : { instance : instanceName } ,
311
311
query : { project } ,
312
312
} )
0 commit comments