@quazardous/qdadm 2.47.0 → 2.49.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 +1 -1
- package/src/chain/StackHydrator.ts +82 -0
- package/src/components/index.ts +3 -0
- package/src/components/layout/EntityItemLayout.vue +120 -0
- package/src/components/layout/PageNav.vue +24 -2
- package/src/components/tasks/TaskDialog.vue +13 -157
- package/src/components/tasks/TaskHost.vue +15 -2
- package/src/components/tasks/TaskRunView.vue +197 -0
- package/src/components/tasks/TaskSequenceDialog.vue +157 -0
- package/src/components/tasks/TaskTray.vue +33 -13
- package/src/composables/useLiveEntity.ts +3 -1
- package/src/composables/useNavigation.ts +3 -4
- package/src/entity/EntityManager.cache.ts +49 -8
- package/src/entity/EntityManager.interface.ts +6 -0
- package/src/entity/EntityManager.ts +8 -0
- package/src/i18n/defaults/core.en.generated.ts +13 -0
- package/src/i18n/defaults/core.en.yml +13 -0
- package/src/i18n/defaults/core.fr.generated.ts +13 -0
- package/src/i18n/defaults/core.fr.yml +13 -0
- package/src/index.ts +7 -0
- package/src/kernel/Kernel.routing.ts +22 -31
- package/src/kernel/KernelContext.routing.ts +9 -0
- package/src/kernel/KernelContext.ts +3 -0
- package/src/kernel/KernelContext.types.ts +6 -0
- package/src/kernel/itemTabs.ts +99 -0
- package/src/module/moduleRegistry.ts +26 -0
- package/src/security/index.ts +1 -0
- package/src/security/routeAccess.ts +94 -0
- package/src/styles/_item-tabs.scss +52 -0
- package/src/styles/_tasks.scss +102 -0
- package/src/styles/index.scss +1 -0
- package/src/tasks/taskStore.ts +503 -14
- package/src/tasks/useTaskNotifications.ts +6 -2
- package/src/tasks/useTaskRunner.ts +15 -1
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* TaskSequenceDialog - tasks chained in one window (#4934)
|
|
4
|
+
*
|
|
5
|
+
* The list: one line per step, with its state (waiting, running, done,
|
|
6
|
+
* failed, not run), its duration and a recap (the kind's `summary`, else the
|
|
7
|
+
* error, else the step reached); the running step is highlighted. A click on
|
|
8
|
+
* a step shows its detail, the body of TaskDialog (TaskRunView); "Back to the
|
|
9
|
+
* list" returns. Closing does not stop anything: the sequence goes on in the
|
|
10
|
+
* tray. TaskHost renders it when the open id is a sequence's.
|
|
11
|
+
*
|
|
12
|
+
* Slots `before-log`, `after-log` and `result` reach the step's detail.
|
|
13
|
+
*/
|
|
14
|
+
import { computed, onBeforeUnmount, ref, useSlots, watch } from 'vue'
|
|
15
|
+
import Dialog from 'primevue/dialog'
|
|
16
|
+
import ProgressBar from 'primevue/progressbar'
|
|
17
|
+
import QdButton from '../base/QdButton.vue'
|
|
18
|
+
import TaskRunView from './TaskRunView.vue'
|
|
19
|
+
import { useI18n } from '../../i18n/useI18n'
|
|
20
|
+
import { getTaskStore, type SequenceStepStatus, type TaskSequenceStep } from '../../tasks/taskStore'
|
|
21
|
+
import { resolveTaskUi, type TaskDialogOptions } from '../../tasks/taskUi'
|
|
22
|
+
import { formatPhaseDuration } from '../../tasks/taskPhases'
|
|
23
|
+
|
|
24
|
+
interface Props {
|
|
25
|
+
sequenceId: string | null
|
|
26
|
+
/** Window options over the app's */
|
|
27
|
+
options?: TaskDialogOptions | null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const props = withDefaults(defineProps<Props>(), { options: null })
|
|
31
|
+
const emit = defineEmits<{ close: [] }>()
|
|
32
|
+
const slots = useSlots()
|
|
33
|
+
const { t } = useI18n()
|
|
34
|
+
const store = getTaskStore()
|
|
35
|
+
|
|
36
|
+
const sequence = computed(() => (props.sequenceId ? store.state.sequences.find((s) => s.id === props.sequenceId) ?? null : null))
|
|
37
|
+
const running = computed(() => store.isActive(sequence.value))
|
|
38
|
+
const opts = computed(() => resolveTaskUi(null, props.options).dialog)
|
|
39
|
+
const bodySlots = computed(() => (['before-log', 'after-log', 'result'] as const).filter((name) => !!slots[name]))
|
|
40
|
+
|
|
41
|
+
/** The run shown in detail, or null for the list */
|
|
42
|
+
const detailId = ref<string | null>(null)
|
|
43
|
+
watch(() => props.sequenceId, () => (detailId.value = null))
|
|
44
|
+
const detailStep = computed(() => (detailId.value ? sequence.value?.steps.find((s) => s.runId === detailId.value) ?? null : null))
|
|
45
|
+
const detailIndex = computed(() => (detailStep.value ? sequence.value!.steps.indexOf(detailStep.value) : -1))
|
|
46
|
+
const detailDef = computed(() => (detailId.value ? store.definition(detailId.value) : undefined))
|
|
47
|
+
const detailRun = computed(() => (detailId.value ? store.state.runs.find((r) => r.id === detailId.value) ?? null : null))
|
|
48
|
+
const canCancelStep = computed(() => !!detailDef.value?.cancel && !!detailRun.value && store.isActive(detailRun.value) && detailRun.value.taskId != null)
|
|
49
|
+
|
|
50
|
+
const done = computed(() => sequence.value?.steps.filter((s) => store.isFinal(store.stepStatus(s)) && store.stepStatus(s) !== 'skipped').length ?? 0)
|
|
51
|
+
const total = computed(() => sequence.value?.steps.length ?? 0)
|
|
52
|
+
|
|
53
|
+
const now = ref(Date.now())
|
|
54
|
+
const ticker = setInterval(() => (now.value = Date.now()), 1000)
|
|
55
|
+
onBeforeUnmount(() => clearInterval(ticker))
|
|
56
|
+
|
|
57
|
+
const stepLabel = (step: TaskSequenceStep, i: number) => step.label || t('core.task.sequence.step', { n: i + 1 })
|
|
58
|
+
const runOf = (step: TaskSequenceStep) => (step.runId ? store.state.runs.find((r) => r.id === step.runId) ?? null : null)
|
|
59
|
+
|
|
60
|
+
function stateText(status: SequenceStepStatus): string {
|
|
61
|
+
if (status === 'pending') return t('core.task.sequence.pending')
|
|
62
|
+
if (status === 'skipped') return t('core.task.sequence.skipped')
|
|
63
|
+
return t(`core.task.status.${status}`)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function icon(status: SequenceStepStatus): string {
|
|
67
|
+
if (status === 'pending') return 'pi pi-circle'
|
|
68
|
+
if (status === 'skipped') return 'pi pi-minus-circle'
|
|
69
|
+
if (status === 'succeeded') return 'pi pi-check-circle'
|
|
70
|
+
if (status === 'failed') return 'pi pi-times-circle'
|
|
71
|
+
if (status === 'cancelled') return 'pi pi-ban'
|
|
72
|
+
return 'pi pi-spin pi-spinner'
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function duration(step: TaskSequenceStep): string {
|
|
76
|
+
const run = runOf(step)
|
|
77
|
+
if (!run) return ''
|
|
78
|
+
return formatPhaseDuration(((run.endedAt ?? now.value) - run.startedAt) / 1000)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function recap(step: TaskSequenceStep): string | null {
|
|
82
|
+
if (step.skipped) return t(`core.task.sequence.why.${step.skipped}`)
|
|
83
|
+
return store.stepSummary(step)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const isCurrent = (i: number) => running.value && sequence.value?.current === i
|
|
87
|
+
</script>
|
|
88
|
+
|
|
89
|
+
<template>
|
|
90
|
+
<Dialog
|
|
91
|
+
:visible="!!sequence"
|
|
92
|
+
:modal="opts.modal"
|
|
93
|
+
:style="{ width: opts.width }"
|
|
94
|
+
:breakpoints="{ '640px': '96vw' }"
|
|
95
|
+
:draggable="opts.draggable"
|
|
96
|
+
:position="opts.position"
|
|
97
|
+
class="qd-task-dialog qd-task-sequence-dialog"
|
|
98
|
+
:class="opts.class"
|
|
99
|
+
@update:visible="(v: boolean) => !v && emit('close')"
|
|
100
|
+
>
|
|
101
|
+
<template #header>
|
|
102
|
+
<div v-if="sequence" class="qd-task-header qd-task-sequence-header">
|
|
103
|
+
<span class="p-dialog-title">{{ sequence.label }}</span>
|
|
104
|
+
<span class="qd-task-status" :class="`qd-task-status--${sequence.status}`">
|
|
105
|
+
<i :class="icon(sequence.status)" aria-hidden="true" />
|
|
106
|
+
{{ t('core.task.sequence.progress', { done, total }) }}
|
|
107
|
+
</span>
|
|
108
|
+
</div>
|
|
109
|
+
</template>
|
|
110
|
+
|
|
111
|
+
<template v-if="sequence">
|
|
112
|
+
<ol v-if="!detailStep" class="qd-task-sequence-list">
|
|
113
|
+
<li v-for="(step, i) in sequence.steps" :key="i">
|
|
114
|
+
<button type="button" class="qd-task-sequence-step"
|
|
115
|
+
:class="[`qd-task-sequence-step--${store.stepStatus(step)}`, { 'qd-task-sequence-step--current': isCurrent(i) }]"
|
|
116
|
+
:disabled="!step.runId" :aria-current="isCurrent(i) ? 'step' : undefined"
|
|
117
|
+
:aria-label="step.runId ? `${stepLabel(step, i)} — ${t('core.task.sequence.details')}` : undefined"
|
|
118
|
+
@click="detailId = step.runId">
|
|
119
|
+
<i class="qd-task-sequence-icon" :class="icon(store.stepStatus(step))" aria-hidden="true" />
|
|
120
|
+
<span class="qd-task-sequence-main">
|
|
121
|
+
<span class="qd-task-sequence-label">{{ stepLabel(step, i) }}</span>
|
|
122
|
+
<span v-if="recap(step)" class="qd-task-sequence-recap">{{ recap(step) }}</span>
|
|
123
|
+
<ProgressBar v-if="isCurrent(i) && runOf(step)" class="qd-task-sequence-progress"
|
|
124
|
+
:mode="runOf(step)!.progress === null ? 'indeterminate' : 'determinate'"
|
|
125
|
+
:value="Math.round(runOf(step)!.progress ?? 0)" :show-value="false" />
|
|
126
|
+
</span>
|
|
127
|
+
<span class="qd-task-sequence-state">{{ stateText(store.stepStatus(step)) }}</span>
|
|
128
|
+
<span class="qd-task-sequence-duration">{{ duration(step) }}</span>
|
|
129
|
+
<i v-if="step.runId" class="pi pi-angle-right qd-task-sequence-open" aria-hidden="true" />
|
|
130
|
+
</button>
|
|
131
|
+
</li>
|
|
132
|
+
</ol>
|
|
133
|
+
<template v-else>
|
|
134
|
+
<div class="qd-task-sequence-detail-title">
|
|
135
|
+
<span class="qd-task-sequence-detail-index">{{ detailIndex + 1 }}/{{ total }}</span>
|
|
136
|
+
{{ stepLabel(detailStep, detailIndex) }}
|
|
137
|
+
</div>
|
|
138
|
+
<TaskRunView :run-id="detailId" :options="options">
|
|
139
|
+
<template v-for="name in bodySlots" :key="name" #[name]="p">
|
|
140
|
+
<slot :name="name" v-bind="p" />
|
|
141
|
+
</template>
|
|
142
|
+
</TaskRunView>
|
|
143
|
+
</template>
|
|
144
|
+
</template>
|
|
145
|
+
|
|
146
|
+
<template #footer>
|
|
147
|
+
<QdButton v-if="detailStep" class="qd-task-sequence-back" icon="pi pi-arrow-left" text
|
|
148
|
+
:label="t('core.task.sequence.back')" @click="detailId = null" />
|
|
149
|
+
<span class="qd-task-spacer" />
|
|
150
|
+
<QdButton v-if="detailStep && canCancelStep" severity="danger" text :loading="detailRun?.cancelling" icon="pi pi-stop-circle"
|
|
151
|
+
:label="t('core.task.cancel')" @click="detailRun && store.cancel(detailRun.id)" />
|
|
152
|
+
<QdButton v-else-if="!detailStep && running" severity="danger" text :loading="sequence?.cancelling" icon="pi pi-stop-circle"
|
|
153
|
+
:label="t('core.task.sequence.cancel')" @click="sequence && store.cancelSequence(sequence.id)" />
|
|
154
|
+
<QdButton :label="running ? t('core.task.background') : t('core.task.close')" severity="secondary" @click="emit('close')" />
|
|
155
|
+
</template>
|
|
156
|
+
</Dialog>
|
|
157
|
+
</template>
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Shown while there is a run to show. Each run reopens its dialog; finished
|
|
6
6
|
* ones can be cleared. A row's content can be replaced (#4334): the `item`
|
|
7
|
-
* slot, or `configureTasks({ tray: { item } })`, gets `{ run }`.
|
|
7
|
+
* slot, or `configureTasks({ tray: { item } })`, gets `{ run }`. A sequence
|
|
8
|
+
* (#4934) is one row, "Verify · 1/2", which opens its window.
|
|
8
9
|
*/
|
|
9
10
|
import { computed, ref } from 'vue'
|
|
10
11
|
import Popover from 'primevue/popover'
|
|
11
12
|
import QdButton from '../base/QdButton.vue'
|
|
12
13
|
import { useI18n } from '../../i18n/useI18n'
|
|
13
|
-
import { getTaskStore } from '../../tasks/taskStore'
|
|
14
|
+
import { getTaskStore, type TaskRun, type TaskSequence } from '../../tasks/taskStore'
|
|
14
15
|
import { getTaskUi } from '../../tasks/taskUi'
|
|
15
16
|
import { useTaskTrayVisible } from '../../tasks/useTaskNotifications'
|
|
16
17
|
|
|
@@ -21,9 +22,20 @@ const visible = useTaskTrayVisible()
|
|
|
21
22
|
const { t } = useI18n()
|
|
22
23
|
const popover = ref<InstanceType<typeof Popover> | null>(null)
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
const
|
|
25
|
+
// A sequence's steps show as the sequence's row
|
|
26
|
+
const runs = computed(() => store.state.runs.filter((r) => !r.sequenceId || !store.state.sequences.some((s) => s.id === r.sequenceId)))
|
|
27
|
+
const sequences = computed(() => store.state.sequences)
|
|
28
|
+
type Row = { id: string; startedAt: number; run: TaskRun | null; sequence: TaskSequence | null }
|
|
29
|
+
const rows = computed<Row[]>(() =>
|
|
30
|
+
[
|
|
31
|
+
...runs.value.map((run) => ({ id: run.id, startedAt: run.startedAt, run, sequence: null })),
|
|
32
|
+
...sequences.value.map((sequence) => ({ id: sequence.id, startedAt: sequence.startedAt, run: null, sequence })),
|
|
33
|
+
].sort((a, b) => b.startedAt - a.startedAt)
|
|
34
|
+
)
|
|
35
|
+
const activeCount = computed(() => runs.value.filter((r) => store.isActive(r)).length + sequences.value.filter((s) => store.isActive(s)).length)
|
|
36
|
+
const hasFinished = computed(() => runs.value.some((r) => store.isFinal(r.status)) || sequences.value.some((s) => !store.isActive(s)))
|
|
37
|
+
const stepsDone = (sequence: TaskSequence) =>
|
|
38
|
+
sequence.steps.filter((st) => ['succeeded', 'failed', 'cancelled'].includes(store.stepStatus(st))).length
|
|
27
39
|
|
|
28
40
|
function openRun(id: string): void {
|
|
29
41
|
store.open(id)
|
|
@@ -35,7 +47,7 @@ const icon = (status: string) =>
|
|
|
35
47
|
</script>
|
|
36
48
|
|
|
37
49
|
<template>
|
|
38
|
-
<div v-if="visible &&
|
|
50
|
+
<div v-if="visible && rows.length" class="qd-task-tray">
|
|
39
51
|
<button type="button" class="qd-task-tray-button" :class="{ 'qd-task-tray-button--busy': activeCount > 0 }"
|
|
40
52
|
:aria-label="t('core.task.tray', { count: activeCount })" @click="popover?.toggle($event)">
|
|
41
53
|
<i :class="activeCount ? 'pi pi-spin pi-cog' : 'pi pi-check'" />
|
|
@@ -44,15 +56,23 @@ const icon = (status: string) =>
|
|
|
44
56
|
</button>
|
|
45
57
|
<Popover ref="popover" class="qd-task-popover">
|
|
46
58
|
<ul class="qd-task-list">
|
|
47
|
-
<li v-for="
|
|
48
|
-
<button type="button" class="qd-task-item
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
<li v-for="row in rows" :key="row.id">
|
|
60
|
+
<button v-if="row.sequence" type="button" class="qd-task-item qd-task-item--sequence"
|
|
61
|
+
:class="`qd-task-item--${row.sequence.status}`" @click="openRun(row.sequence.id)">
|
|
62
|
+
<i :class="icon(row.sequence.status)" />
|
|
63
|
+
<span class="qd-task-item-label">{{ row.sequence.label }}</span>
|
|
64
|
+
<span class="qd-task-item-state">
|
|
65
|
+
{{ t('core.task.sequence.progress', { done: stepsDone(row.sequence), total: row.sequence.steps.length }) }}
|
|
66
|
+
</span>
|
|
67
|
+
</button>
|
|
68
|
+
<button v-else-if="row.run" type="button" class="qd-task-item" :class="`qd-task-item--${row.run.status}`" @click="openRun(row.run.id)">
|
|
69
|
+
<slot name="item" :run="row.run">
|
|
70
|
+
<component :is="taskUi.tray.item" v-if="taskUi.tray?.item" :run="row.run" />
|
|
51
71
|
<template v-else>
|
|
52
|
-
<i :class="icon(
|
|
53
|
-
<span class="qd-task-item-label">{{
|
|
72
|
+
<i :class="icon(row.run.status)" />
|
|
73
|
+
<span class="qd-task-item-label">{{ row.run.label }}</span>
|
|
54
74
|
<span class="qd-task-item-state">
|
|
55
|
-
{{
|
|
75
|
+
{{ row.run.progress !== null && !store.isFinal(row.run.status) ? `${Math.round(row.run.progress)} %` : t(`core.task.status.${row.run.status}`) }}
|
|
56
76
|
</span>
|
|
57
77
|
</template>
|
|
58
78
|
</slot>
|
|
@@ -135,7 +135,9 @@ export function useLiveEntity(
|
|
|
135
135
|
|
|
136
136
|
// Local writes are the manager's own echo: it has already repaired its
|
|
137
137
|
// cache and the page that triggered the write reloads on its own path.
|
|
138
|
-
|
|
138
|
+
// 'app' is the app saying a record changed (`manager.invalidate`, #4959):
|
|
139
|
+
// news to this screen, like a change made elsewhere.
|
|
140
|
+
if (payload.source !== 'remote' && payload.source !== 'app') return
|
|
139
141
|
if (payload.entity !== entityName) return
|
|
140
142
|
|
|
141
143
|
if (options.id) {
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* the navigation structure dynamically.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import { routePermissions } from '../security/routeAccess'
|
|
12
13
|
import { computed, inject, ref, onMounted, type ComputedRef, type Ref } from 'vue'
|
|
13
14
|
import { useRoute, useRouter } from 'vue-router'
|
|
14
15
|
import { getNavSections, alterMenuSections, isMenuAltered } from '../module/moduleRegistry'
|
|
@@ -129,10 +130,8 @@ export function useNavigation(): UseNavigationReturn {
|
|
|
129
130
|
|
|
130
131
|
function routePermission(name: string): string | string[] | undefined {
|
|
131
132
|
try {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return p === undefined ? [] : Array.isArray(p) ? p : [p]
|
|
135
|
-
})
|
|
133
|
+
// The same reading as the router guard and PageNav (#4962)
|
|
134
|
+
return routePermissions(router.resolve({ name }))
|
|
136
135
|
} catch {
|
|
137
136
|
return undefined
|
|
138
137
|
}
|
|
@@ -332,7 +332,7 @@ export function applyCacheMethods(EntityManagerClass: { prototype: any }): void
|
|
|
332
332
|
)
|
|
333
333
|
}
|
|
334
334
|
|
|
335
|
-
// Listen for
|
|
335
|
+
// Listen for changes to this entity that this manager did not make.
|
|
336
336
|
//
|
|
337
337
|
// The invalidation signals were written for local mutations, where the
|
|
338
338
|
// manager that mutates repairs its own cache on the way out. A change that
|
|
@@ -340,27 +340,34 @@ export function applyCacheMethods(EntityManagerClass: { prototype: any }): void
|
|
|
340
340
|
// while claiming to be valid (#1887). Gated on the origin marker: without
|
|
341
341
|
// it, this handler would fire on every local write too and force a refetch
|
|
342
342
|
// of a list the manager is already holding correctly.
|
|
343
|
+
//
|
|
344
|
+
// 'remote' comes from a live stream, 'app' from `invalidate()` (#4959).
|
|
345
|
+
// With an id, only that record's detail entry goes; the list cache goes
|
|
346
|
+
// whole either way, since a changed record can enter or leave a filtered
|
|
347
|
+
// or sorted page, and a complete list cache also answers list() locally.
|
|
343
348
|
cleanups.push(
|
|
344
349
|
signals.on('entity:data-invalidate', (event: { name: string; data: unknown }) => {
|
|
345
|
-
const { entity, source } = (event.data || {}) as {
|
|
350
|
+
const { entity, source, id } = (event.data || {}) as {
|
|
346
351
|
entity?: string
|
|
347
352
|
source?: string
|
|
353
|
+
id?: string | number
|
|
348
354
|
}
|
|
349
|
-
if (source !== 'remote') return
|
|
355
|
+
if (source !== 'remote' && source !== 'app') return
|
|
350
356
|
if (entity !== this.name) return
|
|
351
|
-
this.
|
|
357
|
+
this._dropCaches(id)
|
|
352
358
|
})
|
|
353
359
|
)
|
|
354
360
|
|
|
355
|
-
//
|
|
361
|
+
// Asymmetric detail cache: a write to this entity drops what it touched —
|
|
362
|
+
// that record when the event names it, every record otherwise.
|
|
356
363
|
if (this.isAsymmetric && this.isDetailCacheEnabled) {
|
|
357
364
|
cleanups.push(
|
|
358
365
|
signals.on(
|
|
359
366
|
'entity:data-invalidate',
|
|
360
367
|
(event: { name: string; data: unknown }) => {
|
|
361
|
-
const { entity } = (event.data || {}) as { entity?: string }
|
|
368
|
+
const { entity, id } = (event.data || {}) as { entity?: string; id?: string | number }
|
|
362
369
|
if (entity === this.name) {
|
|
363
|
-
this.
|
|
370
|
+
this._dropDetail(id)
|
|
364
371
|
}
|
|
365
372
|
}
|
|
366
373
|
)
|
|
@@ -415,7 +422,16 @@ export function applyCacheMethods(EntityManagerClass: { prototype: any }): void
|
|
|
415
422
|
this._detailInflight.clear()
|
|
416
423
|
}
|
|
417
424
|
|
|
418
|
-
proto.
|
|
425
|
+
proto._dropDetail = function (this: Self, id?: string | number | null): void {
|
|
426
|
+
if (id === undefined || id === null) {
|
|
427
|
+
this.invalidateDetailCache()
|
|
428
|
+
return
|
|
429
|
+
}
|
|
430
|
+
this._detailCache.items.delete(String(id))
|
|
431
|
+
this._detailInflight.delete(String(id))
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
proto._dropListCache = function (this: Self): void {
|
|
419
435
|
const cache = this._cache
|
|
420
436
|
cache.valid = false
|
|
421
437
|
cache.items = []
|
|
@@ -423,10 +439,35 @@ export function applyCacheMethods(EntityManagerClass: { prototype: any }): void
|
|
|
423
439
|
cache.overflowed = false
|
|
424
440
|
cache.loadedAt = null
|
|
425
441
|
this._cacheLoading = null
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
proto._dropCaches = function (this: Self, id?: string | number | null): void {
|
|
445
|
+
this._dropListCache()
|
|
446
|
+
this._dropDetail(id)
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
proto.invalidateCache = function (this: Self): void {
|
|
450
|
+
this._dropListCache()
|
|
426
451
|
// Also clear detail cache
|
|
427
452
|
this.invalidateDetailCache()
|
|
428
453
|
}
|
|
429
454
|
|
|
455
|
+
/**
|
|
456
|
+
* Say that a record of this entity changed, or the whole entity without an
|
|
457
|
+
* id (#4959). Drops what the caches hold of it, then tells the mounted views
|
|
458
|
+
* (`useLiveEntity`, list and show pages, the active stack) to read it again,
|
|
459
|
+
* with `source: 'app'` — heard like a change made elsewhere.
|
|
460
|
+
*/
|
|
461
|
+
proto.invalidate = function (this: Self, id?: string | number | null): void {
|
|
462
|
+
this._dropCaches(id)
|
|
463
|
+
this._signals?.emit('entity:data-invalidate', {
|
|
464
|
+
entity: this.name,
|
|
465
|
+
action: 'updated',
|
|
466
|
+
...(id !== undefined && id !== null && { id }),
|
|
467
|
+
source: 'app',
|
|
468
|
+
})
|
|
469
|
+
}
|
|
470
|
+
|
|
430
471
|
proto.invalidateDataLayer = function (this: Self): void {
|
|
431
472
|
this.invalidateCache()
|
|
432
473
|
|
|
@@ -81,6 +81,12 @@ export interface EntityManagerRead<T = unknown> extends EntityManagerBase<T>, En
|
|
|
81
81
|
delete: (id: string | number, context?: unknown) => Promise<void>
|
|
82
82
|
request: (method: string, path: string, options?: { data?: unknown }) => Promise<unknown>
|
|
83
83
|
invalidateCache: () => void
|
|
84
|
+
/**
|
|
85
|
+
* A record changed, or the whole entity without an id (#4959): drops it from
|
|
86
|
+
* the caches and has the mounted views read it again. Optional on the
|
|
87
|
+
* structural view so hand-written managers and test doubles stay valid.
|
|
88
|
+
*/
|
|
89
|
+
invalidate?: (id?: string | number | null) => void
|
|
84
90
|
/** Field config lookup — read-side too since list column binding (#1255) */
|
|
85
91
|
getFieldConfig: (name: string) => unknown | null
|
|
86
92
|
/** Config-carrying property: always present on the class, VALUE nullable */
|
|
@@ -1007,6 +1007,14 @@ export interface EntityManager<T extends EntityRecord = EntityRecord> {
|
|
|
1007
1007
|
/** @internal */ _loadCacheInBackground(): void
|
|
1008
1008
|
/** @internal */ _loadCache(): Promise<boolean>
|
|
1009
1009
|
invalidateCache(): void
|
|
1010
|
+
/** @internal */ _dropDetail(id?: string | number | null): void
|
|
1011
|
+
/** @internal */ _dropListCache(): void
|
|
1012
|
+
/** @internal */ _dropCaches(id?: string | number | null): void
|
|
1013
|
+
/**
|
|
1014
|
+
* A record of this entity changed, or the whole entity without an id: drop
|
|
1015
|
+
* what the caches hold of it and have the mounted views read it again.
|
|
1016
|
+
*/
|
|
1017
|
+
invalidate(id?: string | number | null): void
|
|
1010
1018
|
invalidateDataLayer(): void
|
|
1011
1019
|
ensureCache(): Promise<boolean>
|
|
1012
1020
|
warmup(): Promise<boolean | null>
|
|
@@ -189,6 +189,19 @@ export default `core:
|
|
|
189
189
|
subs: "{count} sub-phase | {count} sub-phases"
|
|
190
190
|
filter: "Phase: {name}"
|
|
191
191
|
showAll: Show the whole log
|
|
192
|
+
# Tasks chained in one window (#4934)
|
|
193
|
+
sequence:
|
|
194
|
+
progress: "{done}/{total}"
|
|
195
|
+
step: "Step {n}"
|
|
196
|
+
pending: Waiting
|
|
197
|
+
skipped: Not run
|
|
198
|
+
why:
|
|
199
|
+
error: An earlier step failed
|
|
200
|
+
cancelled: The sequence was stopped
|
|
201
|
+
reload: The page was reloaded
|
|
202
|
+
back: Back to the list
|
|
203
|
+
details: Show this step
|
|
204
|
+
cancel: Stop the sequence
|
|
192
205
|
# Waiting states (#4665)
|
|
193
206
|
pending:
|
|
194
207
|
reading: Reading…
|
|
@@ -187,6 +187,19 @@ core:
|
|
|
187
187
|
subs: "{count} sub-phase | {count} sub-phases"
|
|
188
188
|
filter: "Phase: {name}"
|
|
189
189
|
showAll: Show the whole log
|
|
190
|
+
# Tasks chained in one window (#4934)
|
|
191
|
+
sequence:
|
|
192
|
+
progress: "{done}/{total}"
|
|
193
|
+
step: "Step {n}"
|
|
194
|
+
pending: Waiting
|
|
195
|
+
skipped: Not run
|
|
196
|
+
why:
|
|
197
|
+
error: An earlier step failed
|
|
198
|
+
cancelled: The sequence was stopped
|
|
199
|
+
reload: The page was reloaded
|
|
200
|
+
back: Back to the list
|
|
201
|
+
details: Show this step
|
|
202
|
+
cancel: Stop the sequence
|
|
190
203
|
# Waiting states (#4665)
|
|
191
204
|
pending:
|
|
192
205
|
reading: Reading…
|
|
@@ -189,6 +189,19 @@ export default `core:
|
|
|
189
189
|
subs: "{count} sous-phase | {count} sous-phases"
|
|
190
190
|
filter: "Phase : {name}"
|
|
191
191
|
showAll: Voir tout le journal
|
|
192
|
+
# Tasks chained in one window (#4934)
|
|
193
|
+
sequence:
|
|
194
|
+
progress: "{done}/{total}"
|
|
195
|
+
step: "Étape {n}"
|
|
196
|
+
pending: En attente
|
|
197
|
+
skipped: Non lancée
|
|
198
|
+
why:
|
|
199
|
+
error: Une étape précédente a échoué
|
|
200
|
+
cancelled: La suite a été arrêtée
|
|
201
|
+
reload: La page a été rechargée
|
|
202
|
+
back: Retour à la liste
|
|
203
|
+
details: Voir cette étape
|
|
204
|
+
cancel: Arrêter la suite
|
|
192
205
|
# Waiting states (#4665)
|
|
193
206
|
pending:
|
|
194
207
|
reading: Lecture…
|
|
@@ -187,6 +187,19 @@ core:
|
|
|
187
187
|
subs: "{count} sous-phase | {count} sous-phases"
|
|
188
188
|
filter: "Phase : {name}"
|
|
189
189
|
showAll: Voir tout le journal
|
|
190
|
+
# Tasks chained in one window (#4934)
|
|
191
|
+
sequence:
|
|
192
|
+
progress: "{done}/{total}"
|
|
193
|
+
step: "Étape {n}"
|
|
194
|
+
pending: En attente
|
|
195
|
+
skipped: Non lancée
|
|
196
|
+
why:
|
|
197
|
+
error: Une étape précédente a échoué
|
|
198
|
+
cancelled: La suite a été arrêtée
|
|
199
|
+
reload: La page a été rechargée
|
|
200
|
+
back: Retour à la liste
|
|
201
|
+
details: Voir cette étape
|
|
202
|
+
cancel: Arrêter la suite
|
|
190
203
|
# Waiting states (#4665)
|
|
191
204
|
pending:
|
|
192
205
|
reading: Lecture…
|
package/src/index.ts
CHANGED
|
@@ -481,6 +481,12 @@ export {
|
|
|
481
481
|
type TaskFollow,
|
|
482
482
|
type TaskConfirm,
|
|
483
483
|
type RunOptions,
|
|
484
|
+
type SequenceStep,
|
|
485
|
+
type SequenceOptions,
|
|
486
|
+
type TaskInvalidate,
|
|
487
|
+
type SequenceStepStatus,
|
|
488
|
+
type TaskSequence,
|
|
489
|
+
type TaskSequenceStep,
|
|
484
490
|
} from './tasks/taskStore'
|
|
485
491
|
export {
|
|
486
492
|
TASK_PHASE_STATE_ICONS,
|
|
@@ -522,6 +528,7 @@ export {
|
|
|
522
528
|
type ModuleInitFunction,
|
|
523
529
|
type InitModulesOptions,
|
|
524
530
|
type MenuAlterContext,
|
|
531
|
+
type ItemTabsOptions,
|
|
525
532
|
// ParentConfig, NavItem, NavSection, ModuleDefinition - already exported
|
|
526
533
|
} from './module/moduleRegistry'
|
|
527
534
|
|
|
@@ -6,8 +6,10 @@ import {
|
|
|
6
6
|
type RouteLocationNormalized,
|
|
7
7
|
type RouteRecordNormalized,
|
|
8
8
|
} from 'vue-router'
|
|
9
|
-
import { getRoutes } from '../module/moduleRegistry'
|
|
9
|
+
import { getRoutes, getItemTabs } from '../module/moduleRegistry'
|
|
10
|
+
import { nestItemTabs } from './itemTabs'
|
|
10
11
|
import { installChunkReload } from './chunkReload'
|
|
12
|
+
import { routeEntity, routePermissions, missingPermission, entityDenial } from '../security/routeAccess'
|
|
11
13
|
import type { Kernel } from './Kernel'
|
|
12
14
|
// #1196 Phase B — this-typing against the real Kernel shape (was Self = any)
|
|
13
15
|
type Self = Kernel
|
|
@@ -72,7 +74,8 @@ export function applyRoutingMethods(KernelClass: { prototype: Kernel }): void {
|
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
76
|
|
|
75
|
-
|
|
77
|
+
// An entity shown as tabs gets its item's pages nested under one frame route (#4963)
|
|
78
|
+
const moduleRoutes = nestItemTabs(getRoutes() as RouteRecordRaw[], getItemTabs())
|
|
76
79
|
|
|
77
80
|
const publicRoutes = moduleRoutes.filter(
|
|
78
81
|
(r) => r.meta?.public || r.meta?.requiresAuth === false
|
|
@@ -247,32 +250,25 @@ export function applyRoutingMethods(KernelClass: { prototype: Kernel }): void {
|
|
|
247
250
|
return sessionLost ? { name: 'login', query: { session_lost: '1' } } : { name: 'login' }
|
|
248
251
|
}
|
|
249
252
|
|
|
250
|
-
|
|
251
|
-
//
|
|
252
|
-
//
|
|
253
|
-
//
|
|
254
|
-
//
|
|
253
|
+
// Who may open it (#4962): the same rule as the menu and PageNav —
|
|
254
|
+
// every matched record's meta.permission (#4332), and the route's entity
|
|
255
|
+
// (or, for a child page, its parent item's) for the action it declares
|
|
256
|
+
// (#2497). An entity not registered yet is the ONLY pass-through; a
|
|
257
|
+
// failing check fails CLOSED, never silently allows (#1190).
|
|
255
258
|
const orchestrator = this.orchestrator
|
|
256
|
-
const entityToCheck = !!entity && !!orchestrator && orchestrator.isRegistered(entity)
|
|
257
|
-
|
|
258
|
-
// Page permissions (#4332): every matched record's meta.permission, so a
|
|
259
|
-
// parent's covers its children; a list needs every entry. Without a
|
|
260
|
-
// security checker (an app without security) nothing is checked, as for
|
|
261
|
-
// the menu.
|
|
262
|
-
const permissions = to.matched.flatMap((record: RouteRecordNormalized) => {
|
|
263
|
-
const p = record.meta.permission
|
|
264
|
-
return (Array.isArray(p) ? p : [p]).filter((x): x is string => typeof x === 'string' && x !== '')
|
|
265
|
-
})
|
|
266
259
|
const checker = this.securityChecker
|
|
267
|
-
const
|
|
260
|
+
const deps = { orchestrator, checker }
|
|
261
|
+
const entity = routeEntity(to)
|
|
262
|
+
const entityToCheck = !!entity && !!orchestrator && orchestrator.isRegistered(entity)
|
|
263
|
+
const permissionsToCheck = routePermissions(to).length > 0 && !!checker
|
|
268
264
|
|
|
269
265
|
if (!entityToCheck && !permissionsToCheck) return
|
|
270
266
|
|
|
271
267
|
const checkPermissions = (): { path: string } | undefined => {
|
|
272
268
|
if (!permissionsToCheck) return undefined
|
|
273
269
|
try {
|
|
274
|
-
const missing =
|
|
275
|
-
if (missing ===
|
|
270
|
+
const missing = missingPermission(to, deps)
|
|
271
|
+
if (missing === null) return undefined
|
|
276
272
|
console.warn(`[qdadm] Access denied to ${to.path} (permission: ${missing})`)
|
|
277
273
|
orchestrator?.toast.error('Access Denied', "You don't have permission to access this page", 'Kernel')
|
|
278
274
|
this.signals!.emit('auth:access-denied', { path: to.path, permission: missing })
|
|
@@ -283,28 +279,23 @@ export function applyRoutingMethods(KernelClass: { prototype: Kernel }): void {
|
|
|
283
279
|
}
|
|
284
280
|
}
|
|
285
281
|
|
|
286
|
-
// The action the route declares (#2497): a list route is governed by
|
|
287
|
-
// `list`. A route that declares none — any custom page — checks `read`.
|
|
288
|
-
const action = to.meta?.entityAction === 'list' ? 'list' : 'read'
|
|
289
|
-
|
|
290
282
|
const checkEntity = (): { path: string } | undefined => {
|
|
291
283
|
if (!entityToCheck) return undefined
|
|
292
284
|
try {
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
if (manager && !allowed) {
|
|
285
|
+
const denial = entityDenial(to, deps)
|
|
286
|
+
if (denial) {
|
|
296
287
|
console.warn(
|
|
297
|
-
`[qdadm] Access denied to ${to.path} (entity: ${entity}, action: ${action})`
|
|
288
|
+
`[qdadm] Access denied to ${to.path} (entity: ${denial.entity}, action: ${denial.action})`
|
|
298
289
|
)
|
|
299
290
|
orchestrator!.toast.error(
|
|
300
291
|
'Access Denied',
|
|
301
|
-
`You don't have permission to access ${manager.labelPlural || entity}`,
|
|
292
|
+
`You don't have permission to access ${denial.manager.labelPlural || denial.entity}`,
|
|
302
293
|
'Kernel'
|
|
303
294
|
)
|
|
304
295
|
this.signals!.emit('auth:access-denied', {
|
|
305
296
|
path: to.path,
|
|
306
|
-
entity,
|
|
307
|
-
manager,
|
|
297
|
+
entity: denial.entity,
|
|
298
|
+
manager: denial.manager,
|
|
308
299
|
})
|
|
309
300
|
return { path: '/' }
|
|
310
301
|
}
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* framework cannot afford two answers to the same question.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import type { ItemTabsOptions } from '../module/moduleRegistry'
|
|
17
18
|
import type { RouteRecordRaw } from 'vue-router'
|
|
18
19
|
import pluralize from '../utils/pluralize'
|
|
19
20
|
import { registry, getRoutes } from '../module/moduleRegistry'
|
|
@@ -153,6 +154,11 @@ export function applyRoutingMethods(KernelContextClass: { prototype: KernelConte
|
|
|
153
154
|
return this
|
|
154
155
|
}
|
|
155
156
|
|
|
157
|
+
proto.itemTabs = function (this: Self, entity: string, options: ItemTabsOptions = {}): Self {
|
|
158
|
+
registry.addItemTabs(entity, options)
|
|
159
|
+
return this
|
|
160
|
+
}
|
|
161
|
+
|
|
156
162
|
proto.navItem = function (this: Self, item: NavItem): Self {
|
|
157
163
|
registry.addNavItem(item)
|
|
158
164
|
return this
|
|
@@ -389,6 +395,9 @@ export function applyRoutingMethods(KernelContextClass: { prototype: KernelConte
|
|
|
389
395
|
meta: {
|
|
390
396
|
layout: 'page',
|
|
391
397
|
...(options.icon && { icon: options.icon }),
|
|
398
|
+
// On top of the parent item's read right, which the guard checks
|
|
399
|
+
// through meta.parent (#4962)
|
|
400
|
+
...(options.permission !== undefined && { permission: options.permission }),
|
|
392
401
|
...options.meta,
|
|
393
402
|
},
|
|
394
403
|
},
|