Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enclave builder tweaks #2142

Merged
merged 6 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions enclave-manager/web/cypress/e2e/enclaveList.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ describe("Enclave List", () => {

// Update the postgres instance
cy.contains("button", "Edit").click();
cy.contains("Loading").parents(".chakra-modal__content").contains("Error").should("not.exist");
cy.contains("Loading").should("not.exist");
cy.focusInputWithLabel("Max CPU").type("1024");
cy.contains("button", "Update").click();
cy.contains("Script completed", { timeout: 30 * 1000 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const DictArgumentInput = <DataModel extends object>({
<PasteButton onValuePasted={handleValuePaste} />
</ButtonGroup>
{fields.map((field, i) => (
<Flex key={i} gap={"10px"}>
<Flex key={field.id} gap={"10px"}>
<KurtosisSubtypeFormControl
name={`${otherProps.name as `args.${string}`}.${i}.key`}
disabled={otherProps.disabled}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { useEnclavesContext } from "../../EnclavesContext";
import { EnclaveFullInfo } from "../../types";
import { KurtosisArtifactNode } from "./enclaveBuilder/KurtosisArtifactNode";
import { KurtosisServiceNode } from "./enclaveBuilder/KurtosisServiceNode";
import { ViewStarlarkModal } from "./enclaveBuilder/modals/ViewStarlarkModal";
import {
generateStarlarkFromGraph,
getInitialGraphStateFromEnclave,
Expand All @@ -58,6 +59,7 @@ export const EnclaveBuilderModal = ({ isOpen, onClose, existingEnclave }: Enclav
const { createEnclave, runStarlarkScript } = useEnclavesContext();
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<string>();
const [currentStarlarkPreview, setCurrentStarlarkPreview] = useState<string>();

const {
nodes: initialNodes,
Expand Down Expand Up @@ -121,10 +123,14 @@ export const EnclaveBuilderModal = ({ isOpen, onClose, existingEnclave }: Enclav
}
};

const handlePreview = () => {
setCurrentStarlarkPreview(visualiserRef.current?.getStarlark() || "Unable to render");
};

return (
<Modal isOpen={isOpen} onClose={!isLoading ? onClose : () => null} closeOnEsc={false}>
<ModalOverlay />
<ModalContent h={"90vh"} minW={"1300px"}>
<ModalContent h={"89vh"} minW={"1300px"}>
<ModalHeader>
{isDefined(existingEnclave) ? `Editing ${existingEnclave.name}` : "Build a new Enclave"}
</ModalHeader>
Expand All @@ -147,12 +153,18 @@ export const EnclaveBuilderModal = ({ isOpen, onClose, existingEnclave }: Enclav
<Button onClick={onClose} isDisabled={isLoading}>
Close
</Button>
<Button onClick={handlePreview}>Preview</Button>
<Button onClick={handleRun} colorScheme={"green"} isLoading={isLoading} loadingText={"Run"}>
Run
</Button>
</ButtonGroup>
</ModalFooter>
</ModalContent>
<ViewStarlarkModal
isOpen={isDefined(currentStarlarkPreview)}
onClose={() => setCurrentStarlarkPreview(undefined)}
starlark={currentStarlarkPreview}
/>
</Modal>
);
};
Expand Down Expand Up @@ -225,7 +237,8 @@ const Visualiser = forwardRef<VisualiserImperativeAttributes, VisualiserProps>(
addNodes({
id,
position: getNewNodePosition(),
width: 600,
width: 650,
style: { width: "650px" },
type: "serviceNode",
data: {},
});
Expand All @@ -238,6 +251,7 @@ const Visualiser = forwardRef<VisualiserImperativeAttributes, VisualiserProps>(
id,
position: getNewNodePosition(),
width: 600,
style: { width: "400px" },
type: "artifactNode",
data: {},
});
Expand All @@ -257,6 +271,27 @@ const Visualiser = forwardRef<VisualiserImperativeAttributes, VisualiserProps>(
});
}, [setEdges, data]);

// Remove the resizeObserver error
useEffect(() => {
const errorHandler = (e: any) => {
if (
e.message.includes(
"ResizeObserver loop completed with undelivered notifications" || "ResizeObserver loop limit exceeded",
)
) {
const resizeObserverErr = document.getElementById("webpack-dev-server-client-overlay");
if (resizeObserverErr) {
resizeObserverErr.style.display = "none";
}
}
};
window.addEventListener("error", errorHandler);

return () => {
window.removeEventListener("error", errorHandler);
};
}, []);

useImperativeHandle(
ref,
() => ({
Expand All @@ -275,7 +310,7 @@ const Visualiser = forwardRef<VisualiserImperativeAttributes, VisualiserProps>(
Add Service Node
</Button>
<Button leftIcon={<FiPlusCircle />} onClick={handleAddArtifactNode}>
Add Artifact Node
Add Files Node
</Button>
</ButtonGroup>
<Box bg={"gray.900"} flex={"1"}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const KurtosisArtifactNode = memo(
flexDirection={"column"}
height={"100%"}
borderRadius={"8px"}
p={selected ? "8px" : "10px"}
p={"10px"}
bg={"gray.600"}
borderWidth={"3px"}
outline={"3px solid transparent"}
Expand Down Expand Up @@ -92,8 +92,8 @@ export const KurtosisArtifactNode = memo(
className={"nodrag nowheel"}
gap={"8px"}
>
<KurtosisFormControl<KurtosisArtifactNodeData> name={"artifactName"} label={"Artifact Name"}>
<StringArgumentInput name={"artifactName"} />
<KurtosisFormControl<KurtosisArtifactNodeData> name={"artifactName"} label={"Artifact Name"} isRequired>
<StringArgumentInput name={"artifactName"} isRequired />
</KurtosisFormControl>
<KurtosisFormControl name={"files"} label={"Files"}>
<FileTreeArgumentInput name={"files"} />
Expand Down
Loading
Loading