Skip to content

Commit ef6a38d

Browse files
committed
fix overzealous dep arrays
1 parent f78415e commit ef6a38d

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

app/pages/project/instances/instance/tabs/NetworkingTab.tsx

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,31 @@ const staticCols = [
133133

134134
const updateNicStates = fancifyStates(instanceCan.updateNic.states)
135135

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+
136161
export function NetworkingTab() {
137162
const instanceSelector = useInstanceSelector()
138163
const { instance: instanceName, project } = instanceSelector
@@ -157,13 +182,13 @@ export function NetworkingTab() {
157182
setCreateModalOpen(false)
158183
},
159184
})
160-
const deleteNic = useApiMutation('instanceNetworkInterfaceDelete', {
185+
const { mutateAsync: deleteNic } = useApiMutation('instanceNetworkInterfaceDelete', {
161186
onSuccess() {
162187
queryClient.invalidateQueries('instanceNetworkInterfaceList')
163188
addToast({ content: 'Network interface deleted' })
164189
},
165190
})
166-
const editNic = useApiMutation('instanceNetworkInterfaceUpdate', {
191+
const { mutate: editNic } = useApiMutation('instanceNetworkInterfaceUpdate', {
167192
onSuccess() {
168193
queryClient.invalidateQueries('instanceNetworkInterfaceList')
169194
},
@@ -180,7 +205,7 @@ export function NetworkingTab() {
180205
{
181206
label: 'Make primary',
182207
onActivate() {
183-
editNic.mutate({
208+
editNic({
184209
path: { interface: nic.name },
185210
query: instanceSelector,
186211
body: { ...nic, primary: true },
@@ -211,7 +236,7 @@ export function NetworkingTab() {
211236
label: 'Delete',
212237
onActivate: confirmDelete({
213238
doDelete: () =>
214-
deleteNic.mutateAsync({
239+
deleteNic({
215240
path: { interface: nic.name },
216241
query: instanceSelector,
217242
}),
@@ -243,32 +268,7 @@ export function NetworkingTab() {
243268
query: { project },
244269
})
245270

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', {
272272
onSuccess() {
273273
queryClient.invalidateQueries('instanceExternalIpList')
274274
addToast({ content: 'Your ephemeral IP has been detached' })
@@ -278,7 +278,7 @@ export function NetworkingTab() {
278278
},
279279
})
280280

281-
const floatingIpDetach = useApiMutation('floatingIpDetach', {
281+
const { mutateAsync: floatingIpDetach } = useApiMutation('floatingIpDetach', {
282282
onSuccess() {
283283
queryClient.invalidateQueries('floatingIpList')
284284
queryClient.invalidateQueries('instanceExternalIpList')
@@ -301,12 +301,12 @@ export function NetworkingTab() {
301301
const doAction =
302302
externalIp.kind === 'floating'
303303
? () =>
304-
floatingIpDetach.mutateAsync({
304+
floatingIpDetach({
305305
path: { floatingIp: externalIp.name },
306306
query: { project },
307307
})
308308
: () =>
309-
ephemeralIpDetach.mutateAsync({
309+
ephemeralIpDetach({
310310
path: { instance: instanceName },
311311
query: { project },
312312
})

mock-api/instance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const instance: Json<Instance> = {
1818
description: 'an instance',
1919
hostname: 'oxide.com',
2020
project_id: project.id,
21-
run_state: 'running',
21+
run_state: 'stopping',
2222
time_created: new Date().toISOString(),
2323
time_modified: new Date().toISOString(),
2424
time_run_state_updated: new Date().toISOString(),

0 commit comments

Comments
 (0)