@quazardous/qdadm 2.36.1 → 2.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/styles/qdadm.css +1 -1
- package/package.json +8 -2
- package/src/components/editors/yaml/VanillaYamlEditor.vue +146 -0
- package/src/components/editors/yaml/YamlConfigEditor.vue +353 -0
- package/src/components/editors/yaml/yamlConfigAdapter.ts +141 -0
- package/src/components/index.ts +1 -0
- package/src/components/layout/AppBanner.vue +226 -0
- package/src/components/layout/AppLayout.vue +14 -5
- package/src/components/layout/BaseLayout.vue +10 -2
- package/src/components/pages/LoginPage.vue +5 -0
- package/src/composables/index.ts +12 -0
- package/src/composables/useAppBanner.ts +145 -0
- package/src/composables/useNavigation.ts +5 -6
- package/src/editors/yaml.ts +24 -0
- package/src/i18n/defaults/core.en.generated.ts +50 -0
- package/src/i18n/defaults/core.en.yml +50 -0
- package/src/i18n/defaults/core.fr.generated.ts +50 -0
- package/src/i18n/defaults/core.fr.yml +50 -0
- package/src/index.ts +12 -0
- package/src/kernel/Kernel.types.ts +3 -0
- package/src/kernel/KernelContext.types.ts +1 -1
- package/src/module/moduleRegistry.ts +1 -1
- package/src/plugin.ts +3 -0
- package/src/styles/_alerts.scss +8 -0
- package/src/styles/_yaml-editor.scss +111 -0
- package/src/styles/index.scss +1 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* AppBanner - the strip above the layout (#4200)
|
|
4
|
+
*
|
|
5
|
+
* Shows the `useAppBanner()` messages one at a time, full width, fixed at the
|
|
6
|
+
* top. Its height goes to `--qd-banner-height` on <html>, which AppLayout,
|
|
7
|
+
* BaseLayout and LoginPage read to start below it: nothing is covered. With
|
|
8
|
+
* no message, there is no strip and the variable is 0.
|
|
9
|
+
*
|
|
10
|
+
* Rendered by AppLayout, BaseLayout and LoginPage; a page outside them can
|
|
11
|
+
* place one too. The default slot replaces the text of the message shown.
|
|
12
|
+
*/
|
|
13
|
+
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
|
14
|
+
import { useAppBanner, type AppBannerMessage, type AppBannerSeverity } from '../../composables/useAppBanner'
|
|
15
|
+
import { isExternalUserLink } from '../../composables/useUserBox'
|
|
16
|
+
import { useI18n } from '../../i18n/useI18n'
|
|
17
|
+
|
|
18
|
+
const HEIGHT_VAR = '--qd-banner-height'
|
|
19
|
+
|
|
20
|
+
const ICONS: Record<AppBannerSeverity, string> = {
|
|
21
|
+
info: 'pi pi-info-circle',
|
|
22
|
+
success: 'pi pi-check-circle',
|
|
23
|
+
warn: 'pi pi-exclamation-triangle',
|
|
24
|
+
error: 'pi pi-exclamation-circle',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const { messages, dismiss } = useAppBanner()
|
|
28
|
+
const { tOr } = useI18n()
|
|
29
|
+
|
|
30
|
+
const index = ref(0)
|
|
31
|
+
// Until the user pages, the first message shows (a new urgent one included);
|
|
32
|
+
// once they have, the strip stays on the message they chose
|
|
33
|
+
const chosen = ref(false)
|
|
34
|
+
const currentKey = ref<string | null>(null)
|
|
35
|
+
watch(
|
|
36
|
+
messages,
|
|
37
|
+
(list) => {
|
|
38
|
+
const kept = chosen.value ? list.findIndex((e) => e.key === currentKey.value) : 0
|
|
39
|
+
index.value = kept >= 0 ? kept : Math.min(index.value, Math.max(list.length - 1, 0))
|
|
40
|
+
currentKey.value = list[index.value]?.key ?? null
|
|
41
|
+
},
|
|
42
|
+
{ immediate: true }
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
const current = computed<AppBannerMessage | null>(() => messages.value[index.value]?.message ?? null)
|
|
46
|
+
const severity = computed<AppBannerSeverity>(() => current.value?.severity ?? 'info')
|
|
47
|
+
const icon = computed(() => (current.value?.icon === false ? null : current.value?.icon || ICONS[severity.value]))
|
|
48
|
+
const external = computed(() => isExternalUserLink(current.value?.link?.href))
|
|
49
|
+
|
|
50
|
+
function go(step: number) {
|
|
51
|
+
const count = messages.value.length
|
|
52
|
+
chosen.value = true
|
|
53
|
+
index.value = (index.value + step + count) % count
|
|
54
|
+
currentKey.value = messages.value[index.value]?.key ?? null
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function close() {
|
|
58
|
+
if (!current.value) return
|
|
59
|
+
// The next message takes this index; past the end, back to the first
|
|
60
|
+
const next = messages.value[index.value + 1] ?? messages.value[0]
|
|
61
|
+
currentKey.value = next && next.message !== current.value ? next.key : null
|
|
62
|
+
dismiss(current.value)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// The layout's offset: the strip's real height, wrapped text included
|
|
66
|
+
const el = ref<HTMLElement | null>(null)
|
|
67
|
+
const setHeight = (px: number) => document.documentElement.style.setProperty(HEIGHT_VAR, `${px}px`)
|
|
68
|
+
let observer: ResizeObserver | null = null
|
|
69
|
+
watch(el, (node) => {
|
|
70
|
+
observer?.disconnect()
|
|
71
|
+
observer = null
|
|
72
|
+
if (!node) return setHeight(0)
|
|
73
|
+
setHeight(node.offsetHeight)
|
|
74
|
+
if (typeof ResizeObserver === 'undefined') return
|
|
75
|
+
observer = new ResizeObserver(() => setHeight(node.offsetHeight))
|
|
76
|
+
observer.observe(node)
|
|
77
|
+
}, { immediate: true })
|
|
78
|
+
onBeforeUnmount(() => {
|
|
79
|
+
observer?.disconnect()
|
|
80
|
+
setHeight(0)
|
|
81
|
+
})
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<template>
|
|
85
|
+
<div
|
|
86
|
+
v-if="current"
|
|
87
|
+
ref="el"
|
|
88
|
+
class="qd-app-banner"
|
|
89
|
+
:class="`qd-app-banner--${severity}`"
|
|
90
|
+
role="status"
|
|
91
|
+
:aria-label="tOr('core.banner.label', 'Environment notice')"
|
|
92
|
+
>
|
|
93
|
+
<div v-if="messages.length > 1" class="qd-app-banner-nav">
|
|
94
|
+
<button type="button" class="qd-app-banner-btn" :aria-label="tOr('core.banner.previous', 'Previous message')" @click="go(-1)">
|
|
95
|
+
<i class="pi pi-chevron-left" />
|
|
96
|
+
</button>
|
|
97
|
+
<span class="qd-app-banner-position" :aria-label="tOr('core.banner.position', '{index} of {count}', { index: index + 1, count: messages.length })">
|
|
98
|
+
{{ index + 1 }}/{{ messages.length }}
|
|
99
|
+
</span>
|
|
100
|
+
<button type="button" class="qd-app-banner-btn" :aria-label="tOr('core.banner.next', 'Next message')" @click="go(1)">
|
|
101
|
+
<i class="pi pi-chevron-right" />
|
|
102
|
+
</button>
|
|
103
|
+
</div>
|
|
104
|
+
<div class="qd-app-banner-message">
|
|
105
|
+
<i v-if="icon" :class="icon" class="qd-app-banner-icon" aria-hidden="true" />
|
|
106
|
+
<span class="qd-app-banner-text">
|
|
107
|
+
<slot :message="current">{{ current.text }}</slot>
|
|
108
|
+
<a
|
|
109
|
+
v-if="current.link"
|
|
110
|
+
class="qd-app-banner-link"
|
|
111
|
+
:href="current.link.href"
|
|
112
|
+
v-bind="external ? { target: '_blank', rel: 'noopener noreferrer' } : {}"
|
|
113
|
+
>{{ current.link.label }}</a>
|
|
114
|
+
</span>
|
|
115
|
+
</div>
|
|
116
|
+
<button
|
|
117
|
+
v-if="current.closable"
|
|
118
|
+
type="button"
|
|
119
|
+
class="qd-app-banner-btn qd-app-banner-close"
|
|
120
|
+
:aria-label="tOr('core.banner.close', 'Close this message')"
|
|
121
|
+
@click="close"
|
|
122
|
+
>
|
|
123
|
+
<i class="pi pi-times" />
|
|
124
|
+
</button>
|
|
125
|
+
</div>
|
|
126
|
+
</template>
|
|
127
|
+
|
|
128
|
+
<style scoped>
|
|
129
|
+
/*
|
|
130
|
+
* Only keep styles here that REQUIRE scoping (:deep, dynamic binding, component-specific overrides).
|
|
131
|
+
* Generic/reusable styles belong in src/styles/ partials (see _forms.scss, _cards.scss, etc.).
|
|
132
|
+
*/
|
|
133
|
+
.qd-app-banner {
|
|
134
|
+
--qd-banner-bg: var(--p-primary-color, #3b82f6);
|
|
135
|
+
--qd-banner-fg: var(--p-primary-contrast-color, #fff);
|
|
136
|
+
position: fixed;
|
|
137
|
+
top: 0;
|
|
138
|
+
left: 0;
|
|
139
|
+
right: 0;
|
|
140
|
+
/* Above the sidebar (100), below PrimeVue overlays and dialogs (1000+) */
|
|
141
|
+
z-index: 900;
|
|
142
|
+
display: flex;
|
|
143
|
+
align-items: center;
|
|
144
|
+
gap: 0.75rem;
|
|
145
|
+
padding: 0.35rem 1rem;
|
|
146
|
+
/* The height of a button row: paging or closing doesn't move the layout */
|
|
147
|
+
min-height: 2.2rem;
|
|
148
|
+
box-sizing: border-box;
|
|
149
|
+
background: var(--qd-banner-bg);
|
|
150
|
+
color: var(--qd-banner-fg);
|
|
151
|
+
font-size: 0.875rem;
|
|
152
|
+
font-weight: 600;
|
|
153
|
+
line-height: 1.35;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.qd-app-banner--success {
|
|
157
|
+
--qd-banner-bg: var(--p-green-600, #16a34a);
|
|
158
|
+
--qd-banner-fg: #fff;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.qd-app-banner--warn {
|
|
162
|
+
--qd-banner-bg: var(--p-amber-400, #fbbf24);
|
|
163
|
+
--qd-banner-fg: var(--p-amber-950, #451a03);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.qd-app-banner--error {
|
|
167
|
+
--qd-banner-bg: var(--p-red-600, #dc2626);
|
|
168
|
+
--qd-banner-fg: #fff;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.qd-app-banner-message {
|
|
172
|
+
flex: 1;
|
|
173
|
+
min-width: 0;
|
|
174
|
+
display: flex;
|
|
175
|
+
align-items: center;
|
|
176
|
+
justify-content: center;
|
|
177
|
+
gap: 0.5rem;
|
|
178
|
+
text-align: center;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.qd-app-banner-text {
|
|
182
|
+
overflow-wrap: anywhere;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.qd-app-banner-link {
|
|
186
|
+
margin-left: 0.5rem;
|
|
187
|
+
color: inherit;
|
|
188
|
+
text-decoration: underline;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.qd-app-banner-nav {
|
|
192
|
+
display: flex;
|
|
193
|
+
align-items: center;
|
|
194
|
+
gap: 0.25rem;
|
|
195
|
+
flex-shrink: 0;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.qd-app-banner-position {
|
|
199
|
+
font-variant-numeric: tabular-nums;
|
|
200
|
+
font-weight: 500;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.qd-app-banner-btn {
|
|
204
|
+
display: inline-flex;
|
|
205
|
+
align-items: center;
|
|
206
|
+
justify-content: center;
|
|
207
|
+
width: 1.5rem;
|
|
208
|
+
height: 1.5rem;
|
|
209
|
+
padding: 0;
|
|
210
|
+
border: 0;
|
|
211
|
+
border-radius: 50%;
|
|
212
|
+
background: transparent;
|
|
213
|
+
color: inherit;
|
|
214
|
+
cursor: pointer;
|
|
215
|
+
flex-shrink: 0;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.qd-app-banner-btn:hover,
|
|
219
|
+
.qd-app-banner-btn:focus-visible {
|
|
220
|
+
background: color-mix(in srgb, currentColor 18%, transparent);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.qd-app-banner-btn .pi {
|
|
224
|
+
font-size: 0.75rem;
|
|
225
|
+
}
|
|
226
|
+
</style>
|
|
@@ -29,6 +29,7 @@ import TaskHost from '../tasks/TaskHost.vue'
|
|
|
29
29
|
import TaskTray from '../tasks/TaskTray.vue'
|
|
30
30
|
import SidebarBox from './SidebarBox.vue'
|
|
31
31
|
import Zone from './Zone.vue'
|
|
32
|
+
import AppBanner from './AppBanner.vue'
|
|
32
33
|
import NavlinksGroup from './NavlinksGroup.vue'
|
|
33
34
|
import qdadmLogo from '../../assets/logo.svg'
|
|
34
35
|
import { version as qdadmVersion } from '../../../package.json'
|
|
@@ -252,6 +253,11 @@ const showBreadcrumb = computed<boolean>(() => {
|
|
|
252
253
|
|
|
253
254
|
<template>
|
|
254
255
|
<div class="app-layout">
|
|
256
|
+
<!-- Top strip (#4200): the layout starts below it, see --qd-banner-height -->
|
|
257
|
+
<AppBanner v-slot="{ message }">
|
|
258
|
+
<slot name="banner" :message="message">{{ message.text }}</slot>
|
|
259
|
+
</AppBanner>
|
|
260
|
+
|
|
255
261
|
<!-- Mobile overlay -->
|
|
256
262
|
<div
|
|
257
263
|
class="sidebar-overlay"
|
|
@@ -470,6 +476,9 @@ const showBreadcrumb = computed<boolean>(() => {
|
|
|
470
476
|
.app-layout {
|
|
471
477
|
display: flex;
|
|
472
478
|
min-height: 100vh;
|
|
479
|
+
/* Below the AppBanner strip, when there is one (#4200) */
|
|
480
|
+
padding-top: var(--qd-banner-height, 0px);
|
|
481
|
+
box-sizing: border-box;
|
|
473
482
|
font-family: var(--fad-font-family);
|
|
474
483
|
}
|
|
475
484
|
|
|
@@ -484,7 +493,7 @@ const showBreadcrumb = computed<boolean>(() => {
|
|
|
484
493
|
display: flex;
|
|
485
494
|
flex-direction: column;
|
|
486
495
|
position: fixed;
|
|
487
|
-
top:
|
|
496
|
+
top: var(--qd-banner-height, 0px);
|
|
488
497
|
left: 0;
|
|
489
498
|
bottom: 0;
|
|
490
499
|
z-index: 100;
|
|
@@ -627,7 +636,7 @@ const showBreadcrumb = computed<boolean>(() => {
|
|
|
627
636
|
flex: 1;
|
|
628
637
|
margin-left: var(--fad-sidebar-width);
|
|
629
638
|
background: var(--p-surface-50, #f8fafc);
|
|
630
|
-
min-height: 100vh;
|
|
639
|
+
min-height: calc(100vh - var(--qd-banner-height, 0px));
|
|
631
640
|
display: flex;
|
|
632
641
|
flex-direction: column;
|
|
633
642
|
transition: margin-left var(--fad-transition-slow);
|
|
@@ -933,7 +942,7 @@ const showBreadcrumb = computed<boolean>(() => {
|
|
|
933
942
|
background: var(--p-surface-0, white);
|
|
934
943
|
border-bottom: 1px solid var(--p-surface-200, #e2e8f0);
|
|
935
944
|
position: sticky;
|
|
936
|
-
top:
|
|
945
|
+
top: var(--qd-banner-height, 0px);
|
|
937
946
|
z-index: 50;
|
|
938
947
|
height: var(--fad-header-height);
|
|
939
948
|
}
|
|
@@ -981,8 +990,8 @@ const showBreadcrumb = computed<boolean>(() => {
|
|
|
981
990
|
box-shadow: none;
|
|
982
991
|
/* Mobile: fullscreen */
|
|
983
992
|
width: 100vw !important;
|
|
984
|
-
height: 100dvh;
|
|
985
|
-
max-height: 100dvh;
|
|
993
|
+
height: calc(100dvh - var(--qd-banner-height, 0px));
|
|
994
|
+
max-height: calc(100dvh - var(--qd-banner-height, 0px));
|
|
986
995
|
overflow-y: auto;
|
|
987
996
|
}
|
|
988
997
|
|
|
@@ -34,6 +34,7 @@ import { useSlots, provide, ref } from 'vue'
|
|
|
34
34
|
import { RouterView } from 'vue-router'
|
|
35
35
|
import ConfirmDialog from 'primevue/confirmdialog'
|
|
36
36
|
import Zone from './Zone.vue'
|
|
37
|
+
import AppBanner from './AppBanner.vue'
|
|
37
38
|
import { LAYOUT_ZONES } from '../../zones/zones'
|
|
38
39
|
import { useGuardDialog, GUARD_DIALOG_HOST } from '../../composables/useGuardStore'
|
|
39
40
|
import UnsavedChangesDialog from '../dialogs/UnsavedChangesDialog.vue'
|
|
@@ -64,6 +65,11 @@ provide('qdadmNavlinksOverride', navlinksOverride)
|
|
|
64
65
|
|
|
65
66
|
<template>
|
|
66
67
|
<div class="base-layout">
|
|
68
|
+
<!-- Top strip (#4200): the layout starts below it, see --qd-banner-height -->
|
|
69
|
+
<AppBanner v-slot="{ message }">
|
|
70
|
+
<slot name="banner" :message="message">{{ message.text }}</slot>
|
|
71
|
+
</AppBanner>
|
|
72
|
+
|
|
67
73
|
<!-- Sidebar (contains header, menu, user-info, footer) -->
|
|
68
74
|
<aside class="sidebar">
|
|
69
75
|
<!-- Header zone: branding, logo -->
|
|
@@ -146,6 +152,8 @@ provide('qdadmNavlinksOverride', navlinksOverride)
|
|
|
146
152
|
.base-layout {
|
|
147
153
|
display: flex;
|
|
148
154
|
min-height: 100vh;
|
|
155
|
+
padding-top: var(--qd-banner-height, 0px);
|
|
156
|
+
box-sizing: border-box;
|
|
149
157
|
}
|
|
150
158
|
|
|
151
159
|
.sidebar {
|
|
@@ -155,7 +163,7 @@ provide('qdadmNavlinksOverride', navlinksOverride)
|
|
|
155
163
|
display: flex;
|
|
156
164
|
flex-direction: column;
|
|
157
165
|
position: fixed;
|
|
158
|
-
top:
|
|
166
|
+
top: var(--qd-banner-height, 0px);
|
|
159
167
|
left: 0;
|
|
160
168
|
bottom: 0;
|
|
161
169
|
z-index: 100;
|
|
@@ -165,7 +173,7 @@ provide('qdadmNavlinksOverride', navlinksOverride)
|
|
|
165
173
|
flex: 1;
|
|
166
174
|
margin-left: var(--fad-sidebar-width, 18rem);
|
|
167
175
|
background: var(--p-surface-50, #f8fafc);
|
|
168
|
-
min-height: 100vh;
|
|
176
|
+
min-height: calc(100vh - var(--qd-banner-height, 0px));
|
|
169
177
|
display: flex;
|
|
170
178
|
flex-direction: column;
|
|
171
179
|
}
|
|
@@ -23,6 +23,7 @@ import Card from 'primevue/card'
|
|
|
23
23
|
import InputText from 'primevue/inputtext'
|
|
24
24
|
import Password from 'primevue/password'
|
|
25
25
|
import QdButton from '../base/QdButton.vue'
|
|
26
|
+
import AppBanner from '../layout/AppBanner.vue'
|
|
26
27
|
import { useI18n } from '../../i18n/useI18n'
|
|
27
28
|
import type { OrchestratorLike } from '../../entity/EntityManager.interface'
|
|
28
29
|
|
|
@@ -229,6 +230,8 @@ async function handleLogin(): Promise<void> {
|
|
|
229
230
|
|
|
230
231
|
<template>
|
|
231
232
|
<div class="qdadm-login-page">
|
|
233
|
+
<!-- Which environment this is, before login too (#4200) -->
|
|
234
|
+
<AppBanner />
|
|
232
235
|
<Card class="qdadm-login-card">
|
|
233
236
|
<template #title>
|
|
234
237
|
<div class="qdadm-login-header">
|
|
@@ -312,6 +315,8 @@ async function handleLogin(): Promise<void> {
|
|
|
312
315
|
*/
|
|
313
316
|
.qdadm-login-page {
|
|
314
317
|
min-height: 100vh;
|
|
318
|
+
padding-top: var(--qd-banner-height, 0px);
|
|
319
|
+
box-sizing: border-box;
|
|
315
320
|
display: flex;
|
|
316
321
|
align-items: center;
|
|
317
322
|
justify-content: center;
|
package/src/composables/index.ts
CHANGED
|
@@ -137,6 +137,18 @@ export {
|
|
|
137
137
|
type BannerSeverity,
|
|
138
138
|
type BannerStore,
|
|
139
139
|
} from './useInfoBanner'
|
|
140
|
+
export {
|
|
141
|
+
useAppBanner,
|
|
142
|
+
getAppBannerStore,
|
|
143
|
+
createAppBannerStore,
|
|
144
|
+
type AppBannerMessage,
|
|
145
|
+
type AppBannerSeverity,
|
|
146
|
+
type AppBannerConfig,
|
|
147
|
+
type AppBannerInput,
|
|
148
|
+
type AppBannerEntry,
|
|
149
|
+
type AppBannerStore,
|
|
150
|
+
type UseAppBannerReturn,
|
|
151
|
+
} from './useAppBanner'
|
|
140
152
|
export {
|
|
141
153
|
useUserImpersonator,
|
|
142
154
|
type UseUserImpersonatorOptions,
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useAppBanner - the messages of the top strip (#4200)
|
|
3
|
+
*
|
|
4
|
+
* The strip above the layout shows one message at a time: the `app.banner`
|
|
5
|
+
* messages (which environment this is, typically) and the ones the app
|
|
6
|
+
* pushes at runtime with `show()`. A message stays unless it is `closable`;
|
|
7
|
+
* closing one shows the next, and a closed message with an `id` stays closed
|
|
8
|
+
* for the browser session, even when the app shows it again: to bring it
|
|
9
|
+
* back, show it under a new id.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Kernel / createQdadm options
|
|
13
|
+
* app: { banner: { id: 'env', text: 'PRODUCTION', severity: 'error' } }
|
|
14
|
+
*
|
|
15
|
+
* // At runtime
|
|
16
|
+
* const banner = useAppBanner()
|
|
17
|
+
* banner.show({ id: 'maintenance', text: 'Maintenance at 22:00', severity: 'warn', closable: true })
|
|
18
|
+
* banner.hide('maintenance')
|
|
19
|
+
*/
|
|
20
|
+
import { computed, inject, reactive, ref, type ComputedRef } from 'vue'
|
|
21
|
+
|
|
22
|
+
export type AppBannerSeverity = 'info' | 'success' | 'warn' | 'error'
|
|
23
|
+
|
|
24
|
+
export interface AppBannerMessage {
|
|
25
|
+
/** Stable id: a later message with the same id replaces it, and closing it lasts the session. */
|
|
26
|
+
id?: string
|
|
27
|
+
text: string
|
|
28
|
+
/** Default: 'info'. */
|
|
29
|
+
severity?: AppBannerSeverity
|
|
30
|
+
/** A PrimeIcons class (`pi pi-…`), or false for none. Default: one per severity. */
|
|
31
|
+
icon?: string | false
|
|
32
|
+
/** A link after the text; an absolute URL opens in a new tab. */
|
|
33
|
+
link?: { label: string; href: string }
|
|
34
|
+
/** Show a close button. Default: false, the message stays. */
|
|
35
|
+
closable?: boolean
|
|
36
|
+
/** Higher first. Default: 0. */
|
|
37
|
+
priority?: number
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type AppBannerInput = AppBannerMessage | AppBannerMessage[] | null | undefined
|
|
41
|
+
|
|
42
|
+
/** `app.banner`: one message, a list, or a function returning either (read reactively). */
|
|
43
|
+
export type AppBannerConfig = AppBannerInput | (() => AppBannerInput)
|
|
44
|
+
|
|
45
|
+
export interface AppBannerEntry {
|
|
46
|
+
/** The message id, or one made from its text when it has none. */
|
|
47
|
+
key: string
|
|
48
|
+
message: AppBannerMessage
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const STORAGE_KEY = 'qdadm.banner.dismissed'
|
|
52
|
+
|
|
53
|
+
function readDismissed(): string[] {
|
|
54
|
+
try {
|
|
55
|
+
const raw = sessionStorage.getItem(STORAGE_KEY)
|
|
56
|
+
const ids = raw ? JSON.parse(raw) : []
|
|
57
|
+
return Array.isArray(ids) ? ids.filter((id) => typeof id === 'string') : []
|
|
58
|
+
} catch {
|
|
59
|
+
return []
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function toList(input: AppBannerInput): AppBannerMessage[] {
|
|
64
|
+
if (!input) return []
|
|
65
|
+
return (Array.isArray(input) ? input : [input]).filter((m) => m && typeof m.text === 'string' && m.text.trim())
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const keyOf = (message: AppBannerMessage): string => message.id ?? `text:${message.severity ?? 'info'}:${message.text}`
|
|
69
|
+
|
|
70
|
+
/** The runtime messages and the dismissals, shared by every strip of the app. */
|
|
71
|
+
export function createAppBannerStore() {
|
|
72
|
+
let seq = 0
|
|
73
|
+
const runtime = ref<{ seq: number; message: AppBannerMessage }[]>([])
|
|
74
|
+
// Ids closed this session; messages without an id are closed in memory only
|
|
75
|
+
const dismissed = reactive(new Set<string>(readDismissed()))
|
|
76
|
+
// Ids made up by show(): they mean nothing after a reload
|
|
77
|
+
const generated = new Set<string>()
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
runtime,
|
|
81
|
+
dismissed,
|
|
82
|
+
show(message: AppBannerMessage): string {
|
|
83
|
+
let id = message.id
|
|
84
|
+
if (!id) generated.add((id = `banner-${++seq}`))
|
|
85
|
+
const entry = { seq: ++seq, message: { ...message, id } }
|
|
86
|
+
const at = runtime.value.findIndex((e) => e.message.id === id)
|
|
87
|
+
if (at >= 0) runtime.value.splice(at, 1, entry)
|
|
88
|
+
else runtime.value.push(entry)
|
|
89
|
+
return id
|
|
90
|
+
},
|
|
91
|
+
hide(id: string): void {
|
|
92
|
+
runtime.value = runtime.value.filter((e) => e.message.id !== id)
|
|
93
|
+
},
|
|
94
|
+
dismiss(message: AppBannerMessage): void {
|
|
95
|
+
dismissed.add(keyOf(message))
|
|
96
|
+
if (message.id && !generated.has(message.id)) {
|
|
97
|
+
try {
|
|
98
|
+
const ids = new Set(readDismissed()).add(message.id)
|
|
99
|
+
sessionStorage.setItem(STORAGE_KEY, JSON.stringify([...ids]))
|
|
100
|
+
} catch {
|
|
101
|
+
// No session storage: closed until the next reload only
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export type AppBannerStore = ReturnType<typeof createAppBannerStore>
|
|
109
|
+
|
|
110
|
+
let store: AppBannerStore | null = null
|
|
111
|
+
|
|
112
|
+
export function getAppBannerStore(): AppBannerStore {
|
|
113
|
+
return (store ??= createAppBannerStore())
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface UseAppBannerReturn {
|
|
117
|
+
/** The messages to show, in order: closed ones left out. */
|
|
118
|
+
messages: ComputedRef<AppBannerEntry[]>
|
|
119
|
+
show: (message: AppBannerMessage) => string
|
|
120
|
+
hide: (id: string) => void
|
|
121
|
+
/** Close a message: it leaves the strip, the next one shows. */
|
|
122
|
+
dismiss: (message: AppBannerMessage) => void
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function useAppBanner(): UseAppBannerReturn {
|
|
126
|
+
const s = getAppBannerStore()
|
|
127
|
+
const app = inject<{ banner?: AppBannerConfig } | null>('qdadmApp', null)
|
|
128
|
+
|
|
129
|
+
const messages = computed(() => {
|
|
130
|
+
const config = app?.banner
|
|
131
|
+
const configured = toList(typeof config === 'function' ? config() : config)
|
|
132
|
+
// Config first, then runtime messages by arrival; a runtime id replaces a configured one
|
|
133
|
+
const runtimeIds = new Set(s.runtime.value.map((e) => e.message.id))
|
|
134
|
+
const all = [
|
|
135
|
+
...configured.filter((m) => !m.id || !runtimeIds.has(m.id)).map((message, i) => ({ order: i - 1e6, message })),
|
|
136
|
+
...s.runtime.value.map((e) => ({ order: e.seq, message: e.message })),
|
|
137
|
+
]
|
|
138
|
+
return all
|
|
139
|
+
.filter(({ message }) => !s.dismissed.has(keyOf(message)))
|
|
140
|
+
.sort((a, b) => (b.message.priority ?? 0) - (a.message.priority ?? 0) || a.order - b.order)
|
|
141
|
+
.map(({ message }) => ({ key: keyOf(message), message }))
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
return { messages, show: s.show, hide: s.hide, dismiss: s.dismiss }
|
|
145
|
+
}
|
|
@@ -34,7 +34,7 @@ export interface NavItem {
|
|
|
34
34
|
href?: string
|
|
35
35
|
/** Where an `href` entry opens: default `_blank` for an absolute URL, same tab otherwise. */
|
|
36
36
|
target?: string
|
|
37
|
-
/**
|
|
37
|
+
/** The entry is shown only to whoever is granted this attribute (`route` or `href`). */
|
|
38
38
|
permission?: string
|
|
39
39
|
/** Set on `href` entries by `navSections`: opens outside the app in another tab. */
|
|
40
40
|
external?: boolean
|
|
@@ -110,11 +110,10 @@ export function useNavigation(): UseNavigationReturn {
|
|
|
110
110
|
* Check if user can access a nav item: canList() when it opens a list route, canRead() otherwise
|
|
111
111
|
*/
|
|
112
112
|
function canAccessNavItem(item: NavItem): boolean {
|
|
113
|
-
//
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (!item.entity || !orchestrator) return true
|
|
113
|
+
// Its own permission, on any entry (#3675, #4318): a link out has nothing
|
|
114
|
+
// else to check, a route entry no longer needs `entity` to follow rights.
|
|
115
|
+
if (item.permission && securityChecker && !securityChecker.isGranted(item.permission)) return false
|
|
116
|
+
if (item.href || !item.entity || !orchestrator) return true
|
|
118
117
|
const manager = orchestrator.get(item.entity)
|
|
119
118
|
if (!manager) return true
|
|
120
119
|
// A menu entry is shown to whoever may do what its page does (#2497): a
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* qdadm/editors/yaml - YAML editors on @quazardous/vanilla-yamleditor (#4303)
|
|
3
|
+
*
|
|
4
|
+
* Import from '@quazardous/qdadm/editors/yaml' only if you install
|
|
5
|
+
* @quazardous/vanilla-yamleditor (an optional peer): it stays out of the
|
|
6
|
+
* main bundle and of '@quazardous/qdadm/editors'.
|
|
7
|
+
*
|
|
8
|
+
* import { VanillaYamlEditor, YamlConfigEditor, restYamlAdapter } from '@quazardous/qdadm/editors/yaml'
|
|
9
|
+
*/
|
|
10
|
+
export { default as VanillaYamlEditor } from '../components/editors/yaml/VanillaYamlEditor.vue'
|
|
11
|
+
export { default as YamlConfigEditor } from '../components/editors/yaml/YamlConfigEditor.vue'
|
|
12
|
+
export {
|
|
13
|
+
restYamlAdapter,
|
|
14
|
+
normalizeProblems,
|
|
15
|
+
normalizeProblemPath,
|
|
16
|
+
YamlConflictError,
|
|
17
|
+
type RestYamlAdapterOptions,
|
|
18
|
+
type YamlConfigAdapter,
|
|
19
|
+
type YamlConfigDocument,
|
|
20
|
+
type YamlHistoryEntry,
|
|
21
|
+
type YamlRevision,
|
|
22
|
+
type YamlSaveInput,
|
|
23
|
+
} from '../components/editors/yaml/yamlConfigAdapter'
|
|
24
|
+
export type { JsonSchema, YamlProblem, YamlProblemInput, YamlEditorMode, YamlEditorStatus } from '@quazardous/vanilla-yamleditor'
|
|
@@ -187,6 +187,56 @@ export default `core:
|
|
|
187
187
|
justNow: just now
|
|
188
188
|
minutesAgo: "{count}m ago"
|
|
189
189
|
hoursAgo: "{count}h ago"
|
|
190
|
+
# AppBanner (#4200)
|
|
191
|
+
banner:
|
|
192
|
+
label: Environment notice
|
|
193
|
+
previous: Previous message
|
|
194
|
+
next: Next message
|
|
195
|
+
position: "{index} of {count}"
|
|
196
|
+
close: Close this message
|
|
197
|
+
# VanillaYamlEditor and YamlConfigEditor (#4303)
|
|
198
|
+
yamlEditor:
|
|
199
|
+
text: Text
|
|
200
|
+
tree: Form
|
|
201
|
+
modes: View
|
|
202
|
+
syntaxBlocked: Fix the syntax errors before switching to the form
|
|
203
|
+
syntaxErrors: "{count} syntax error | {count} syntax errors"
|
|
204
|
+
addItem: Add item
|
|
205
|
+
addKey: Add
|
|
206
|
+
newKey: new key
|
|
207
|
+
remove: Remove
|
|
208
|
+
rename: Key name
|
|
209
|
+
empty: (empty)
|
|
210
|
+
alias: An alias, edit it in the text view
|
|
211
|
+
count: "{count} entry | {count} entries"
|
|
212
|
+
loading: Loading
|
|
213
|
+
loadError: "Could not load: {message}"
|
|
214
|
+
readOnly: Read only
|
|
215
|
+
unsaved: Unsaved changes
|
|
216
|
+
upToDate: Up to date
|
|
217
|
+
check: Check
|
|
218
|
+
checkOk: No problem found
|
|
219
|
+
problems: "{count} problem | {count} problems"
|
|
220
|
+
save: Save…
|
|
221
|
+
review: Review the change
|
|
222
|
+
noChange: Nothing changed
|
|
223
|
+
reason: Reason
|
|
224
|
+
reasonPlaceholder: Why this change? It goes into the history.
|
|
225
|
+
confirmSave: Save
|
|
226
|
+
saved: Saved
|
|
227
|
+
saveError: "Could not save: {message}"
|
|
228
|
+
cancel: Cancel
|
|
229
|
+
revert: Discard changes
|
|
230
|
+
before: Before
|
|
231
|
+
after: After
|
|
232
|
+
history: History
|
|
233
|
+
historyEmpty: No history yet
|
|
234
|
+
restore: Load this version
|
|
235
|
+
restored: "Version {revision} loaded: review and save it to restore it"
|
|
236
|
+
conflictTitle: Changed meanwhile
|
|
237
|
+
conflictText: Someone saved this document after you opened it. Their version is on the left, yours on the right.
|
|
238
|
+
takeTheirs: Load their version
|
|
239
|
+
keepMine: Keep mine and save over it
|
|
190
240
|
# NotFoundPage
|
|
191
241
|
notFound:
|
|
192
242
|
title: Page not found
|