From 535e452c5c9ba6dbf44554ad431710594bb0be97 Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Thu, 17 Oct 2024 21:43:38 +0200 Subject: [PATCH] Fix relative hidden file resolution --- .../computeRootFormFieldGroup.test.ts | 78 ++++++++++++++++++- .../computeRootFormFieldGroup.ts | 2 +- 2 files changed, 77 insertions(+), 3 deletions(-) diff --git a/web/src/core/usecases/launcher/decoupledLogic/computeRootForm/computeRootFormFieldGroup.test.ts b/web/src/core/usecases/launcher/decoupledLogic/computeRootForm/computeRootFormFieldGroup.test.ts index e7a7ac0c9..6e499041c 100644 --- a/web/src/core/usecases/launcher/decoupledLogic/computeRootForm/computeRootFormFieldGroup.test.ts +++ b/web/src/core/usecases/launcher/decoupledLogic/computeRootForm/computeRootFormFieldGroup.test.ts @@ -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({ @@ -102,7 +176,7 @@ describe(symToStr({ computeRootFormFieldGroup }), () => { "helmValues": { "persistence": { "enabled": false, - "size": 10 + "size": "10Gi" } }, xOnyxiaContext diff --git a/web/src/core/usecases/launcher/decoupledLogic/computeRootForm/computeRootFormFieldGroup.ts b/web/src/core/usecases/launcher/decoupledLogic/computeRootForm/computeRootFormFieldGroup.ts index f085d78e5..6009409e9 100644 --- a/web/src/core/usecases/launcher/decoupledLogic/computeRootForm/computeRootFormFieldGroup.ts +++ b/web/src/core/usecases/launcher/decoupledLogic/computeRootForm/computeRootFormFieldGroup.ts @@ -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({