@quazardous/qdadm 2.33.1 → 2.34.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quazardous/qdadm",
3
- "version": "2.33.1",
3
+ "version": "2.34.0",
4
4
  "description": "Vue 3 framework for admin dashboards with PrimeVue",
5
5
  "author": "quazardous",
6
6
  "license": "MIT",
@@ -62,7 +62,7 @@
62
62
  "dist/styles"
63
63
  ],
64
64
  "dependencies": {
65
- "@quazardous/qdcore": "^1.2.0",
65
+ "@quazardous/qdcore": "^1.3.0",
66
66
  "@quazardous/qddebug": "^1.3.0",
67
67
  "@quazardous/quarkernel": "^2.1.0",
68
68
  "yaml": "^2.8.4"
@@ -39,10 +39,10 @@
39
39
  * - loading: boolean - shows loading state on submit button
40
40
  * - width: string - dialog width (default: '800px')
41
41
  * - linear: boolean - require validation before next step (default: true)
42
- * - submitLabel: string - label for submit button (default: 'Submit')
43
- * - cancelLabel: string - label for cancel button (default: 'Cancel')
44
- * - nextLabel: string - label for next button (default: 'Next')
45
- * - backLabel: string - label for back button (default: 'Back')
42
+ * - submitLabel: string - label for submit button (default: core.actions.submit)
43
+ * - cancelLabel: string - label for cancel button (default: core.actions.cancel)
44
+ * - nextLabel: string - label for next button (default: core.actions.next)
45
+ * - backLabel: string - label for back button (default: core.actions.back)
46
46
  * - showBackOnFirst: boolean - show back button on first step (default: false)
47
47
  * - hideStepIndicator: boolean - hide the step indicator (default: false)
48
48
  *
@@ -59,6 +59,7 @@
59
59
  import { computed, watch, type PropType } from 'vue'
60
60
  import Dialog from 'primevue/dialog'
61
61
  import QdButton from '../base/QdButton.vue'
62
+ import { useI18n } from '../../i18n/useI18n'
62
63
  import Stepper from 'primevue/stepper'
63
64
  import StepList from 'primevue/steplist'
64
65
  import Step from 'primevue/step'
@@ -88,6 +89,8 @@ export interface SlotActions {
88
89
  cancel: () => void
89
90
  }
90
91
 
92
+ const { tOr } = useI18n()
93
+
91
94
  const props = defineProps({
92
95
  visible: {
93
96
  type: Boolean,
@@ -120,19 +123,19 @@ const props = defineProps({
120
123
  },
121
124
  submitLabel: {
122
125
  type: String,
123
- default: 'Submit'
126
+ default: ''
124
127
  },
125
128
  cancelLabel: {
126
129
  type: String,
127
- default: 'Cancel'
130
+ default: ''
128
131
  },
129
132
  nextLabel: {
130
133
  type: String,
131
- default: 'Next'
134
+ default: ''
132
135
  },
133
136
  backLabel: {
134
137
  type: String,
135
- default: 'Back'
138
+ default: ''
136
139
  },
137
140
  showBackOnFirst: {
138
141
  type: Boolean,
@@ -286,7 +289,7 @@ const slotActions = computed<SlotActions>(() => ({
286
289
  <!-- Back button -->
287
290
  <QdButton
288
291
  v-if="!isFirstStep || showBackOnFirst"
289
- :label="backLabel"
292
+ :label="backLabel || tOr('core.actions.back', 'Back')"
290
293
  icon="pi pi-arrow-left"
291
294
  severity="secondary"
292
295
  @click="goPrev"
@@ -295,7 +298,7 @@ const slotActions = computed<SlotActions>(() => ({
295
298
 
296
299
  <!-- Cancel button -->
297
300
  <QdButton
298
- :label="cancelLabel"
301
+ :label="cancelLabel || tOr('core.actions.cancel', 'Cancel')"
299
302
  severity="secondary"
300
303
  @click="cancel"
301
304
  :disabled="loading"
@@ -304,7 +307,7 @@ const slotActions = computed<SlotActions>(() => ({
304
307
  <!-- Next button (not on last step) -->
305
308
  <QdButton
306
309
  v-if="!isLastStep"
307
- :label="nextLabel"
310
+ :label="nextLabel || tOr('core.actions.next', 'Next')"
308
311
  icon="pi pi-arrow-right"
309
312
  iconPos="right"
310
313
  @click="goNext"
@@ -314,7 +317,7 @@ const slotActions = computed<SlotActions>(() => ({
314
317
  <!-- Submit button (only on last step) -->
315
318
  <QdButton
316
319
  v-if="isLastStep"
317
- :label="submitLabel"
320
+ :label="submitLabel || tOr('core.actions.submit', 'Submit')"
318
321
  icon="pi pi-check"
319
322
  @click="submit"
320
323
  :loading="loading"
@@ -258,20 +258,22 @@ const fullFormat = computed(() => new Intl.DateTimeFormat(locale.value, { dateSt
258
258
 
259
259
  const rows = computed<Row[]>(() => {
260
260
  const visible = chronological.value.filter((e) => !e.item.actor || !hiddenActors.value.has(e.item.actor))
261
- const withSince = visible.map((entry, i) => ({
262
- entry,
263
- since: props.gaps === true && i > 0 ? duration(entry.time - visible[i - 1]!.time) : null,
264
- }))
265
- const ordered = currentOrder.value === 'desc' ? [...withSince].reverse() : withSince
261
+ const ordered = currentOrder.value === 'desc' ? [...visible].reverse() : visible
266
262
  const out: Row[] = []
267
263
  let lastDay = ''
268
- for (const { entry, since } of ordered) {
264
+ let previous: (typeof visible)[number] | null = null
265
+ for (const entry of ordered) {
269
266
  const day = dayFormat.value.format(entry.time)
270
- if (day !== lastDay) {
267
+ const newDay = day !== lastDay
268
+ if (newDay) {
271
269
  out.push({ type: 'day', key: `day:${day}`, day })
272
270
  lastDay = day
273
271
  }
272
+ // The gap sits above an event and reads from the row above it, in either
273
+ // order. Under a day separator it is left out: the date says it.
274
+ const since = props.gaps === true && previous && !newDay ? duration(Math.abs(entry.time - previous.time)) : null
274
275
  out.push({ type: 'event', key: entry.key, entry, since })
276
+ previous = entry
275
277
  }
276
278
  return out
277
279
  })
@@ -58,6 +58,11 @@ const props = withDefaults(defineProps<Props>(), {
58
58
  maxLines: 100_000,
59
59
  })
60
60
 
61
+ const emit = defineEmits<{
62
+ /** The source reported the end of the log. */
63
+ done: []
64
+ }>()
65
+
61
66
  const { t } = useI18n()
62
67
 
63
68
  const log: UseLogStreamReturn =
@@ -272,6 +277,12 @@ function download(): void {
272
277
 
273
278
  // --- Status ---
274
279
 
280
+ watch(
281
+ () => log.status.value,
282
+ (status) => status === 'done' && emit('done'),
283
+ { immediate: true }
284
+ )
285
+
275
286
  const statusLabel = computed(() => {
276
287
  switch (log.status.value) {
277
288
  case 'streaming':
@@ -19,6 +19,7 @@ import { computed, watch, inject, type Ref } from 'vue'
19
19
  import { useRoute, useRouter } from 'vue-router'
20
20
  import { getSiblingRoutes, getChildRoutes, routeParamsSatisfied, type ModuleRoute, type ParentConfig } from '../../module/moduleRegistry'
21
21
  import { useOrchestrator } from '../../orchestrator/useOrchestrator.js'
22
+ import { useI18n } from '../../i18n/useI18n'
22
23
  import type { EntityManager } from '../../entity/EntityManager'
23
24
  import type { EntityRecord } from '../../types'
24
25
 
@@ -39,6 +40,7 @@ const props = defineProps<{
39
40
  const route = useRoute()
40
41
  const router = useRouter()
41
42
  const { getManager } = useOrchestrator()
43
+ const { tOr } = useI18n()
42
44
 
43
45
  // Parent config from route meta
44
46
  const parentConfig = computed<ParentConfig | undefined>(() => route.meta?.parent as ParentConfig | undefined)
@@ -156,7 +158,7 @@ const allNavlinks = computed<NavLink[]>(() => {
156
158
 
157
159
  // Details link to parent item page
158
160
  const detailsLink: NavLink = {
159
- label: 'Details',
161
+ label: tOr('breadcrumb.details', 'Details'),
160
162
  to: { name: parentRouteName ?? undefined, params: { [parentManager.idField]: parentId } },
161
163
  active: isOnParentRoute
162
164
  }
@@ -172,7 +174,7 @@ const allNavlinks = computed<NavLink[]>(() => {
172
174
  // Details link is optional since breadcrumb already shows current page
173
175
  if (props.showDetailsLink) {
174
176
  const detailsLink: NavLink = {
175
- label: 'Details',
177
+ label: tOr('breadcrumb.details', 'Details'),
176
178
  to: { name: route.name as string | undefined, params: route.params as Record<string, unknown> },
177
179
  active: true
178
180
  }
@@ -6,8 +6,10 @@
6
6
  */
7
7
  import { computed, type ComputedRef } from 'vue'
8
8
  import { useRouter, type RouteRecordName } from 'vue-router'
9
+ import { useI18n } from '../../i18n/useI18n'
9
10
 
10
11
  const router = useRouter()
12
+ const { tOr } = useI18n()
11
13
 
12
14
  const homeRoute: ComputedRef<RouteRecordName | string> = computed(() => {
13
15
  // Find home route (first route or named 'home'/'dashboard')
@@ -29,11 +31,11 @@ function goHome(): void {
29
31
  <div class="not-found-page">
30
32
  <div class="not-found-content">
31
33
  <div class="not-found-code">404</div>
32
- <h1>Page not found</h1>
33
- <p>The page you're looking for doesn't exist or has been moved.</p>
34
+ <h1>{{ tOr('core.notFound.title', 'Page not found') }}</h1>
35
+ <p>{{ tOr('core.notFound.message', "The page you're looking for doesn't exist or has been moved.") }}</p>
34
36
  <button class="home-link" @click="goHome">
35
37
  <i class="pi pi-home"></i>
36
- Back to Home
38
+ {{ tOr('core.notFound.home', 'Back to Home') }}
37
39
  </button>
38
40
  </div>
39
41
  </div>
@@ -69,7 +69,7 @@ const elapsed = computed(() => {
69
69
  <div v-if="run.step" class="qd-task-step">{{ run.step }}</div>
70
70
 
71
71
  <LogStream v-if="logSource" :key="run.id" class="qd-task-log" :source="logSource" height="16rem"
72
- error-pattern="error|fatal|failed" />
72
+ error-pattern="error|fatal|failed" @done="store.poke(run.id)" />
73
73
 
74
74
  <div v-if="run.status === 'failed' && run.error" class="qd-task-error"><i class="pi pi-exclamation-triangle" /> {{ run.error }}</div>
75
75
  <div v-else-if="!final && run.error" class="qd-task-warning">{{ t('core.task.readError', { error: run.error }) }}</div>
@@ -27,12 +27,13 @@ const typed = ref('')
27
27
  watch(pending, () => (typed.value = ''))
28
28
  const expected = computed(() => pending.value?.confirm.typed ?? null)
29
29
  const confirmable = computed(() => expected.value === null || typed.value === expected.value)
30
+ const severity = computed(() => pending.value?.confirm.severity ?? (expected.value !== null ? 'danger' : 'primary'))
30
31
  </script>
31
32
 
32
33
  <template>
33
34
  <TaskDialog :run-id="store.state.openId" @close="store.open(null)" />
34
35
  <SimpleDialog :visible="!!pending" :title="pending?.label ?? ''" :confirm-label="pending?.confirm.accept ?? t('core.task.start')"
35
- confirm-severity="danger" :confirm-disabled="!confirmable" :cancel-label="t('core.task.dontStart')"
36
+ :confirm-severity="severity" :confirm-disabled="!confirmable" :cancel-label="t('core.task.dontStart')"
36
37
  @confirm="store.answerConfirm(true)" @cancel="store.answerConfirm(false)"
37
38
  @update:visible="(v: boolean) => !v && pending && store.answerConfirm(false)">
38
39
  <p v-if="pending?.confirm.message" class="qd-task-confirm-message">{{ pending.confirm.message }}</p>
@@ -2,6 +2,7 @@ import { computed, inject, type ComputedRef, type Ref } from 'vue'
2
2
  import { useRouter } from 'vue-router'
3
3
  import { useSemanticBreadcrumb, type SemanticBreadcrumbItem } from './useSemanticBreadcrumb'
4
4
  import { useStackHydrator, type HydratedLevel } from '../chain/useStackHydrator'
5
+ import { useI18n } from '../i18n/useI18n'
5
6
 
6
7
  /**
7
8
  * Breadcrumb display item
@@ -59,14 +60,21 @@ export function useBreadcrumb(options: UseBreadcrumbOptions = {}): UseBreadcrumb
59
60
  // Get hydrator for parent entity labels
60
61
  const hydrator = useStackHydrator()
61
62
 
62
- // Default label mapping
63
- const defaultLabelMap: Record<string, string> = {
64
- home: 'Home',
65
- dashboard: 'Dashboard',
66
- create: 'Create',
67
- edit: 'Edit',
68
- show: 'View',
69
- delete: 'Delete',
63
+ // Default labels, from the i18n catalog (a custom labelMap entry wins)
64
+ const { tOr } = useI18n()
65
+ const defaultLabels: Record<string, [string, string]> = {
66
+ home: ['breadcrumb.home', 'Home'],
67
+ dashboard: ['breadcrumb.dashboard', 'Dashboard'],
68
+ create: ['core.actions.create', 'Create'],
69
+ edit: ['core.actions.edit', 'Edit'],
70
+ show: ['core.actions.view', 'View'],
71
+ delete: ['core.actions.delete', 'Delete'],
72
+ }
73
+ function label(key: string): string | undefined {
74
+ const custom = options.labelMap?.[key]
75
+ if (custom) return custom
76
+ const def = defaultLabels[key]
77
+ return def ? tOr(def[0], def[1]) : undefined
70
78
  }
71
79
 
72
80
  // Default icon mapping for entities
@@ -80,7 +88,6 @@ export function useBreadcrumb(options: UseBreadcrumbOptions = {}): UseBreadcrumb
80
88
  }
81
89
 
82
90
  // Merge with custom mappings
83
- const labelMap = { ...defaultLabelMap, ...options.labelMap }
84
91
  const iconMap = { ...defaultIconMap, ...options.iconMap }
85
92
 
86
93
  /**
@@ -133,7 +140,7 @@ export function useBreadcrumb(options: UseBreadcrumbOptions = {}): UseBreadcrumb
133
140
  if (item.kind === 'route') {
134
141
  // Generic route
135
142
  const routeName = item.route!
136
- displayItem.label = item.label || labelMap[routeName] || capitalize(routeName)
143
+ displayItem.label = item.label || label(routeName) || capitalize(routeName)
137
144
  displayItem.to = isLast ? null : routeExists(routeName) ? { name: routeName } : null
138
145
  if (routeName === 'home') {
139
146
  displayItem.icon = 'pi pi-home'
@@ -144,7 +151,7 @@ export function useBreadcrumb(options: UseBreadcrumbOptions = {}): UseBreadcrumb
144
151
 
145
152
  if (item.kind === 'entity-list') {
146
153
  // Entity list - use plural label
147
- displayItem.label = labelMap[entityName] || capitalize(entityName)
154
+ displayItem.label = label(entityName) || capitalize(entityName)
148
155
  displayItem.icon = index === 1 ? iconMap[entityName] || null : null
149
156
  const routeName = getEntityRouteName(entityName, item.kind)
150
157
  displayItem.to = isLast ? null : routeExists(routeName) ? { name: routeName } : null
@@ -177,7 +184,7 @@ export function useBreadcrumb(options: UseBreadcrumbOptions = {}): UseBreadcrumb
177
184
  }
178
185
  } else if (item.kind === 'entity-create') {
179
186
  // Create page - label as action
180
- displayItem.label = labelMap.create || 'Create'
187
+ displayItem.label = label('create')!
181
188
  }
182
189
  }
183
190
 
@@ -190,7 +197,7 @@ export function useBreadcrumb(options: UseBreadcrumbOptions = {}): UseBreadcrumb
190
197
  function getHomeItem(): BreadcrumbDisplayItem | null {
191
198
  if (!homeRouteName || !routeExists(homeRouteName)) return null
192
199
  return {
193
- label: labelMap.home || 'Home',
200
+ label: label('home')!,
194
201
  to: { name: homeRouteName },
195
202
  icon: 'pi pi-home',
196
203
  }
@@ -237,7 +244,7 @@ export function useBreadcrumb(options: UseBreadcrumbOptions = {}): UseBreadcrumb
237
244
  */
238
245
  function setBreadcrumb(items: BreadcrumbDisplayItem[]): BreadcrumbDisplayItem[] {
239
246
  const homeItem: BreadcrumbDisplayItem = {
240
- label: labelMap.home || 'Home',
247
+ label: label('home')!,
241
248
  to: { name: homeRouteName! },
242
249
  icon: 'pi pi-home',
243
250
  }
@@ -31,6 +31,7 @@ import { requireDeleteConfirmation } from './confirmDelete'
31
31
  import { useDirtyState } from './useDirtyState'
32
32
  import { useUnsavedChangesGuard, type GuardDialogState } from './useUnsavedChangesGuard'
33
33
  import { useBreadcrumb } from './useBreadcrumb'
34
+ import { useI18n } from '../i18n/useI18n'
34
35
  import {
35
36
  useEntityItemPage,
36
37
  type CreateContext,
@@ -130,6 +131,7 @@ export function useEntityItemFormPage<T extends Record<string, unknown> = Record
130
131
  const router = useRouter()
131
132
  const route = useRoute()
132
133
  const confirm = useConfirm() as ConfirmService
134
+ const { tOr } = useI18n()
133
135
  const debug = inject<boolean>('qdadmDebug', false)
134
136
  // Loads show as activity on the notification badge (#2677); a no-op without notifications.
135
137
  const notifications = useNotifications()
@@ -441,8 +443,8 @@ export function useEntityItemFormPage<T extends Record<string, unknown> = Record
441
443
  function confirmDelete(): void {
442
444
  const label = manager.getEntityLabel(data.value) || entityId.value
443
445
  requireDeleteConfirmation(confirm, {
444
- message: `Delete ${entityName} "${label}"?`,
445
- header: 'Confirm Delete',
446
+ message: tOr('core.messages.confirmDeleteItem', 'Delete {entity} "{label}"?', { entity: entityName, label: String(label) }),
447
+ header: tOr('core.messages.confirmDeleteTitle', 'Confirm Delete'),
446
448
  accept: remove,
447
449
  })
448
450
  }
@@ -766,7 +768,7 @@ export function useEntityItemFormPage<T extends Record<string, unknown> = Record
766
768
  }
767
769
 
768
770
  function addDeleteAction(options: AddDeleteActionOptions = {}): void {
769
- const { label = 'Delete' } = options
771
+ const { label = tOr('core.actions.delete', 'Delete') } = options
770
772
 
771
773
  addAction('delete', {
772
774
  label,
@@ -798,13 +800,14 @@ export function useEntityItemFormPage<T extends Record<string, unknown> = Record
798
800
  const pageTitle = computed(() => {
799
801
  if (isEdit.value) {
800
802
  const label = entityLabel.value
801
- return label ? `Edit ${entityName}: ${label}` : `Edit ${entityName}`
803
+ const action = tOr('core.actions.edit', 'Edit')
804
+ return label ? `${action} ${entityName}: ${label}` : `${action} ${entityName}`
802
805
  }
803
- return `Create ${entityName}`
806
+ return `${tOr('core.actions.create', 'Create')} ${entityName}`
804
807
  })
805
808
 
806
809
  const pageTitleParts = computed<PageTitleParts>(() => ({
807
- action: isEdit.value ? 'Edit' : 'Create',
810
+ action: isEdit.value ? tOr('core.actions.edit', 'Edit') : tOr('core.actions.create', 'Create'),
808
811
  entityName,
809
812
  entityLabel: isEdit.value ? entityLabel.value : undefined,
810
813
  }))
@@ -39,6 +39,7 @@ import { useRouter, useRoute, type Router } from 'vue-router'
39
39
  import { useNotifications } from '../notifications/NotificationStore'
40
40
  import { useConfirm } from 'primevue/useconfirm'
41
41
  import { requireDeleteConfirmation } from './confirmDelete'
42
+ import { useI18n } from '../i18n/useI18n'
42
43
  import {
43
44
  useEntityItemPage,
44
45
  type ParentConfig,
@@ -270,6 +271,7 @@ export function useEntityItemShowPage<T = Record<string, unknown>>(
270
271
 
271
272
  const router: Router = useRouter()
272
273
  const confirm = useConfirm() as ConfirmService
274
+ const { tOr } = useI18n()
273
275
 
274
276
  // Lazy action state (declared before base so onLoadSuccess wrapper can reference it)
275
277
  const lazyActionsMap = ref<Map<string, LazyActionConfig>>(new Map())
@@ -441,7 +443,7 @@ export function useEntityItemShowPage<T = Record<string, unknown>>(
441
443
  }
442
444
 
443
445
  function addEditAction(editOptions: { label?: string; icon?: string } = {}): UseEntityItemShowPageReturn<T> {
444
- const { label = 'Edit', icon = 'pi pi-pencil' } = editOptions
446
+ const { label = tOr('core.actions.edit', 'Edit'), icon = 'pi pi-pencil' } = editOptions
445
447
  return addAction({
446
448
  name: 'edit',
447
449
  label,
@@ -455,7 +457,7 @@ export function useEntityItemShowPage<T = Record<string, unknown>>(
455
457
  function addDeleteAction(
456
458
  deleteOptions: { label?: string; icon?: string; confirm?: boolean } = {}
457
459
  ): UseEntityItemShowPageReturn<T> {
458
- const { label = 'Delete', icon = 'pi pi-trash', confirm: confirmDelete = true } = deleteOptions
460
+ const { label = tOr('core.actions.delete', 'Delete'), icon = 'pi pi-trash', confirm: confirmDelete = true } = deleteOptions
459
461
  return addAction({
460
462
  name: 'delete',
461
463
  label,
@@ -464,8 +466,8 @@ export function useEntityItemShowPage<T = Record<string, unknown>>(
464
466
  onClick: () => {
465
467
  if (confirmDelete) {
466
468
  requireDeleteConfirmation(confirm, {
467
- message: `Are you sure you want to delete this ${manager.label || entity}?`,
468
- header: 'Confirm Delete',
469
+ message: tOr('core.messages.confirmDeleteThis', 'Are you sure you want to delete this {entity}?', { entity: manager.label || entity }),
470
+ header: tOr('core.messages.confirmDeleteTitle', 'Confirm Delete'),
469
471
  accept: () => deleteEntity(),
470
472
  })
471
473
  } else {
@@ -477,7 +479,7 @@ export function useEntityItemShowPage<T = Record<string, unknown>>(
477
479
  }
478
480
 
479
481
  function addBackAction(backOptions: { label?: string; icon?: string; route?: string } = {}): UseEntityItemShowPageReturn<T> {
480
- const { label = 'Back', icon = 'pi pi-arrow-left', route: backRoute } = backOptions
482
+ const { label = tOr('core.actions.back', 'Back'), icon = 'pi pi-arrow-left', route: backRoute } = backOptions
481
483
  return addAction({
482
484
  name: 'back',
483
485
  label,
@@ -532,7 +534,7 @@ export function useEntityItemShowPage<T = Record<string, unknown>>(
532
534
  // ============ PAGE TITLE ============
533
535
 
534
536
  const titleParts = computed<PageTitleParts>(() => ({
535
- action: 'View',
537
+ action: tOr('core.actions.view', 'View'),
536
538
  entityName: manager.label || entity,
537
539
  entityLabel: entityLabel.value || undefined,
538
540
  }))
@@ -151,7 +151,7 @@ export function useListPage<T = unknown>(config: UseListPageOptions<T>): UseList
151
151
  const isMobile = ref(window.innerWidth < 768)
152
152
 
153
153
  // i18n integration — column headers resolve via entities.{entity}.fields.{field}
154
- const { i18n: kernelI18n, locale: i18nLocale } = useI18n()
154
+ const { i18n: kernelI18n, locale: i18nLocale, tOr } = useI18n()
155
155
 
156
156
  // Get EntityManager via orchestrator (#1193 — canonical injection: one
157
157
  // error-message source; erased to this file's Read-tier view)
@@ -1059,8 +1059,11 @@ export function useListPage<T = unknown>(config: UseListPageOptions<T>): UseList
1059
1059
  function confirmDelete(item: unknown, labelField = 'name'): void {
1060
1060
  const itemRecord = item as Record<string, unknown>
1061
1061
  requireDeleteConfirmation(confirm, {
1062
- message: `Delete ${entityName} "${itemRecord[labelField] || itemRecord[resolvedDataKey]}"?`,
1063
- header: 'Confirm Delete',
1062
+ message: tOr('core.messages.confirmDeleteItem', 'Delete {entity} "{label}"?', {
1063
+ entity: entityName,
1064
+ label: String(itemRecord[labelField] || itemRecord[resolvedDataKey]),
1065
+ }),
1066
+ header: tOr('core.messages.confirmDeleteTitle', 'Confirm Delete'),
1064
1067
  accept: () => deleteItem(item, labelField),
1065
1068
  })
1066
1069
  }
@@ -1243,7 +1246,7 @@ export function useListPage<T = unknown>(config: UseListPageOptions<T>): UseList
1243
1246
  function addViewAction(options: Partial<ActionConfig> = {}): void {
1244
1247
  addAction('view', {
1245
1248
  icon: 'pi pi-eye',
1246
- tooltip: 'View',
1249
+ tooltip: tOr('core.actions.view', 'View'),
1247
1250
  onClick: options.onClick || goToShow,
1248
1251
  ...options,
1249
1252
  })
@@ -1252,7 +1255,7 @@ export function useListPage<T = unknown>(config: UseListPageOptions<T>): UseList
1252
1255
  function addEditAction(options: Partial<ActionConfig> = {}): void {
1253
1256
  addAction('edit', {
1254
1257
  icon: 'pi pi-pencil',
1255
- tooltip: 'Edit',
1258
+ tooltip: tOr('core.actions.edit', 'Edit'),
1256
1259
  onClick: options.onClick || goToEdit,
1257
1260
  visible: (row) => manager.canUpdate(row),
1258
1261
  ...options,
@@ -1263,7 +1266,7 @@ export function useListPage<T = unknown>(config: UseListPageOptions<T>): UseList
1263
1266
  const labelField = options.labelField || 'name'
1264
1267
  addAction('delete', {
1265
1268
  icon: 'pi pi-trash',
1266
- tooltip: 'Delete',
1269
+ tooltip: tOr('core.actions.delete', 'Delete'),
1267
1270
  severity: 'danger',
1268
1271
  onClick: (row) => confirmDelete(row, labelField),
1269
1272
  visible: (row) => manager.canDelete(row),
@@ -153,7 +153,7 @@ export function useNavContext(_options: UseNavContextOptions = {}): UseNavContex
153
153
  const hydrator = useStackHydrator()
154
154
 
155
155
  // i18n for the mode-toggle labels (no-op shim outside a kernel)
156
- const { i18n: kernelI18n, locale: i18nLocale } = useI18n()
156
+ const { tOr, locale: i18nLocale } = useI18n()
157
157
 
158
158
  function getManager(entityName: string): EntityManager | null {
159
159
  return orchestrator?.get(entityName) ?? null
@@ -224,7 +224,7 @@ export function useNavContext(_options: UseNavContextOptions = {}): UseNavContex
224
224
  type: 'create',
225
225
  entity: item.entity,
226
226
  manager,
227
- label: 'Create',
227
+ label: tOr('core.actions.create', 'Create'),
228
228
  routeName: manager ? `${manager.routePrefix}-create` : null,
229
229
  })
230
230
  } else if (item.kind === 'route') {
@@ -302,7 +302,7 @@ export function useNavContext(_options: UseNavContextOptions = {}): UseNavContex
302
302
  const homeItem = computed(() => {
303
303
  if (!homeRouteName || !routeExists(homeRouteName)) return null
304
304
  return {
305
- label: homeRouteName === 'dashboard' ? 'Dashboard' : 'Home',
305
+ label: homeRouteName === 'dashboard' ? breadcrumbLabel('dashboard', 'Dashboard') : breadcrumbLabel('home', 'Home'),
306
306
  to: { name: homeRouteName },
307
307
  icon: 'pi pi-home',
308
308
  }
@@ -461,9 +461,7 @@ export function useNavContext(_options: UseNavContextOptions = {}): UseNavContex
461
461
 
462
462
  /** Resolve a `breadcrumb.*` label from the i18n catalog, with fallback. */
463
463
  function breadcrumbLabel(key: string, fallback: string): string {
464
- const trace = kernelI18n?.resolve(`breadcrumb.${key}`)
465
- if (trace?.hit) return trace.result
466
- return fallback
464
+ return tOr(`breadcrumb.${key}`, fallback)
467
465
  }
468
466
 
469
467
  function toggleLabel(target: 'show' | 'edit'): string {
@@ -198,3 +198,17 @@ describe('I18n — dump', () => {
198
198
  expect(dumped.core).toBeUndefined()
199
199
  })
200
200
  })
201
+
202
+ describe('I18n — plural forms in the core bundle (#4147)', () => {
203
+ it('reads the singular for one, by the locale rules', async () => {
204
+ const fr = new I18n({ defaultLocale: 'fr' })
205
+ await fr.bootstrap()
206
+ expect(fr.t('core.task.tray', { count: 1 })).toBe('1 tâche en cours')
207
+ expect(fr.t('core.task.tray', { count: 0 })).toBe('0 tâche en cours')
208
+ expect(fr.t('core.log.lines', { count: 12 })).toBe('12 lignes')
209
+ const en = new I18n()
210
+ await en.bootstrap()
211
+ expect(en.t('core.log.errors', { count: 1 })).toBe('1 error')
212
+ expect(en.t('core.log.errors', { count: 0 })).toBe('0 errors')
213
+ })
214
+ })
@@ -45,7 +45,7 @@ describe('i18n default providers — generated/.yml sync', () => {
45
45
  const provider = createDefaultCoreProvider()
46
46
  const en = (await provider.load('en')) as BreadcrumbBundle
47
47
  const fr = (await provider.load('fr')) as BreadcrumbBundle
48
- expect(en.breadcrumb).toEqual({ view: 'View', edit: 'Edit' })
49
- expect(fr.breadcrumb).toEqual({ view: 'Voir', edit: 'Modifier' })
48
+ expect(en.breadcrumb).toEqual({ home: 'Home', dashboard: 'Dashboard', details: 'Details', view: 'View', edit: 'Edit' })
49
+ expect(fr.breadcrumb).toEqual({ home: 'Accueil', dashboard: 'Tableau de bord', details: 'Détails', view: 'Voir', edit: 'Modifier' })
50
50
  })
51
51
  })
@@ -15,6 +15,7 @@ export default `core:
15
15
  submit: Submit
16
16
  reset: Reset
17
17
  back: Back
18
+ view: View
18
19
  next: Next
19
20
  previous: Previous
20
21
  close: Close
@@ -48,6 +49,9 @@ export default `core:
48
49
  created: Created
49
50
  updated: Updated
50
51
  confirmDelete: Are you sure you want to delete this item?
52
+ confirmDeleteTitle: Confirm Delete
53
+ confirmDeleteItem: 'Delete {entity} "{label}"?'
54
+ confirmDeleteThis: Are you sure you want to delete this {entity}?
51
55
  errors:
52
56
  required: Required
53
57
  tooShort: Too short (min {min})
@@ -77,24 +81,24 @@ export default `core:
77
81
  done: Complete
78
82
  stopped: Stopped
79
83
  failed: "Failed: {error}"
80
- lines: "{count} lines"
84
+ lines: "{count} line | {count} lines"
81
85
  search: Search the log
82
86
  previous: Previous match
83
87
  next: Next match
84
88
  onlyMatches: Only matching lines
85
- errors: "{count} errors"
89
+ errors: "{count} error | {count} errors"
86
90
  firstError: Go to the next error line
87
91
  wrap: Wrap long lines
88
92
  follow: Follow the end of the log
89
93
  download: Download the log
90
- newLines: "{count} new lines, resume"
94
+ newLines: "{count} new line, resume | {count} new lines, resume"
91
95
  empty: No output yet
92
96
  # EntityTimeline (#4111)
93
97
  timeline:
94
98
  actors: Filter by actor
95
99
  loading: Loading…
96
100
  empty: Nothing happened yet
97
- newEvents: "{count} new events"
101
+ newEvents: "{count} new event | {count} new events"
98
102
  oldestFirst: Oldest first
99
103
  newestFirst: Newest first
100
104
  # PayloadViewer / PayloadDiff (#4112)
@@ -105,14 +109,14 @@ export default `core:
105
109
  copied: Copied to the clipboard
106
110
  copyFailed: Could not copy
107
111
  download: Download
108
- showAll: "Show all {count} rows"
112
+ showAll: "Show {count} row | Show all {count} rows"
109
113
  binary: "Binary content, {size}. First bytes:"
110
114
  malformed: "Not valid {format} ({error}), shown as text"
111
115
  expected: Expected
112
116
  captured: Captured
113
117
  identical: Identical
114
- unchanged: "{count} unchanged lines"
115
- showSame: "Show {count} unchanged rows"
118
+ unchanged: "{count} unchanged line | {count} unchanged lines"
119
+ showSame: "Show {count} unchanged row | Show {count} unchanged rows"
116
120
  inline: Inline
117
121
  split: Side by side
118
122
  # EmailPreview (#4113)
@@ -129,7 +133,7 @@ export default `core:
129
133
  html: HTML
130
134
  text: Text
131
135
  source: Source
132
- imagesBlocked: "{count} remote images blocked"
136
+ imagesBlocked: "{count} remote image blocked | {count} remote images blocked"
133
137
  loadImages: Load images
134
138
  blockImages: Block images
135
139
  empty: This email has no body
@@ -153,11 +157,19 @@ export default `core:
153
157
  start: Start
154
158
  dontStart: Do not start
155
159
  typeToConfirm: "Type {value} to confirm"
156
- tray: "{count} running tasks"
160
+ tray: "{count} running task | {count} running tasks"
157
161
  trayDone: Recent tasks
158
162
  clear: Clear finished
159
- # The breadcrumb's View↔Edit toggle (useNavContext).
163
+ # NotFoundPage
164
+ notFound:
165
+ title: Page not found
166
+ message: The page you're looking for doesn't exist or has been moved.
167
+ home: Back to Home
168
+ # The breadcrumb (useBreadcrumb, useNavContext, PageNav).
160
169
  breadcrumb:
170
+ home: Home
171
+ dashboard: Dashboard
172
+ details: Details
161
173
  view: View
162
174
  edit: Edit
163
175
  `
@@ -13,6 +13,7 @@ core:
13
13
  submit: Submit
14
14
  reset: Reset
15
15
  back: Back
16
+ view: View
16
17
  next: Next
17
18
  previous: Previous
18
19
  close: Close
@@ -46,6 +47,9 @@ core:
46
47
  created: Created
47
48
  updated: Updated
48
49
  confirmDelete: Are you sure you want to delete this item?
50
+ confirmDeleteTitle: Confirm Delete
51
+ confirmDeleteItem: 'Delete {entity} "{label}"?'
52
+ confirmDeleteThis: Are you sure you want to delete this {entity}?
49
53
  errors:
50
54
  required: Required
51
55
  tooShort: Too short (min {min})
@@ -75,24 +79,24 @@ core:
75
79
  done: Complete
76
80
  stopped: Stopped
77
81
  failed: "Failed: {error}"
78
- lines: "{count} lines"
82
+ lines: "{count} line | {count} lines"
79
83
  search: Search the log
80
84
  previous: Previous match
81
85
  next: Next match
82
86
  onlyMatches: Only matching lines
83
- errors: "{count} errors"
87
+ errors: "{count} error | {count} errors"
84
88
  firstError: Go to the next error line
85
89
  wrap: Wrap long lines
86
90
  follow: Follow the end of the log
87
91
  download: Download the log
88
- newLines: "{count} new lines, resume"
92
+ newLines: "{count} new line, resume | {count} new lines, resume"
89
93
  empty: No output yet
90
94
  # EntityTimeline (#4111)
91
95
  timeline:
92
96
  actors: Filter by actor
93
97
  loading: Loading…
94
98
  empty: Nothing happened yet
95
- newEvents: "{count} new events"
99
+ newEvents: "{count} new event | {count} new events"
96
100
  oldestFirst: Oldest first
97
101
  newestFirst: Newest first
98
102
  # PayloadViewer / PayloadDiff (#4112)
@@ -103,14 +107,14 @@ core:
103
107
  copied: Copied to the clipboard
104
108
  copyFailed: Could not copy
105
109
  download: Download
106
- showAll: "Show all {count} rows"
110
+ showAll: "Show {count} row | Show all {count} rows"
107
111
  binary: "Binary content, {size}. First bytes:"
108
112
  malformed: "Not valid {format} ({error}), shown as text"
109
113
  expected: Expected
110
114
  captured: Captured
111
115
  identical: Identical
112
- unchanged: "{count} unchanged lines"
113
- showSame: "Show {count} unchanged rows"
116
+ unchanged: "{count} unchanged line | {count} unchanged lines"
117
+ showSame: "Show {count} unchanged row | Show {count} unchanged rows"
114
118
  inline: Inline
115
119
  split: Side by side
116
120
  # EmailPreview (#4113)
@@ -127,7 +131,7 @@ core:
127
131
  html: HTML
128
132
  text: Text
129
133
  source: Source
130
- imagesBlocked: "{count} remote images blocked"
134
+ imagesBlocked: "{count} remote image blocked | {count} remote images blocked"
131
135
  loadImages: Load images
132
136
  blockImages: Block images
133
137
  empty: This email has no body
@@ -151,10 +155,18 @@ core:
151
155
  start: Start
152
156
  dontStart: Do not start
153
157
  typeToConfirm: "Type {value} to confirm"
154
- tray: "{count} running tasks"
158
+ tray: "{count} running task | {count} running tasks"
155
159
  trayDone: Recent tasks
156
160
  clear: Clear finished
157
- # The breadcrumb's View↔Edit toggle (useNavContext).
161
+ # NotFoundPage
162
+ notFound:
163
+ title: Page not found
164
+ message: The page you're looking for doesn't exist or has been moved.
165
+ home: Back to Home
166
+ # The breadcrumb (useBreadcrumb, useNavContext, PageNav).
158
167
  breadcrumb:
168
+ home: Home
169
+ dashboard: Dashboard
170
+ details: Details
159
171
  view: View
160
172
  edit: Edit
@@ -15,6 +15,7 @@ export default `core:
15
15
  submit: Valider
16
16
  reset: Réinitialiser
17
17
  back: Retour
18
+ view: Voir
18
19
  next: Suivant
19
20
  previous: Précédent
20
21
  close: Fermer
@@ -48,6 +49,9 @@ export default `core:
48
49
  created: Créé
49
50
  updated: Modifié
50
51
  confirmDelete: Êtes-vous sûr de vouloir supprimer cet élément ?
52
+ confirmDeleteTitle: Confirmer la suppression
53
+ confirmDeleteItem: "Supprimer {entity} « {label} » ?"
54
+ confirmDeleteThis: "Êtes-vous sûr de vouloir supprimer cet élément ({entity}) ?"
51
55
  errors:
52
56
  required: Requis
53
57
  tooShort: Trop court (min {min})
@@ -77,24 +81,24 @@ export default `core:
77
81
  done: Terminé
78
82
  stopped: Arrêté
79
83
  failed: "Échec : {error}"
80
- lines: "{count} lignes"
84
+ lines: "{count} ligne | {count} lignes"
81
85
  search: Chercher dans le log
82
86
  previous: Occurrence précédente
83
87
  next: Occurrence suivante
84
88
  onlyMatches: Seulement les lignes trouvées
85
- errors: "{count} erreurs"
89
+ errors: "{count} erreur | {count} erreurs"
86
90
  firstError: Aller à la ligne d'erreur suivante
87
91
  wrap: Couper les lignes longues
88
92
  follow: Suivre la fin du log
89
93
  download: Télécharger le log
90
- newLines: "{count} nouvelles lignes, reprendre"
94
+ newLines: "{count} nouvelle ligne, reprendre | {count} nouvelles lignes, reprendre"
91
95
  empty: Rien pour l'instant
92
96
  # EntityTimeline (#4111)
93
97
  timeline:
94
98
  actors: Filtrer par acteur
95
99
  loading: Chargement…
96
100
  empty: Rien ne s'est encore passé
97
- newEvents: "{count} nouveaux événements"
101
+ newEvents: "{count} nouvel événement | {count} nouveaux événements"
98
102
  oldestFirst: Plus anciens d'abord
99
103
  newestFirst: Plus récents d'abord
100
104
  # PayloadViewer / PayloadDiff (#4112)
@@ -105,14 +109,14 @@ export default `core:
105
109
  copied: Copié dans le presse-papiers
106
110
  copyFailed: Copie impossible
107
111
  download: Télécharger
108
- showAll: "Afficher les {count} lignes"
112
+ showAll: "Afficher {count} ligne | Afficher les {count} lignes"
109
113
  binary: "Contenu binaire, {size}. Premiers octets :"
110
114
  malformed: "{format} invalide ({error}), affiché comme texte"
111
115
  expected: Attendu
112
116
  captured: Capturé
113
117
  identical: Identiques
114
- unchanged: "{count} lignes inchangées"
115
- showSame: "Afficher les {count} lignes inchangées"
118
+ unchanged: "{count} ligne inchangée | {count} lignes inchangées"
119
+ showSame: "Afficher {count} ligne inchangée | Afficher les {count} lignes inchangées"
116
120
  inline: En ligne
117
121
  split: Côte à côte
118
122
  # EmailPreview (#4113)
@@ -129,7 +133,7 @@ export default `core:
129
133
  html: HTML
130
134
  text: Texte
131
135
  source: Source
132
- imagesBlocked: "{count} images distantes bloquées"
136
+ imagesBlocked: "{count} image distante bloquée | {count} images distantes bloquées"
133
137
  loadImages: Charger les images
134
138
  blockImages: Bloquer les images
135
139
  empty: Ce mail n'a pas de contenu
@@ -153,11 +157,19 @@ export default `core:
153
157
  start: Lancer
154
158
  dontStart: Ne pas lancer
155
159
  typeToConfirm: "Taper {value} pour confirmer"
156
- tray: "{count} tâches en cours"
160
+ tray: "{count} tâche en cours | {count} tâches en cours"
157
161
  trayDone: Tâches récentes
158
162
  clear: Effacer les terminées
159
- # The breadcrumb's View↔Edit toggle (useNavContext).
163
+ # NotFoundPage
164
+ notFound:
165
+ title: Page introuvable
166
+ message: La page demandée n'existe pas ou a été déplacée.
167
+ home: Retour à l'accueil
168
+ # The breadcrumb (useBreadcrumb, useNavContext, PageNav).
160
169
  breadcrumb:
170
+ home: Accueil
171
+ dashboard: Tableau de bord
172
+ details: Détails
161
173
  view: Voir
162
174
  edit: Modifier
163
175
  `
@@ -13,6 +13,7 @@ core:
13
13
  submit: Valider
14
14
  reset: Réinitialiser
15
15
  back: Retour
16
+ view: Voir
16
17
  next: Suivant
17
18
  previous: Précédent
18
19
  close: Fermer
@@ -46,6 +47,9 @@ core:
46
47
  created: Créé
47
48
  updated: Modifié
48
49
  confirmDelete: Êtes-vous sûr de vouloir supprimer cet élément ?
50
+ confirmDeleteTitle: Confirmer la suppression
51
+ confirmDeleteItem: "Supprimer {entity} « {label} » ?"
52
+ confirmDeleteThis: "Êtes-vous sûr de vouloir supprimer cet élément ({entity}) ?"
49
53
  errors:
50
54
  required: Requis
51
55
  tooShort: Trop court (min {min})
@@ -75,24 +79,24 @@ core:
75
79
  done: Terminé
76
80
  stopped: Arrêté
77
81
  failed: "Échec : {error}"
78
- lines: "{count} lignes"
82
+ lines: "{count} ligne | {count} lignes"
79
83
  search: Chercher dans le log
80
84
  previous: Occurrence précédente
81
85
  next: Occurrence suivante
82
86
  onlyMatches: Seulement les lignes trouvées
83
- errors: "{count} erreurs"
87
+ errors: "{count} erreur | {count} erreurs"
84
88
  firstError: Aller à la ligne d'erreur suivante
85
89
  wrap: Couper les lignes longues
86
90
  follow: Suivre la fin du log
87
91
  download: Télécharger le log
88
- newLines: "{count} nouvelles lignes, reprendre"
92
+ newLines: "{count} nouvelle ligne, reprendre | {count} nouvelles lignes, reprendre"
89
93
  empty: Rien pour l'instant
90
94
  # EntityTimeline (#4111)
91
95
  timeline:
92
96
  actors: Filtrer par acteur
93
97
  loading: Chargement…
94
98
  empty: Rien ne s'est encore passé
95
- newEvents: "{count} nouveaux événements"
99
+ newEvents: "{count} nouvel événement | {count} nouveaux événements"
96
100
  oldestFirst: Plus anciens d'abord
97
101
  newestFirst: Plus récents d'abord
98
102
  # PayloadViewer / PayloadDiff (#4112)
@@ -103,14 +107,14 @@ core:
103
107
  copied: Copié dans le presse-papiers
104
108
  copyFailed: Copie impossible
105
109
  download: Télécharger
106
- showAll: "Afficher les {count} lignes"
110
+ showAll: "Afficher {count} ligne | Afficher les {count} lignes"
107
111
  binary: "Contenu binaire, {size}. Premiers octets :"
108
112
  malformed: "{format} invalide ({error}), affiché comme texte"
109
113
  expected: Attendu
110
114
  captured: Capturé
111
115
  identical: Identiques
112
- unchanged: "{count} lignes inchangées"
113
- showSame: "Afficher les {count} lignes inchangées"
116
+ unchanged: "{count} ligne inchangée | {count} lignes inchangées"
117
+ showSame: "Afficher {count} ligne inchangée | Afficher les {count} lignes inchangées"
114
118
  inline: En ligne
115
119
  split: Côte à côte
116
120
  # EmailPreview (#4113)
@@ -127,7 +131,7 @@ core:
127
131
  html: HTML
128
132
  text: Texte
129
133
  source: Source
130
- imagesBlocked: "{count} images distantes bloquées"
134
+ imagesBlocked: "{count} image distante bloquée | {count} images distantes bloquées"
131
135
  loadImages: Charger les images
132
136
  blockImages: Bloquer les images
133
137
  empty: Ce mail n'a pas de contenu
@@ -151,10 +155,18 @@ core:
151
155
  start: Lancer
152
156
  dontStart: Ne pas lancer
153
157
  typeToConfirm: "Taper {value} pour confirmer"
154
- tray: "{count} tâches en cours"
158
+ tray: "{count} tâche en cours | {count} tâches en cours"
155
159
  trayDone: Tâches récentes
156
160
  clear: Effacer les terminées
157
- # The breadcrumb's View↔Edit toggle (useNavContext).
161
+ # NotFoundPage
162
+ notFound:
163
+ title: Page introuvable
164
+ message: La page demandée n'existe pas ou a été déplacée.
165
+ home: Retour à l'accueil
166
+ # The breadcrumb (useBreadcrumb, useNavContext, PageNav).
158
167
  breadcrumb:
168
+ home: Accueil
169
+ dashboard: Tableau de bord
170
+ details: Détails
159
171
  view: Voir
160
172
  edit: Modifier
@@ -7,12 +7,19 @@
7
7
 
8
8
  import { computed, inject, type Ref, type ComputedRef } from 'vue'
9
9
  import type { I18n } from './I18n'
10
+ import { interpolate } from '@quazardous/qdcore'
10
11
  import type { TranslateParams } from './types'
11
12
 
12
13
  export const I18N_INJECTION_KEY = Symbol('qdadm.i18n')
13
14
 
14
15
  export interface UseI18nResult {
15
16
  t: (key: string, params?: TranslateParams) => string
17
+ /**
18
+ * The catalog's text for `key`, or `fallback` (interpolated) when the key
19
+ * is missing or there is no I18n: for labels that read as English text,
20
+ * not as a key, outside a kernel.
21
+ */
22
+ tOr: (key: string, fallback: string, params?: TranslateParams) => string
16
23
  locale: ComputedRef<string> | Ref<string>
17
24
  i18n: I18n | null
18
25
  }
@@ -22,12 +29,17 @@ export function useI18n(): UseI18nResult {
22
29
  if (!i18n) {
23
30
  return {
24
31
  t: (key: string) => key,
32
+ tOr: (_key, fallback, params) => interpolate(fallback, params),
25
33
  locale: computed(() => 'en'),
26
34
  i18n: null,
27
35
  }
28
36
  }
29
37
  return {
30
38
  t: (key, params) => i18n.t(key, params),
39
+ tOr: (key, fallback, params) => {
40
+ const trace = i18n.resolve(key, params)
41
+ return trace.hit ? trace.result : interpolate(fallback, params, i18n.locale.value)
42
+ },
31
43
  locale: i18n.locale,
32
44
  i18n,
33
45
  }
@@ -53,6 +53,8 @@ export interface TaskKind {
53
53
  to?: (taskId: string | number) => unknown
54
54
  /** Toast when it ends. Default true. */
55
55
  notify?: boolean
56
+ /** Called once the run ends, whatever the outcome (read `run.status`). */
57
+ onSettled?: (run: TaskRun) => void
56
58
  }
57
59
 
58
60
  export interface TaskConfirm {
@@ -61,6 +63,8 @@ export interface TaskConfirm {
61
63
  typed?: string
62
64
  /** Label of the confirm button. */
63
65
  accept?: string
66
+ /** Severity of the confirm button. Default `danger` when `typed` is set, `primary` otherwise. */
67
+ severity?: 'primary' | 'secondary' | 'success' | 'info' | 'warn' | 'danger' | 'contrast'
64
68
  }
65
69
 
66
70
  export interface RunOptions extends Partial<TaskKind> {
@@ -87,6 +91,8 @@ export interface TaskRun {
87
91
  startedAt: number
88
92
  endedAt: number | null
89
93
  cancelling: boolean
94
+ /** Settles with the run once it ends: succeeded, failed or cancelled (it never rejects). */
95
+ finished: Promise<TaskRun>
90
96
  }
91
97
 
92
98
  interface TaskHostDeps {
@@ -150,6 +156,7 @@ function createTaskStore() {
150
156
  const defs = new Map<string, TaskKind>()
151
157
  const stops = new Map<string, () => void>()
152
158
  const pokes = new Map<string, () => void>()
159
+ const settles = new Map<string, (run: TaskRun) => void>()
153
160
  let deps: TaskHostDeps = {}
154
161
  let restored = false
155
162
 
@@ -188,8 +195,9 @@ function createTaskStore() {
188
195
  // --- Runs ---
189
196
 
190
197
  function addRun(partial: Partial<TaskRun> & Pick<TaskRun, 'label'>): TaskRun {
198
+ const id = partial.id ?? `task-${Date.now().toString(36)}-${++seq}`
191
199
  const run: TaskRun = {
192
- id: partial.id ?? `task-${Date.now().toString(36)}-${++seq}`,
200
+ id,
193
201
  kind: partial.kind ?? null,
194
202
  label: partial.label,
195
203
  taskId: partial.taskId ?? null,
@@ -201,6 +209,8 @@ function createTaskStore() {
201
209
  startedAt: partial.startedAt ?? Date.now(),
202
210
  endedAt: null,
203
211
  cancelling: false,
212
+ // A promise is not made reactive: run.finished stays the raw promise.
213
+ finished: new Promise<TaskRun>((resolve) => settles.set(id, resolve)),
204
214
  }
205
215
  state.runs.unshift(run)
206
216
  // Keep every active run, and the most recent finished ones.
@@ -223,6 +233,13 @@ function createTaskStore() {
223
233
  pokes.delete(id)
224
234
  persist()
225
235
  notifyEnd(run)
236
+ settles.get(id)?.(run)
237
+ settles.delete(id)
238
+ try {
239
+ defs.get(id)?.onSettled?.(run)
240
+ } catch (err) {
241
+ console.error(`[qdadm] Task "${run.label}": onSettled threw`, err)
242
+ }
226
243
  }
227
244
 
228
245
  function notifyEnd(run: TaskRun): void {
@@ -397,6 +414,7 @@ function createTaskStore() {
397
414
  stops.delete(id)
398
415
  pokes.delete(id)
399
416
  defs.delete(id)
417
+ settles.delete(id)
400
418
  const i = state.runs.findIndex((r) => r.id === id)
401
419
  if (i !== -1) state.runs.splice(i, 1)
402
420
  if (state.openId === id) state.openId = null
@@ -424,6 +442,8 @@ function createTaskStore() {
424
442
  dismiss,
425
443
  clearFinished,
426
444
  open: (id: string | null) => (state.openId = id),
445
+ /** Read the run's task record now, instead of at the next poll (a log that just ended, a page that knows better). */
446
+ poke: (id: string) => pokes.get(id)?.(),
427
447
  registerTaskKind,
428
448
  answerConfirm,
429
449
  attach,
@@ -434,6 +454,7 @@ function createTaskStore() {
434
454
  for (const stop of stops.values()) stop()
435
455
  stops.clear()
436
456
  pokes.clear()
457
+ settles.clear()
437
458
  defs.clear()
438
459
  kinds.clear()
439
460
  state.runs.splice(0)