@quazardous/qdadm 2.33.0 → 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.
@@ -34,7 +34,7 @@ export class NotificationModule extends Module {
34
34
  static override requires: string[] = []
35
35
  static override priority = 5 // Before toast-bridge (10) to intercept first
36
36
 
37
- static override styles = () => import('./styles.scss')
37
+ static override styles = () => import('./styles.css')
38
38
 
39
39
  async connect(ctx: KernelContext): Promise<void> {
40
40
  // Define notification zones
@@ -5,9 +5,9 @@
5
5
  * Panel and badge styles are scoped in their respective Vue components.
6
6
  */
7
7
 
8
- /* Timing values match _sidebar.scss sidebar-box-content-* variables */
9
- $_content-delay: 0.2s;
10
- $_content-duration: 0.1s;
8
+ /* Timing (0.1s after a 0.2s delay) matches the sidebar-box-content-* variables
9
+ of _sidebar.scss. Plain CSS (#4140): an app must not need sass for a module
10
+ the kernel injects by itself. */
11
11
 
12
12
  /* =============================================================================
13
13
  Notification Status Zone (always visible below footer in sidebar)
@@ -15,14 +15,14 @@ $_content-duration: 0.1s;
15
15
 
16
16
  .sidebar-notification-status {
17
17
  opacity: 1;
18
- transition: opacity $_content-duration ease $_content-delay;
18
+ transition: opacity 0.1s ease 0.2s;
19
19
  }
20
20
 
21
21
  /* Status label: delayed fade-in on expand, instant hide on collapse.
22
22
  Matches SidebarBox content behavior (.sidebar-box-content). */
23
23
  .sidebar-notification-status .status-label {
24
24
  opacity: 1;
25
- transition: opacity $_content-duration ease $_content-delay;
25
+ transition: opacity 0.1s ease 0.2s;
26
26
  }
27
27
 
28
28
  .sidebar--collapsed .sidebar-notification-status .status-label {
@@ -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)