This repository was archived by the owner on Jun 26, 2026. It is now read-only.
Repository navigation
Commit 1d9d26b
feat(console): dynamic form dropdowns via x-cozystack-options (DynamicOptionsWidget) (#30)
* feat(console): unify form dropdowns on x-cozystack-options
Add a single generic DynamicOptionsWidget that renders any string field
carrying the x-cozystack-options schema keyword as a <select>, populated
from the cozystack-api Option resource (one source per dropdown). A
shared addDynamicOptionWidgets walker binds the widget across nested
properties, array items and additionalProperties (so vm-instance
disks[].name and kubernetes nodeGroups.* are covered); the
AdditionalPropertiesField passes it through to its nested forms.
Replaces the bespoke StorageClassWidget, VMDiskWidget and
BackupClassWidget (default-StorageClass preselect and disk-size labels
are preserved via the server-provided item.default flag and labels), so
every form dropdown now uses one mechanism.
Co-Authored-By: Claude <[email protected]>
Signed-off-by: Andrei Kvapil <[email protected]>
* feat(console): migrate backup form dropdowns to x-cozystack-options
The standalone backup-resource create pages (Plan, BackupJob, Backup,
RestoreJob) maintained a parallel client-side dropdown mechanism: they
fetched BackupClasses / Plans / Backups / application kinds and injected
them into the CRD schema as static enum arrays via enumMap. The CRD
schemas now carry the x-cozystack-options keyword on these fields, so
DynamicOptionsWidget renders them automatically from the cozystack-api
Option resource.
Drop the now-redundant enumMap entries and their backing useK8sList
fetches for backupClassName, planRef.name, backupRef.name and
applicationRef.kind / targetApplicationRef.kind. Keep applicationRef.name
and targetApplicationRef.name on enumMap: they depend on the sibling
kind field, a context the Option contract cannot express.
Add unit coverage for the addDynamicOptionWidgets walker over the
nested backup CRD shape.
Co-Authored-By: Claude <[email protected]>
Signed-off-by: Andrei Kvapil <[email protected]>
* test(forms): cover DynamicOptionsWidget runtime behavior
The migration to the generic widget removed the StorageClass/VMDisk/BackupClass
widget test suites, dropping coverage of behavior that absorbed several prior
bug fixes. Pin it on DynamicOptionsWidget: auto-selecting the server-marked
default once, showing an explicit placeholder for a required empty select
instead of the first option, keeping a committed value visible while the list
loads, emitting undefined (not "") on clear, and resolving items only from the
Option whose name matches the field's source.
Assisted-By: Claude <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
* test(forms): cover the dynamic-options walker's items and additionalProperties branches
The walker recurses into array items and additionalProperties maps — the whole
reason it exists over inlining (vm-instance disks[].name, kubernetes
nodeGroups.*.instanceType) — but only the properties path was tested. Add cases
for both recursion branches.
Assisted-By: Claude <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
* docs(forms): correct stale apiGroup-gating comments for the kind dropdown
The applicationRef.kind field now resolves through the appkind option source, so
it renders as a dropdown for every apiGroup — it is no longer gated to
apps.cozystack.io. Only the applicationRef.name enum remains gated (it is served
client-side and depends on the chosen kind). Update the comments that still
described the old free-text-fallback behavior for the kind field.
Assisted-By: Claude <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
* docs: describe the x-cozystack-options widget binding in the RJSF pipeline
The forms pipeline section still listed the removed StorageClass/BackupClass/
VMDisk field-name widgets and framed binding as a field-name convention. Update
it to describe addDynamicOptionWidgets binding any field carrying
x-cozystack-options to DynamicOptionsWidget, recursing into properties, array
items and additionalProperties.
Assisted-By: Claude <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
* docs(forms): drop stale references to the removed per-field widgets
Two comments still pointed at entities this migration removed: the backup-class
access hook claimed the dropdown is powered by a tenant list on backupclasses
(it is now served by the Option resource), and the SchemaForm default-emit
comment cited plansData/backupClassesData as the async-sibling example (both
deleted). Correct both to match the code.
Assisted-By: Claude <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
* test(forms): pin the dynamic-options walker's oneOf/anyOf/allOf gap
The walker recurses into properties/items/additionalProperties but not the
composition keywords, mirroring the same intentional limitation in
addSensitiveStringWidgets. Pin it with a FIXME so the gap is documented rather
than silent.
Assisted-By: Claude <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
* test(forms): pin VMDisk no-auto-default and the namespaced Option query
The generic widget auto-selects only the server-marked default item, so a
default-less source (vmdisk) must not auto-commit on load — the invariant the
old VMDiskWidget enforced to avoid dropping the user's disk on a fast submit.
Also pin that the Option resource is listed namespaced to the active tenant
(querying it cluster-wide would return nothing).
Assisted-By: Claude <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
* test(forms): assert the dynamic-options walker does not mutate its input uiSchema
The pipeline contract (and the sibling sensitive-fields walker) requires the
binders to return a new object and leave the input untouched. Pin it for
addDynamicOptionWidgets: a nested input uiSchema stays byte-identical and the
result's touched sub-objects are fresh references.
Assisted-By: Claude <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
* fix(forms): keep a cleared optional dropdown cleared instead of re-applying the default
The select onChange reset the auto-default guard whenever the field was cleared,
which re-armed the effect: for an optional field with a server-marked default,
clearing emitted undefined, the effect then saw no value and re-selected the
default, so the field could never be cleared. Latch the guard after the first
auto-default and never reset it — clearing now sticks, matching the comment's
stated intent. Required fields were unaffected (their empty option is disabled).
Assisted-By: Claude <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
---------
Signed-off-by: Andrei Kvapil <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
Co-authored-by: Claude <[email protected]>
Co-authored-by: Aleksei Sviridkin <[email protected]>1 parent cecb486 commit 1d9d26b
19 files changed
Lines changed: 640 additions & 825 deletions
File tree
- apps/console/src
- components
- hooks
- lib
- routes
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
| 99 | + | |
| 100 | + | |
103 | 101 | | |
104 | 102 | | |
105 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
13 | 17 | | |
14 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
15 | 24 | | |
16 | 25 | | |
17 | 26 | | |
| |||
79 | 88 | | |
80 | 89 | | |
81 | 90 | | |
| 91 | + | |
82 | 92 | | |
83 | 93 | | |
84 | 94 | | |
| |||
This file was deleted.
This file was deleted.
0 commit comments