From 96892d819c06e0328be79cb1f97a016088d345fc Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp Date: Wed, 18 Oct 2023 15:23:29 -0400 Subject: [PATCH] added loading when importing sdl in builder --- .../newDeploymentWizard/SdlBuilder.tsx | 70 +++++++++++-------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/deploy-web/src/components/newDeploymentWizard/SdlBuilder.tsx b/deploy-web/src/components/newDeploymentWizard/SdlBuilder.tsx index a7892157b..99eb5bc28 100644 --- a/deploy-web/src/components/newDeploymentWizard/SdlBuilder.tsx +++ b/deploy-web/src/components/newDeploymentWizard/SdlBuilder.tsx @@ -4,7 +4,7 @@ import { useFieldArray, useForm } from "react-hook-form"; import { SdlBuilderFormValues, Service } from "@src/types"; import { nanoid } from "nanoid"; import { generateSdl } from "@src/utils/sdl/sdlGenerator"; -import { Alert, Box, Button } from "@mui/material"; +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"; @@ -21,6 +21,7 @@ export type SdlBuilderRefType = { export const SdlBuilder = React.forwardRef(({ sdlString, setEditedManifest }, ref) => { const [error, setError] = useState(null); const formRef = useRef(); + const [isLoading, setIsLoading] = useState(true); const { control, trigger, watch, setValue } = useForm({ defaultValues: { services: [{ ...defaultService }] @@ -48,6 +49,7 @@ export const SdlBuilder = React.forwardRef(({ sdlStrin try { const services = createAndValidateSdl(sdlString); setValue("services", services as Service[]); + setIsLoading(false); } catch (error) { setError("Error importing SDL"); } @@ -100,35 +102,43 @@ export const SdlBuilder = React.forwardRef(({ sdlStrin }; return ( -
- {services.map((service, serviceIndex) => ( - - ))} - - {error && ( - - {error} - + <> + {isLoading ? ( + + + + ) : ( + + {services.map((service, serviceIndex) => ( + + ))} + + {error && ( + + {error} + + )} + + +
+ +
+
+ )} - - -
- -
-
- + ); });