Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove alerts instead of deactivating them #1139

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/components/ssd/SchematicStatusDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ function onAction(event: CustomEvent<SsdActionEventPayload>): void {
id: `undefined-action-${now.toISOString()}`,
type: 'error',
message: 'No left click actions defined for this object',
active: true,
})
return
}
Expand All @@ -135,7 +134,6 @@ function onAction(event: CustomEvent<SsdActionEventPayload>): void {
id: `action-${results[0].type}-${now.toISOString()}`,
type: 'error',
message: `Action '${results[0].type}' not supported yet.`,
active: true,
})
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/components/workflows/WorkflowsControl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ function showErrorMessage(message: string) {
id: `workflow-error-${userId.value}`,
type: 'error',
message,
active: true,
})
}

Expand All @@ -444,7 +443,6 @@ function showStartMessage(message: string) {
id: `workflow-start-${userId.value}`,
type: 'success',
message,
active: true,
})
}

Expand All @@ -453,7 +451,6 @@ function showSuccessMessage(message: string) {
id: `workflow-success-${userId.value}`,
type: 'success',
message,
active: true,
})
}

Expand Down
17 changes: 14 additions & 3 deletions src/layouts/DefaultLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@
<Suspense>
<router-view></router-view>
</Suspense>
<div class="alerts__container" v-if="alertsStore.hasActiveAlerts">
<div class="alerts__container" v-if="alertsStore.hasAlerts">
<v-alert
v-for="alert in alertsStore.activeAlerts"
v-for="alert in alertsStore.alerts"
:type="alert.type"
closable
density="compact"
Expand Down Expand Up @@ -198,6 +198,17 @@ const logoSrc = ref('')
const appBarStyle = ref<StyleValue>()
const appBarColor = ref<string>('')

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',
Expand Down Expand Up @@ -279,7 +290,7 @@ const shouldRenderInfoMenu = computed(() => {
})

function onCloseAlert(alert: Alert) {
alertsStore.deactiveAlert(alert.id)
alertsStore.removeAlert(alert.id)
}

const useRail = computed(
Expand Down
11 changes: 3 additions & 8 deletions src/stores/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export interface Alert {
id: string
type: AlertType
message: string
active: boolean
}

interface AlertState {
Expand All @@ -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,
},
})

Expand Down
Loading