-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenericError.vue
More file actions
59 lines (54 loc) · 1.72 KB
/
Copy pathGenericError.vue
File metadata and controls
59 lines (54 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<template>
<q-dialog
v-model="showError"
@hide="hide"
auto-close
full-width
backdrop-filter="brightness(50%)"
position="top"
aria-label="Error notification"
>
<q-banner class="text-center error-surface">
<template #avatar>
<q-icon
name="error"
color="negative"
/>
</template>
{{ errorMessage }}
<span v-if="showLogin">
Your session may have expired.
<a
:href="loginUrl"
target="_blank"
rel="noopener noreferrer"
>
Click to log in, and then try your action again.
<q-icon name="launch"></q-icon>
</a>
</span>
</q-banner>
</q-dialog>
</template>
<script setup lang="ts">
import { computed, ref, watch } from "vue"
import { useErrorStore } from "@/store/ErrorStore"
import { storeToRefs } from "pinia"
import { getLoginUrl } from "@/composables/RequireLogin"
const errorStore = useErrorStore()
const { errorMessage, status } = storeToRefs(errorStore)
const showErrorMessage = computed(() => errorMessage.value !== null && errorMessage.value.length > 0)
const loginUrl = getLoginUrl()
const showError = ref(false)
const showLogin = ref(false)
function hide() {
errorStore.clearError()
}
watch(showErrorMessage, () => {
showError.value = showErrorMessage.value
showLogin.value =
status.value !== undefined &&
status.value !== null &&
(errorMessage.value === "Error: not logged in." || errorMessage.value === "Error: Access Denied.")
})
</script>