-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ✨ introduced the new snackbar queue with composable * 🔥 removed old snackbar and store * changed to new snackbar queue * changed to new snackbar queue * changed to new snackbar queue and changed api call to wait * changed to new snackbar queue and changed api call to wait * ✅ adjusted tests to fit new snackbar queue * moved eventbus to the composable --------- Co-authored-by: langehm <[email protected]>
- Loading branch information
Showing
11 changed files
with
105 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<template> | ||
<v-snackbar-queue v-model="queue"> | ||
<template #text="textData"> | ||
<v-layout class="align-center"> | ||
<v-icon | ||
class="mr-3" | ||
size="25" | ||
:icon="textData.item.icon" | ||
/> | ||
<p class="text-body-1">{{ textData.item.text }}</p> | ||
</v-layout> | ||
</template> | ||
</v-snackbar-queue> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import type { SnackbarMessage } from "@/types/SnackbarMessage"; | ||
import { ref } from "vue"; | ||
import { VSnackbarQueue } from "vuetify/labs/VSnackbarQueue"; | ||
import { Levels } from "@/api/error"; | ||
import { snackbarBus } from "@/composables/useSnackbar"; | ||
const queue = ref<SnackbarMessageInternal[]>([]); | ||
interface SnackbarMessageInternal { | ||
text: string; | ||
timeout: number; | ||
color: string; | ||
icon: string; | ||
} | ||
snackbarBus.on((message: SnackbarMessage) => { | ||
queue.value.push({ | ||
color: message.level || "info", | ||
text: message.message || "", | ||
timeout: message.timeout || message.level === Levels.ERROR ? 10000 : 5000, | ||
icon: getIcon(message.level || Levels.INFO), | ||
}); | ||
}); | ||
const getIcon = (level: Levels) => { | ||
switch (level) { | ||
case Levels.INFO: | ||
return "mdi-information-outline"; | ||
case Levels.ERROR: | ||
return "mdi-alert-outline"; | ||
case Levels.SUCCESS: | ||
return "mdi-check-circle-outline"; | ||
case Levels.WARNING: | ||
return "mdi-alert-outline"; | ||
} | ||
}; | ||
</script> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { SnackbarMessage } from "@/types/SnackbarMessage"; | ||
|
||
import { useEventBus } from "@vueuse/core"; | ||
|
||
import { EV_SNACKBAR } from "@/Constants"; | ||
|
||
export const snackbarBus = useEventBus<SnackbarMessage>(EV_SNACKBAR); | ||
|
||
export const useSnackbar = () => { | ||
const sendMessage = (message: SnackbarMessage) => { | ||
snackbarBus.emit(message); | ||
}; | ||
|
||
return { sendMessage }; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Levels } from "@/api/error"; | ||
|
||
export interface SnackbarMessage { | ||
message?: string | undefined; | ||
level?: Levels; | ||
timeout?: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters