From 3bef4eda142f533f1c8140382ff1f62a38da8ed7 Mon Sep 17 00:00:00 2001 From: Cees Voesenek Date: Wed, 18 Dec 2024 11:42:45 +0100 Subject: [PATCH] Remove alerts instead of deactivating them This removes the active state for an alert altogether, since it is no longer used anywhere. --- src/components/ssd/SchematicStatusDisplay.vue | 2 -- src/components/workflows/WorkflowsControl.vue | 3 --- src/layouts/DefaultLayout.vue | 17 ++++++++++++++--- src/stores/alerts.ts | 11 +++-------- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/components/ssd/SchematicStatusDisplay.vue b/src/components/ssd/SchematicStatusDisplay.vue index c0c2b154a..9087daf0e 100644 --- a/src/components/ssd/SchematicStatusDisplay.vue +++ b/src/components/ssd/SchematicStatusDisplay.vue @@ -115,7 +115,6 @@ function onAction(event: CustomEvent): void { id: `undefined-action-${now.toISOString()}`, type: 'error', message: 'No left click actions defined for this object', - active: true, }) return } @@ -135,7 +134,6 @@ function onAction(event: CustomEvent): void { id: `action-${results[0].type}-${now.toISOString()}`, type: 'error', message: `Action '${results[0].type}' not supported yet.`, - active: true, }) } } diff --git a/src/components/workflows/WorkflowsControl.vue b/src/components/workflows/WorkflowsControl.vue index b983e3465..7724116f7 100644 --- a/src/components/workflows/WorkflowsControl.vue +++ b/src/components/workflows/WorkflowsControl.vue @@ -435,7 +435,6 @@ function showErrorMessage(message: string) { id: `workflow-error-${userId.value}`, type: 'error', message, - active: true, }) } @@ -444,7 +443,6 @@ function showStartMessage(message: string) { id: `workflow-start-${userId.value}`, type: 'success', message, - active: true, }) } @@ -453,7 +451,6 @@ function showSuccessMessage(message: string) { id: `workflow-success-${userId.value}`, type: 'success', message, - active: true, }) } diff --git a/src/layouts/DefaultLayout.vue b/src/layouts/DefaultLayout.vue index f551928be..ffd723509 100644 --- a/src/layouts/DefaultLayout.vue +++ b/src/layouts/DefaultLayout.vue @@ -147,9 +147,9 @@ -
+
() const appBarColor = ref('') +alertsStore.addAlert({ + id: crypto.randomUUID(), + type: 'success', + message: 'hallo dit is een bericht', +}) +alertsStore.addAlert({ + id: crypto.randomUUID(), + type: 'success', + message: 'hallo dit is een bericht', +}) + function updateAppBarColor() { appBarColor.value = getComputedStyle(document.body).getPropertyValue( '--weboc-app-bar-bg-color', @@ -279,7 +290,7 @@ const shouldRenderInfoMenu = computed(() => { }) function onCloseAlert(alert: Alert) { - alertsStore.deactiveAlert(alert.id) + alertsStore.removeAlert(alert.id) } const useRail = computed( diff --git a/src/stores/alerts.ts b/src/stores/alerts.ts index 9bf4cf812..495f7ebe6 100644 --- a/src/stores/alerts.ts +++ b/src/stores/alerts.ts @@ -6,7 +6,6 @@ export interface Alert { id: string type: AlertType message: string - active: boolean } interface AlertState { @@ -22,17 +21,13 @@ const useAlertsStore = defineStore('alerts', { addAlert(alert: Alert) { this.alerts.push(alert) }, - deactiveAlert(id: string) { - const alert = this.alerts.find((alert) => alert.id === id) - if (alert) { - alert.active = false - } + removeAlert(id: string) { + this.alerts = this.alerts.filter((alert) => alert.id !== id) }, }, getters: { - activeAlerts: (state) => state.alerts.filter((alert) => alert.active), - hasActiveAlerts: (state) => state.alerts.some((alert) => alert.active), + hasAlerts: (state) => state.alerts.length > 0, }, })