@conduction/nextcloud-vue 2.62.0 → 2.63.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.
Files changed (154) hide show
  1. package/dist/esm/components/CnAdminActionCard/CnAdminActionCard.vue.js +10 -0
  2. package/dist/esm/components/CnAdminActionCard/CnAdminActionCard.vue.js.map +1 -0
  3. package/dist/esm/components/CnAdminActionCard/CnAdminActionCard.vue2.js +189 -0
  4. package/dist/esm/components/CnAdminActionCard/CnAdminActionCard.vue2.js.map +1 -0
  5. package/dist/esm/components/CnAdminActionCard/CnAdminActionCard.vue3.js +72 -0
  6. package/dist/esm/components/CnAdminActionCard/CnAdminActionCard.vue3.js.map +1 -0
  7. package/dist/esm/components/CnAppNav/CnAppNav.vue2.js +271 -32
  8. package/dist/esm/components/CnAppNav/CnAppNav.vue2.js.map +1 -1
  9. package/dist/esm/components/CnAppNav/CnAppNav.vue3.js.map +1 -1
  10. package/dist/esm/components/CnAppRoot/CnAppRoot.vue2.js +99 -9
  11. package/dist/esm/components/CnAppRoot/CnAppRoot.vue2.js.map +1 -1
  12. package/dist/esm/components/CnAppRoot/CnAppRoot.vue3.js +39 -18
  13. package/dist/esm/components/CnAppRoot/CnAppRoot.vue3.js.map +1 -1
  14. package/dist/esm/components/CnChoiceCards/CnChoiceCards.vue2.js.map +1 -1
  15. package/dist/esm/components/CnChoiceCards/CnChoiceCards.vue3.js +53 -37
  16. package/dist/esm/components/CnChoiceCards/CnChoiceCards.vue3.js.map +1 -1
  17. package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue2.js.map +1 -1
  18. package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue3.js +2 -2
  19. package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue3.js.map +1 -1
  20. package/dist/esm/components/CnDataTable/CnColumnFilterPopover.vue.js +10 -0
  21. package/dist/esm/components/CnDataTable/CnColumnFilterPopover.vue.js.map +1 -0
  22. package/dist/esm/components/CnDataTable/CnColumnFilterPopover.vue2.js +293 -0
  23. package/dist/esm/components/CnDataTable/CnColumnFilterPopover.vue2.js.map +1 -0
  24. package/dist/esm/components/CnDataTable/CnColumnFilterPopover.vue3.js +189 -0
  25. package/dist/esm/components/CnDataTable/CnColumnFilterPopover.vue3.js.map +1 -0
  26. package/dist/esm/components/CnDataTable/CnDataTable.vue2.js +216 -8
  27. package/dist/esm/components/CnDataTable/CnDataTable.vue2.js.map +1 -1
  28. package/dist/esm/components/CnDataTable/CnDataTable.vue3.js +118 -50
  29. package/dist/esm/components/CnDataTable/CnDataTable.vue3.js.map +1 -1
  30. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue2.js.map +1 -1
  31. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue3.js +2 -1
  32. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue3.js.map +1 -1
  33. package/dist/esm/components/CnFieldHelper/CnFieldHelper.vue2.js +3 -1
  34. package/dist/esm/components/CnFieldHelper/CnFieldHelper.vue2.js.map +1 -1
  35. package/dist/esm/components/CnFieldHelper/CnFieldHelper.vue3.js +1 -1
  36. package/dist/esm/components/CnFieldHelper/CnFieldHelper.vue3.js.map +1 -1
  37. package/dist/esm/components/CnFormDialog/CnFormDialog.vue2.js +234 -9
  38. package/dist/esm/components/CnFormDialog/CnFormDialog.vue2.js.map +1 -1
  39. package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js +96 -57
  40. package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js.map +1 -1
  41. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js +51 -2
  42. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js.map +1 -1
  43. package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js +5 -1
  44. package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js.map +1 -1
  45. package/dist/esm/components/CnIndexPage/selfModeActions.js +3 -3
  46. package/dist/esm/components/CnIndexPage/selfModeActions.js.map +1 -1
  47. package/dist/esm/components/CnObjectListWidget/CnObjectListWidget.vue2.js +36 -1
  48. package/dist/esm/components/CnObjectListWidget/CnObjectListWidget.vue2.js.map +1 -1
  49. package/dist/esm/components/CnObjectListWidget/CnObjectListWidget.vue3.js +4 -1
  50. package/dist/esm/components/CnObjectListWidget/CnObjectListWidget.vue3.js.map +1 -1
  51. package/dist/esm/components/CnResourceSelect/CnResourceSelect.vue2.js +121 -12
  52. package/dist/esm/components/CnResourceSelect/CnResourceSelect.vue2.js.map +1 -1
  53. package/dist/esm/components/CnResourceSelect/CnResourceSelect.vue3.js +3 -1
  54. package/dist/esm/components/CnResourceSelect/CnResourceSelect.vue3.js.map +1 -1
  55. package/dist/esm/components/CnSetupWizard/CnSetupWizard.vue2.js +326 -1
  56. package/dist/esm/components/CnSetupWizard/CnSetupWizard.vue2.js.map +1 -1
  57. package/dist/esm/components/CnSetupWizard/CnSetupWizard.vue3.js +112 -26
  58. package/dist/esm/components/CnSetupWizard/CnSetupWizard.vue3.js.map +1 -1
  59. package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue.js +10 -0
  60. package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue.js.map +1 -0
  61. package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue2.js +337 -0
  62. package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue2.js.map +1 -0
  63. package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue3.js +102 -0
  64. package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue3.js.map +1 -0
  65. package/dist/esm/components/CnTimelineWidget/dashboardRegistration.js +34 -0
  66. package/dist/esm/components/CnTimelineWidget/dashboardRegistration.js.map +1 -0
  67. package/dist/esm/components/CnWalkthrough/CnWalkthrough.vue2.js +131 -8
  68. package/dist/esm/components/CnWalkthrough/CnWalkthrough.vue2.js.map +1 -1
  69. package/dist/esm/components/CnWalkthrough/CnWalkthrough.vue3.js +40 -38
  70. package/dist/esm/components/CnWalkthrough/CnWalkthrough.vue3.js.map +1 -1
  71. package/dist/esm/components/CnWidgetGrid/builtInWidgets.js +8 -6
  72. package/dist/esm/components/CnWidgetGrid/builtInWidgets.js.map +1 -1
  73. package/dist/esm/components/CnWidgetGrid/registerDashboardWidgets.js +1 -0
  74. package/dist/esm/components/CnWidgetGrid/registerDashboardWidgets.js.map +1 -1
  75. package/dist/esm/components/CnWizardDialog/CnWizardDialog.vue2.js +19 -0
  76. package/dist/esm/components/CnWizardDialog/CnWizardDialog.vue2.js.map +1 -1
  77. package/dist/esm/components/CnWizardDialog/CnWizardDialog.vue3.js +1 -1
  78. package/dist/esm/components/CnWizardDialog/CnWizardDialog.vue3.js.map +1 -1
  79. package/dist/esm/composables/useDependencyCheck.js +65 -0
  80. package/dist/esm/composables/useDependencyCheck.js.map +1 -0
  81. package/dist/esm/composables/useWalkthrough.js +218 -6
  82. package/dist/esm/composables/useWalkthrough.js.map +1 -1
  83. package/dist/esm/index.js +2 -0
  84. package/dist/esm/index.js.map +1 -1
  85. package/dist/esm/l10n/en.json.js +43 -0
  86. package/dist/esm/l10n/en.json.js.map +1 -1
  87. package/dist/esm/l10n/nl.json.js +43 -0
  88. package/dist/esm/l10n/nl.json.js.map +1 -1
  89. package/dist/esm/nextcloud-vue.css +449 -0
  90. package/dist/esm/store/useObjectStore.js +8 -0
  91. package/dist/esm/store/useObjectStore.js.map +1 -1
  92. package/dist/esm/utils/columnFilters.js +311 -0
  93. package/dist/esm/utils/columnFilters.js.map +1 -0
  94. package/dist/esm/utils/groupAutocomplete.js +123 -0
  95. package/dist/esm/utils/groupAutocomplete.js.map +1 -0
  96. package/dist/esm/utils/libraryWidgetKeys.js +2 -0
  97. package/dist/esm/utils/libraryWidgetKeys.js.map +1 -1
  98. package/dist/esm/utils/pickerOptions.js +198 -0
  99. package/dist/esm/utils/pickerOptions.js.map +1 -0
  100. package/dist/esm/utils/schema.js +83 -7
  101. package/dist/esm/utils/schema.js.map +1 -1
  102. package/dist/esm/utils/timelineEvents.js +174 -0
  103. package/dist/esm/utils/timelineEvents.js.map +1 -0
  104. package/dist/esm/utils/validateManifestV2.compiled.js +2 -2
  105. package/dist/esm/utils/validateManifestV2.compiled.js.map +1 -1
  106. package/dist/esm/utils/walkthroughSignals.js +88 -0
  107. package/dist/esm/utils/walkthroughSignals.js.map +1 -0
  108. package/dist/nextcloud-vue.cjs.js +9369 -5193
  109. package/dist/nextcloud-vue.cjs.js.map +2 -2
  110. package/dist/nextcloud-vue.css +449 -0
  111. package/l10n/en.json +43 -0
  112. package/l10n/nl.json +43 -0
  113. package/package.json +1 -1
  114. package/src/components/CnAdminActionCard/CnAdminActionCard.vue +234 -0
  115. package/src/components/CnAdminActionCard/index.js +4 -0
  116. package/src/components/CnAppNav/CnAppNav.vue +271 -32
  117. package/src/components/CnAppRoot/CnAppRoot.vue +129 -15
  118. package/src/components/CnChoiceCards/CnChoiceCards.vue +56 -31
  119. package/src/components/CnDashboardPage/CnDashboardPage.vue +2 -2
  120. package/src/components/CnDataTable/CnColumnFilterPopover.vue +524 -0
  121. package/src/components/CnDataTable/CnDataTable.md +3 -0
  122. package/src/components/CnDataTable/CnDataTable.vue +260 -4
  123. package/src/components/CnDetailWidgetHost/CnDetailWidgetHost.vue +2 -2
  124. package/src/components/CnFieldHelper/CnFieldHelper.vue +4 -2
  125. package/src/components/CnFormDialog/CnFormDialog.vue +290 -31
  126. package/src/components/CnIndexPage/CnIndexPage.vue +55 -2
  127. package/src/components/CnIndexPage/selfModeActions.js +3 -3
  128. package/src/components/CnObjectListWidget/CnObjectListWidget.vue +39 -1
  129. package/src/components/CnResourceSelect/CnResourceSelect.vue +123 -12
  130. package/src/components/CnSetupWizard/CnSetupWizard.vue +392 -3
  131. package/src/components/CnTimelineWidget/CnTimelineWidget.vue +477 -0
  132. package/src/components/CnTimelineWidget/dashboardRegistration.js +32 -0
  133. package/src/components/CnTimelineWidget/index.js +4 -0
  134. package/src/components/CnWalkthrough/CnWalkthrough.vue +143 -10
  135. package/src/components/CnWidgetGrid/builtInWidgets.js +2 -0
  136. package/src/components/CnWidgetGrid/registerDashboardWidgets.js +1 -0
  137. package/src/components/CnWizardDialog/CnWizardDialog.vue +20 -1
  138. package/src/components/index.js +2 -0
  139. package/src/composables/useDependencyCheck.js +61 -0
  140. package/src/composables/useWalkthrough.js +217 -5
  141. package/src/css/dashboard.css +49 -0
  142. package/src/css/detail-page.css +19 -0
  143. package/src/css/table.css +81 -0
  144. package/src/index.js +2 -0
  145. package/src/schemas/app-manifest-v2.schema.json +23 -1
  146. package/src/store/useObjectStore.js +8 -0
  147. package/src/utils/columnFilters.js +324 -0
  148. package/src/utils/groupAutocomplete.js +119 -0
  149. package/src/utils/libraryWidgetKeys.js +2 -0
  150. package/src/utils/pickerOptions.js +194 -0
  151. package/src/utils/schema.js +83 -7
  152. package/src/utils/timelineEvents.js +171 -0
  153. package/src/utils/validateManifestV2.compiled.js +2 -2
  154. package/src/utils/walkthroughSignals.js +94 -0
@@ -1,10 +1,20 @@
1
+ import { getCurrentUser } from '@nextcloud/auth';
2
+ import { loadState } from '@nextcloud/initial-state';
1
3
  import { translate } from '@nextcloud/l10n';
2
4
  import { NcButton, NcNoteCard, NcSelect, NcTextField, NcCheckboxRadioSwitch, NcLoadingIcon } from '@nextcloud/vue';
3
5
  import __sfc_main$1 from '../CnChoiceCards/CnChoiceCards.vue.js';
6
+ import __sfc_main$2 from '../CnLeafDependencySettings/CnLeafDependencySettings.vue.js';
4
7
  import __sfc_main from '../CnWizardDialog/CnWizardDialog.vue.js';
8
+ import { checkDependencies, isDependencyResolved } from '../../composables/useDependencyCheck.js';
5
9
  import { useSetupStatus } from '../../composables/useSetupStatus.js';
6
10
  import { fieldsFromSchema } from '../../utils/schema.js';
7
11
 
12
+ /** Id of the synthetic step shown while a required app is missing. */
13
+ const DEPENDENCY_STEP_ID = 'cn-setup-dependencies';
14
+
15
+ /** The dataset value that means "seed nothing"; it never gets a Load button. */
16
+ const NONE_DATASET = 'none';
17
+
8
18
  /**
9
19
  * CnSetupWizard — abstract, manifest-driven first-time setup wizard (ADR-042).
10
20
  *
@@ -34,6 +44,7 @@ var script = {
34
44
  components: {
35
45
  CnWizardDialog: __sfc_main,
36
46
  CnChoiceCards: __sfc_main$1,
47
+ CnLeafDependencySettings: __sfc_main$2,
37
48
  NcButton,
38
49
  NcNoteCard,
39
50
  NcSelect,
@@ -52,6 +63,11 @@ var script = {
52
63
  * standalone (no CnAppRoot ancestor).
53
64
  */
54
65
  cnTranslate: { default: () => (key) => key },
66
+ /**
67
+ * The app manifest, provided by CnAppRoot. Read only for its
68
+ * `dependencies` when the `dependencies` prop is empty.
69
+ */
70
+ cnManifest: { default: null },
55
71
  },
56
72
 
57
73
  props: {
@@ -161,6 +177,33 @@ var script = {
161
177
  type: Array,
162
178
  default: () => [],
163
179
  },
180
+
181
+ /**
182
+ * The app's dependencies, in the manifest's own shape (app-id strings
183
+ * or `{ id, name?, required? }`). Falls back to the injected manifest's
184
+ * `dependencies`. A missing REQUIRED one replaces every step with the
185
+ * dependency list and disables Next; a missing optional one is listed
186
+ * on the first step and does not block.
187
+ *
188
+ * @type {Array<string|object>}
189
+ * @spec openspec/changes/setup-wizard-card-load-and-dependency-gate/specs/cn-setup-wizard/spec.md#requirement-the-wizard-checks-dependencies-before-any-step
190
+ */
191
+ dependencies: {
192
+ type: Array,
193
+ default: () => [],
194
+ },
195
+
196
+ /** Load button label on a dataset card (`loadAction`). */
197
+ loadLabel: {
198
+ type: String,
199
+ default: () => translate('nextcloud-vue', 'Load'),
200
+ },
201
+
202
+ /** Load button label once that dataset loaded in this session. */
203
+ reloadLabel: {
204
+ type: String,
205
+ default: () => translate('nextcloud-vue', 'Load again'),
206
+ },
164
207
  },
165
208
 
166
209
  emits: ['complete', 'close', 'step-change', 'action-result'],
@@ -196,6 +239,9 @@ var script = {
196
239
  actionResult: {},
197
240
  localDone: {},
198
241
  userTouched: {},
242
+ // Per-card load state for `loadAction` steps, keyed by `loadKey()`.
243
+ datasetRunning: {},
244
+ datasetResult: {},
199
245
  }
200
246
  },
201
247
 
@@ -213,11 +259,150 @@ var script = {
213
259
  : this.dialogTitle
214
260
  },
215
261
 
216
- setupSteps() {
262
+ /**
263
+ * Every well-formed step, before `requires` is applied.
264
+ *
265
+ * @return {Array<object>}
266
+ */
267
+ declaredSteps() {
217
268
  return (this.steps || []).filter((s) => s && s.id && s.type)
218
269
  },
219
270
 
271
+ /**
272
+ * Steps that declare `requires` on an app that is not installed and
273
+ * enabled. They are not offered; the summary names them as skipped.
274
+ *
275
+ * @return {Array<{ step: object, missing: Array<string> }>}
276
+ * @spec openspec/changes/setup-wizard-card-load-and-dependency-gate/specs/cn-setup-wizard/spec.md#requirement-the-wizard-checks-dependencies-before-any-step
277
+ */
278
+ skippedSteps() {
279
+ return this.declaredSteps
280
+ .filter((s) => Array.isArray(s.requires) && s.requires.length > 0)
281
+ .map((step) => {
282
+ const known = Object.fromEntries(this.dependencyRows.map((d) => [d.id, d]));
283
+ const missing = checkDependencies(step.requires, this.serverAppStatuses)
284
+ .map((row) => known[row.id] || row)
285
+ .filter((row) => !isDependencyResolved(row))
286
+ .map((row) => row.name || row.id);
287
+ return { step, missing }
288
+ })
289
+ .filter((entry) => entry.missing.length > 0)
290
+ },
291
+
292
+ setupSteps() {
293
+ const skipped = new Set(this.skippedSteps.map((entry) => entry.step.id));
294
+ return this.declaredSteps.filter((s) => !skipped.has(s.id))
295
+ },
296
+
297
+ /**
298
+ * Id of the first offered step: where the optional-apps note shows.
299
+ *
300
+ * @return {string}
301
+ */
302
+ firstStepId() {
303
+ return this.setupSteps.length > 0 ? this.setupSteps[0].id : ''
304
+ },
305
+
306
+ /**
307
+ * The dependency declarations to check: the prop, else the manifest's.
308
+ *
309
+ * @return {Array<string|object>}
310
+ */
311
+ dependencyEntries() {
312
+ if (Array.isArray(this.dependencies) && this.dependencies.length > 0) {
313
+ return this.dependencies
314
+ }
315
+ const fromManifest = this.cnManifest && this.cnManifest.dependencies;
316
+ return Array.isArray(fromManifest) ? fromManifest : []
317
+ },
318
+
319
+ /**
320
+ * The `dependency_statuses` initial state an app may inject from PHP.
321
+ * Same source CnAppRoot reads; `{}` when the app injects none.
322
+ *
323
+ * @return {object}
324
+ */
325
+ serverAppStatuses() {
326
+ try {
327
+ return loadState(this.appId, 'dependency_statuses', {}) || {}
328
+ } catch {
329
+ return {}
330
+ }
331
+ },
332
+
333
+ /**
334
+ * The declared dependencies with their live status.
335
+ *
336
+ * @return {Array<object>}
337
+ */
338
+ dependencyRows() {
339
+ return checkDependencies(this.dependencyEntries, this.serverAppStatuses)
340
+ },
341
+
342
+ /** @return {Array<object>} Required dependencies that are missing or disabled. */
343
+ missingRequired() {
344
+ return this.dependencyRows.filter((d) => d.required && !isDependencyResolved(d))
345
+ },
346
+
347
+ /** @return {Array<object>} Optional dependencies that are missing or disabled. */
348
+ missingOptional() {
349
+ return this.dependencyRows.filter((d) => !d.required && !isDependencyResolved(d))
350
+ },
351
+
352
+ /**
353
+ * Whether a required app is missing, so the wizard shows the
354
+ * dependency list instead of its steps and refuses to continue.
355
+ *
356
+ * @return {boolean}
357
+ * @spec openspec/changes/setup-wizard-card-load-and-dependency-gate/specs/cn-setup-wizard/spec.md#requirement-the-wizard-checks-dependencies-before-any-step
358
+ */
359
+ dependencyBlocked() {
360
+ return this.missingRequired.length > 0
361
+ },
362
+
363
+ dependencyStepSlot() {
364
+ return 'step-' + DEPENDENCY_STEP_ID
365
+ },
366
+
367
+ dependencySectionName() {
368
+ return translate('nextcloud-vue', 'Apps this app needs')
369
+ },
370
+
371
+ dependencyBlockedText() {
372
+ return translate('nextcloud-vue', 'Setup can start once these apps are installed and enabled: {apps}.', {
373
+ apps: this.missingRequired.map((d) => d.name).join(', '),
374
+ })
375
+ },
376
+
377
+ optionalMissingText() {
378
+ return translate('nextcloud-vue', 'Optional, not installed: {apps}. You can add them later.', {
379
+ apps: this.missingOptional.map((d) => d.name).join(', '),
380
+ })
381
+ },
382
+
383
+ /**
384
+ * Whether the current user is a Nextcloud admin; only admins get the
385
+ * install and enable buttons.
386
+ *
387
+ * @return {boolean}
388
+ */
389
+ isAdmin() {
390
+ try {
391
+ const user = getCurrentUser();
392
+ return !!(user && user.isAdmin)
393
+ } catch {
394
+ return false
395
+ }
396
+ },
397
+
220
398
  wizardSteps() {
399
+ if (this.dependencyBlocked) {
400
+ return [{
401
+ id: DEPENDENCY_STEP_ID,
402
+ label: translate('nextcloud-vue', 'Required apps'),
403
+ optional: false,
404
+ }]
405
+ }
221
406
  return this.setupSteps.map((s) => ({
222
407
  id: s.id,
223
408
  label: this.stepTitle(s),
@@ -241,6 +426,15 @@ var script = {
241
426
  * @return {Array<{ id: string, title: string, value: string, done: boolean, notRun: boolean }>}
242
427
  */
243
428
  summaryItems() {
429
+ const skipped = this.skippedSteps
430
+ .filter((entry) => entry.step.type !== 'summary' && entry.step.type !== 'info')
431
+ .map((entry) => ({
432
+ id: entry.step.id,
433
+ title: this.stepTitle(entry.step),
434
+ value: translate('nextcloud-vue', 'Skipped, needs {apps}', { apps: entry.missing.join(', ') }),
435
+ done: false,
436
+ notRun: true,
437
+ }));
244
438
  return this.setupSteps
245
439
  .filter((s) => s.type !== 'summary')
246
440
  .map((step) => {
@@ -277,6 +471,7 @@ var script = {
277
471
  }
278
472
  return { id: step.id, title: this.stepTitle(step), value, done, notRun: false }
279
473
  })
474
+ .concat(skipped)
280
475
  },
281
476
 
282
477
  /**
@@ -337,6 +532,11 @@ var script = {
337
532
  * @return {void}
338
533
  */
339
534
  maybeAutoRunStep(stepId) {
535
+ // Nothing runs while a required app is missing: every action
536
+ // would fail with an error that does not name the app.
537
+ if (this.dependencyBlocked) {
538
+ return
539
+ }
340
540
  const step = this.setupSteps.find((s) => s.id === stepId);
341
541
  if (step && step.type === 'run-action' && !this.isOnDemand(step) && !this.isStepDone(step.id) && !this.running[step.id]) {
342
542
  this.runAction(step);
@@ -719,6 +919,131 @@ var script = {
719
919
  }
720
920
  },
721
921
 
922
+ /**
923
+ * Key for one card's load state.
924
+ *
925
+ * @param {object} step The choice step.
926
+ * @param {object} option The card's option.
927
+ * @return {string}
928
+ */
929
+ loadKey(step, option) {
930
+ return step.id + '::' + String(option && option.value)
931
+ },
932
+
933
+ /**
934
+ * Whether a card gets a Load button: the step declares `loadAction`
935
+ * and the option is not the "seed nothing" answer.
936
+ *
937
+ * @param {object} step The choice step.
938
+ * @param {object} option The card's option.
939
+ * @return {boolean}
940
+ * @spec openspec/changes/setup-wizard-card-load-and-dependency-gate/specs/cn-setup-wizard/spec.md#requirement-a-dataset-card-loads-itself
941
+ */
942
+ isLoadableOption(step, option) {
943
+ return !!(step && step.loadAction) && !!option && String(option.value) !== NONE_DATASET
944
+ },
945
+
946
+ isDatasetLoading(step, option) {
947
+ return this.datasetRunning[this.loadKey(step, option)] === true
948
+ },
949
+
950
+ datasetResultFor(step, option) {
951
+ return this.datasetResult[this.loadKey(step, option)] || null
952
+ },
953
+
954
+ loadButtonLabel(step, option) {
955
+ if (this.isDatasetLoading(step, option)) {
956
+ return this.runningLabel
957
+ }
958
+ const result = this.datasetResultFor(step, option);
959
+ return (result && result.success) ? this.reloadLabel : this.loadLabel
960
+ },
961
+
962
+ loadAriaLabel(option) {
963
+ return translate('nextcloud-vue', 'Load {name}', { name: option.label })
964
+ },
965
+
966
+ /**
967
+ * Load one dataset from its card: POST `{ dataset }` to the step's
968
+ * `loadAction`, spinner on the button while it runs, the result on the
969
+ * card after. A successful load also selects the card, so the summary
970
+ * and the stored choice name what was loaded.
971
+ *
972
+ * @param {object} step The choice step declaring `loadAction`.
973
+ * @param {object} option The card's option.
974
+ * @return {Promise<void>}
975
+ * @spec openspec/changes/setup-wizard-card-load-and-dependency-gate/specs/cn-setup-wizard/spec.md#requirement-a-dataset-card-loads-itself
976
+ */
977
+ async loadDataset(step, option) {
978
+ if (!this.isLoadableOption(step, option) || this.isDatasetLoading(step, option)) {
979
+ return
980
+ }
981
+ const key = this.loadKey(step, option);
982
+ this.datasetRunning[key] = true;
983
+ this.datasetResult[key] = null;
984
+ let result;
985
+ try {
986
+ const [{ default: axios }, { generateUrl }] = await Promise.all([
987
+ import('@nextcloud/axios'),
988
+ import('@nextcloud/router'),
989
+ ]);
990
+ const { data } = await axios.post(
991
+ generateUrl(`/apps/${this.appId}/api/setup/action/${step.loadAction}`),
992
+ { dataset: option.value },
993
+ );
994
+ result = {
995
+ success: !!data && data.success !== false,
996
+ message: (data && data.message) || translate('nextcloud-vue', 'Loaded.'),
997
+ };
998
+ } catch (err) {
999
+ result = { success: false, message: this.errorMessage(err) };
1000
+ } finally {
1001
+ this.datasetRunning[key] = false;
1002
+ }
1003
+ this.datasetResult[key] = result;
1004
+ if (result.success) {
1005
+ this.selectLoadedOption(step, option);
1006
+ this.localDone[step.id] = true;
1007
+ }
1008
+ this.$emit('action-result', {
1009
+ stepId: step.id,
1010
+ action: step.loadAction,
1011
+ dataset: option.value,
1012
+ ...result,
1013
+ });
1014
+ },
1015
+
1016
+ /**
1017
+ * Select a card that just loaded, adding to (never replacing) the
1018
+ * selection of a `multiple` step.
1019
+ *
1020
+ * @param {object} step The choice step.
1021
+ * @param {object} option The loaded option.
1022
+ * @return {void}
1023
+ */
1024
+ selectLoadedOption(step, option) {
1025
+ if (step.multiple === true) {
1026
+ const current = this.cardModel(step);
1027
+ if (current.some((v) => String(v) === String(option.value))) {
1028
+ return
1029
+ }
1030
+ this.onChoice(step, current.concat([option.value]));
1031
+ return
1032
+ }
1033
+ this.onChoice(step, option.value);
1034
+ },
1035
+
1036
+ /**
1037
+ * A required app was installed from the dependency list. A new app's
1038
+ * scripts and its `OC.appswebroots` entry exist only after a full page
1039
+ * load, and `useAppStatus` caches per page, so reload.
1040
+ *
1041
+ * @return {void}
1042
+ */
1043
+ onDependencyInstalled() {
1044
+ window.location.reload();
1045
+ },
1046
+
722
1047
  /**
723
1048
  * Whether a step is marked on-demand (`onDemand: true`): it runs only
724
1049
  * when the user asks, never automatically, and the summary ticks it