Skip to content

Commit b6c8d10

Browse files
authored
Fix double error toasts (#3167)
All of these mutations get confirmed and therefore have their error toasts handled by the `catch` in `ConfirmActionModal`. Using an `onError` means they get two toasts. Thanks @jordanhendricks for reporting this. https://github.com/oxidecomputer/console/blob/c53101e2cbd76bf41cfd8e0e39c1adf688be8e58/app/components/ConfirmActionModal.tsx#L36-L44 I am working on some zany schemes for avoiding this in the future, but in the meantime let's at least fix these.
1 parent c53101e commit b6c8d10

File tree

4 files changed

+1
-19
lines changed

4 files changed

+1
-19
lines changed

app/pages/project/floating-ips/FloatingIpsPage.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ export default function FloatingIpsPage() {
118118
// prettier-ignore
119119
addToast(<>Floating IP <HL>{floatingIp.name}</HL> detached</>)
120120
},
121-
onError: (err) => {
122-
addToast({ title: 'Error', content: err.message, variant: 'error' })
123-
},
124121
})
125122
const { mutateAsync: deleteFloatingIp } = useApiMutation(api.floatingIpDelete, {
126123
onSuccess(_data, variables) {

app/pages/project/instances/NetworkingTab.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,6 @@ export default function NetworkingTab() {
479479
queryClient.invalidateEndpoint('instanceExternalIpList')
480480
addToast({ content: 'Ephemeral IP detached' })
481481
},
482-
onError: (err) => {
483-
addToast({ title: 'Error', content: err.message, variant: 'error' })
484-
},
485482
})
486483

487484
const { mutateAsync: floatingIpDetach } = useApiMutation(api.floatingIpDetach, {
@@ -491,9 +488,6 @@ export default function NetworkingTab() {
491488
// prettier-ignore
492489
addToast(<>Floating IP <HL>{variables.path.floatingIp}</HL> detached</>)
493490
},
494-
onError: (err) => {
495-
addToast({ title: 'Error', content: err.message, variant: 'error' })
496-
},
497491
})
498492

499493
const { mutateAsync: externalSubnetDetach } = useApiMutation(api.externalSubnetDetach, {

app/pages/project/instances/StorageTab.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ export default function StorageTab() {
113113
// prettier-ignore
114114
addToast(<>Disk <HL>{disk.name}</HL> detached</>)
115115
},
116-
onError(err) {
117-
addToast({ title: 'Failed to detach disk', content: err.message, variant: 'error' })
118-
},
119116
})
120117
const { mutate: createSnapshot } = useApiMutation(api.snapshotCreate, {
121118
onSuccess(snapshot) {

app/pages/project/instances/actions.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,14 @@ export const useMakeInstanceActions = (
6363
startInstanceAsync(instanceParams, {
6464
// prettier-ignore
6565
onSuccess: () => addToast(<>Starting instance <HL>{instance.name}</HL></>),
66-
onError: (error) =>
67-
addToast({
68-
variant: 'error',
69-
title: `Error starting instance '${instance.name}'`,
70-
content: error.message,
71-
}),
7266
}),
7367
modalTitle: 'Confirm start instance',
7468
modalContent: (
7569
<p>
7670
Are you sure you want to start <HL>{instance.name}</HL>?
7771
</p>
7872
),
79-
errorTitle: `Error starting ${instance.name}`,
73+
errorTitle: `Error starting instance '${instance.name}'`,
8074
})
8175
},
8276
disabled: !instanceCan.start(instance) && (

0 commit comments

Comments
 (0)