From d644be8430a57ebbf195afd2c460946b38e5a56f Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Wed, 17 Jan 2024 22:23:33 -0500 Subject: [PATCH] bugfixes/save-template-error (#79) * fix error when saving template with empty env * fix persistent storage sdl import --- .../src/components/newDeploymentWizard/SdlBuilder.tsx | 1 - deploy-web/src/hooks/useShortText.ts | 2 +- deploy-web/src/utils/sdl/sdlImport.ts | 9 +++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/deploy-web/src/components/newDeploymentWizard/SdlBuilder.tsx b/deploy-web/src/components/newDeploymentWizard/SdlBuilder.tsx index 9d39e7349..2af318ef4 100644 --- a/deploy-web/src/components/newDeploymentWizard/SdlBuilder.tsx +++ b/deploy-web/src/components/newDeploymentWizard/SdlBuilder.tsx @@ -8,7 +8,6 @@ import { Alert, Box, Button, CircularProgress } from "@mui/material"; import { SimpleServiceFormControl } from "../sdl/SimpleServiceFormControl"; import { useProviderAttributesSchema } from "@src/queries/useProvidersQuery"; import { importSimpleSdl } from "@src/utils/sdl/sdlImport"; -import { Subscription } from "react-hook-form/dist/utils/createSubject"; interface Props { sdlString: string; diff --git a/deploy-web/src/hooks/useShortText.ts b/deploy-web/src/hooks/useShortText.ts index 569649772..b9d14a0c0 100644 --- a/deploy-web/src/hooks/useShortText.ts +++ b/deploy-web/src/hooks/useShortText.ts @@ -1,4 +1,4 @@ -export const getShortText = (text: string, length: number) => { +export const getShortText = (text: string = "", length: number) => { return text.length < length ? text : `${text.substring(0, length - 3)}...`; }; diff --git a/deploy-web/src/utils/sdl/sdlImport.ts b/deploy-web/src/utils/sdl/sdlImport.ts index cbcaec32e..22852350e 100644 --- a/deploy-web/src/utils/sdl/sdlImport.ts +++ b/deploy-web/src/utils/sdl/sdlImport.ts @@ -23,9 +23,10 @@ export const importSimpleSdl = (yamlStr: string, providerAttributesSchema: Provi const compute = yamlJson.profiles.compute[svcName]; const storages = compute.resources.storage.map ? compute.resources.storage : [compute.resources.storage]; - const hasPersistentStorage = storages.some(s => s.attributes?.persistent === true); const persistentStorage = storages.find(s => s.attributes?.persistent === true); + const hasPersistentStorage = !!persistentStorage; const ephStorage = storages.find(s => !s.attributes); + const persistentStorageName = hasPersistentStorage ? persistentStorage.name : "data"; // TODO validation // Service compute profile @@ -43,10 +44,10 @@ export const importSimpleSdl = (yamlStr: string, providerAttributesSchema: Provi persistentStorage: hasPersistentStorage ? getResourceDigit(persistentStorage?.size) : 10, persistentStorageUnit: hasPersistentStorage ? getResourceUnit(persistentStorage?.size) : "Gi", persistentStorageParam: { - name: hasPersistentStorage ? persistentStorage?.name : "data", + name: persistentStorageName, type: hasPersistentStorage ? persistentStorage?.attributes?.class : "beta2", - mount: hasPersistentStorage ? svc.params?.storage?.data?.mount : "", - readOnly: hasPersistentStorage ? svc.params?.storage?.data?.readOnly : false + mount: hasPersistentStorage ? svc.params?.storage[persistentStorageName]?.mount : "", + readOnly: hasPersistentStorage ? svc.params?.storage[persistentStorageName]?.readOnly : false } };