Skip to content

Commit

Permalink
Fix relative hidden file resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Oct 17, 2024
1 parent d88a74b commit 535e452
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,81 @@ describe(symToStr({ computeRootFormFieldGroup }), () => {
expect(got).toStrictEqual(expected);
});

it("compute hidden field", () => {
it("compute hidden field - relative", () => {
const xOnyxiaContext = {};

const got = computeRootFormFieldGroup({
"helmValuesSchema": {
"type": "object",
"properties": {
"persistence": {
"description": "Configuration for persistence",
"type": "object",
"properties": {
"enabled": {
"type": "boolean",
"description": "Create a persistent volume"
},
"size": {
"type": "string",
"title": "Persistent volume size",
"description": "Size of the persistent volume",
"render": "slider",
"sliderMin": 1,
"sliderMax": 100,
"sliderStep": 1,
"sliderUnit": "Gi",
"hidden": {
"value": false,
"path": "enabled",
"isPathRelative": true
}
}
}
}
}
},
"helmValues": {
"persistence": {
"enabled": false,
"size": "10Gi"
}
},
xOnyxiaContext
});

const expected: FormFieldGroup = {
"type": "group",
"helmValuesPath": [],
"description": undefined,
"nodes": [
{
"type": "group",
"helmValuesPath": ["persistence"],
"description": "Configuration for persistence",
"nodes": [
{
"type": "field",
"title": "enabled",
"isReadonly": false,
"fieldType": "checkbox",
"helmValuesPath": ["persistence", "enabled"],
"description": "Create a persistent volume",
"value": false
}
],
"canAdd": false,
"canRemove": false
}
],
"canAdd": false,
"canRemove": false
};

expect(got).toStrictEqual(expected);
});

it("compute hidden field - absolute", () => {
const xOnyxiaContext = {};

const got = computeRootFormFieldGroup({
Expand Down Expand Up @@ -102,7 +176,7 @@ describe(symToStr({ computeRootFormFieldGroup }), () => {
"helmValues": {
"persistence": {
"enabled": false,
"size": 10
"size": "10Gi"
}
},
xOnyxiaContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function computeRootFormFieldGroup_rec(params: {
const splittedPath = path.split("/");

const helmValuesPath_target = isPathRelative
? [...helmValuesPath, ...splittedPath]
? [...helmValuesPath.slice(0, -1), ...splittedPath]
: splittedPath;

const value_target = getValueAtPathInObject<Stringifyable>({
Expand Down

0 comments on commit 535e452

Please sign in to comment.