Skip to content

Commit 3f2021b

Browse files
committed
fix(frontend): remove network error toasts
Remove network errors from toasts which are usually just noise. Signed-off-by: Edward Sammut Alessi <[email protected]>
1 parent 31d4213 commit 3f2021b

File tree

7 files changed

+17
-15
lines changed

7 files changed

+17
-15
lines changed

frontend/src/notification.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
//
33
// Use of this software is governed by the Business Source License
44
// included in the LICENSE file.
5+
import { milliseconds } from 'date-fns'
56
import { toast } from 'vue-sonner'
67

78
export function showError(title: string, description?: string) {
89
console.error(`error occurred: title: ${title}, body: ${description}`)
910

10-
toast.error(title, { description, duration: Infinity })
11+
toast.error(title, { description, duration: milliseconds({ minutes: 1 }) })
1112
}
1213

1314
export function showSuccess(title: string, description?: string) {
14-
toast.success(title, { description, duration: 5000 })
15+
toast.success(title, { description, duration: milliseconds({ seconds: 5 }) })
1516
}

frontend/src/views/omni/Clusters/Management/ClusterCreate.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import TAlert from '@/components/TAlert.vue'
4141
import { setupBackupStatus } from '@/methods'
4242
import { canCreateClusters } from '@/methods/auth'
4343
import {
44+
ClusterCommandError,
4445
clusterSync,
4546
embeddedDiscoveryServiceAvailable,
4647
nextAvailableClusterName,
@@ -249,7 +250,7 @@ const createCluster_ = async (untaint: boolean) => {
249250
state.value.cluster.name = await nextAvailableClusterName('talos-default')
250251
}
251252
252-
if (e.errorNotification) {
253+
if (e instanceof ClusterCommandError) {
253254
showError(e.errorNotification.title, e.errorNotification.details)
254255
255256
return

frontend/src/views/omni/Clusters/Management/ClusterScale.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import PageHeader from '@/components/common/PageHeader.vue'
2929
import TSpinner from '@/components/common/Spinner/TSpinner.vue'
3030
import Watch from '@/components/common/Watch/Watch.vue'
3131
import TAlert from '@/components/TAlert.vue'
32-
import { clusterSync } from '@/methods/cluster'
32+
import { ClusterCommandError, clusterSync } from '@/methods/cluster'
3333
import { showError, showSuccess } from '@/notification'
3434
import { populateExisting, state } from '@/states/cluster-management'
3535
import ManagedByTemplatesWarning from '@/views/cluster/ManagedByTemplatesWarning.vue'
@@ -66,7 +66,7 @@ const scaleCluster = async () => {
6666
try {
6767
await clusterSync(state.value.resources(), existingResources.value)
6868
} catch (e) {
69-
if (e.errorNotification) {
69+
if (e instanceof ClusterCommandError) {
7070
showError(e.errorNotification.title, e.errorNotification.details)
7171
7272
return

frontend/src/views/omni/Home/HomeGeneralInformation.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ included in the LICENSE file.
66
-->
77
<script setup lang="ts">
88
import { useClipboard } from '@vueuse/core'
9-
import { onBeforeMount, ref, watch } from 'vue'
9+
import { onBeforeMount, ref } from 'vue'
1010
1111
import { Runtime } from '@/api/common/omni.pb'
1212
import type { DefaultJoinTokenSpec, SiderolinkAPIConfigSpec } from '@/api/omni/specs/siderolink.pb'
@@ -25,6 +25,7 @@ import TButton from '@/components/common/Button/TButton.vue'
2525
import Card from '@/components/common/Card/Card.vue'
2626
import TSpinner from '@/components/common/Spinner/TSpinner.vue'
2727
import { useWatch } from '@/components/common/Watch/useWatch'
28+
import TAlert from '@/components/TAlert.vue'
2829
import {
2930
downloadAuditLog,
3031
downloadMachineJoinConfig,
@@ -34,7 +35,6 @@ import {
3435
} from '@/methods'
3536
import { canReadAuditLog } from '@/methods/auth'
3637
import { auditLogEnabled, useInstallationMediaEnabled } from '@/methods/features'
37-
import { showError } from '@/notification'
3838
import HomeGeneralInformationCopyable from '@/views/omni/Home/HomeGeneralInformationCopyable.vue'
3939
4040
const auditLogAvailable = ref(false)
@@ -79,8 +79,6 @@ const {
7979
},
8080
runtime: Runtime.Omni,
8181
})
82-
83-
watch(apiConfigErr, (err) => err && showError(err))
8482
</script>
8583

8684
<template>
@@ -90,6 +88,8 @@ watch(apiConfigErr, (err) => err && showError(err))
9088
<TSpinner v-if="apiConfigLoading" class="size-4" />
9189
</header>
9290

91+
<TAlert v-if="apiConfigErr" type="error" :title="apiConfigErr" />
92+
9393
<dl class="flex flex-col gap-4">
9494
<HomeGeneralInformationCopyable
9595
title="Backend Version"

frontend/src/views/omni/Modals/ClusterDestroy.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
import Watch from '@/api/watch'
2626
import TButton from '@/components/common/Button/TButton.vue'
2727
import TSpinner from '@/components/common/Spinner/TSpinner.vue'
28-
import { clusterDestroy } from '@/methods/cluster'
28+
import { ClusterCommandError, clusterDestroy } from '@/methods/cluster'
2929
import { showError, showSuccess } from '@/notification'
3030
import ManagedByTemplatesWarning from '@/views/cluster/ManagedByTemplatesWarning.vue'
3131
import CloseButton from '@/views/omni/Modals/CloseButton.vue'
@@ -93,7 +93,7 @@ const destroyCluster = async () => {
9393
} catch (e) {
9494
close()
9595
96-
if (e.errorNotification) {
96+
if (e instanceof ClusterCommandError) {
9797
showError(e.errorNotification.title, e.errorNotification.details)
9898
9999
return

frontend/src/views/omni/Modals/NodeDestroy.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
} from '@/api/resources'
2727
import TButton from '@/components/common/Button/TButton.vue'
2828
import TSpinner from '@/components/common/Spinner/TSpinner.vue'
29-
import { destroyNodes } from '@/methods/cluster'
29+
import { ClusterCommandError, destroyNodes } from '@/methods/cluster'
3030
import { controlPlaneMachineSetId } from '@/methods/machineset'
3131
import { setupNodenameWatch } from '@/methods/node'
3232
import { showError, showSuccess } from '@/notification'
@@ -163,7 +163,7 @@ const destroyNode = async () => {
163163
forceDestroy.value,
164164
)
165165
} catch (e) {
166-
if (e.errorNotification) {
166+
if (e instanceof ClusterCommandError) {
167167
showError(e.errorNotification.title, e.errorNotification.details)
168168
169169
close(true)

frontend/src/views/omni/Modals/NodeDestroyCancel.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { ClusterMachineSpec } from '@/api/omni/specs/omni.pb'
1313
import { ClusterMachineType, DefaultNamespace } from '@/api/resources'
1414
import TButton from '@/components/common/Button/TButton.vue'
1515
import Watch from '@/components/common/Watch/Watch.vue'
16-
import { restoreNode } from '@/methods/cluster'
16+
import { ClusterCommandError, restoreNode } from '@/methods/cluster'
1717
import { setupNodenameWatch } from '@/methods/node'
1818
import { showError, showSuccess } from '@/notification'
1919
import CloseButton from '@/views/omni/Modals/CloseButton.vue'
@@ -53,7 +53,7 @@ const restore = async (clusterMachine: Resource<ClusterMachineSpec>) => {
5353
try {
5454
await restoreNode(clusterMachine)
5555
} catch (e) {
56-
if (e.errorNotification) {
56+
if (e instanceof ClusterCommandError) {
5757
showError(e.errorNotification.title, e.errorNotification.details)
5858
5959
close(true)

0 commit comments

Comments
 (0)