Skip to content

Commit

Permalink
Show issues warning on run button tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
Dartoxian committed Feb 9, 2024
1 parent c2f4c7d commit 02f523e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ import {
Button,
ButtonGroup,
Flex,
ListItem,
Modal,
ModalBody,
ModalCloseButton,
ModalContent,
ModalFooter,
ModalHeader,
ModalOverlay,
Text,
Tooltip,
UnorderedList,
} from "@chakra-ui/react";
import Dagre from "@dagrejs/dagre";
import { isDefined, KurtosisAlert, KurtosisAlertModal, RemoveFunctions, stringifyError } from "kurtosis-ui-components";
Expand Down Expand Up @@ -121,7 +125,18 @@ const EnclaveBuilderModalImpl = ({
const visualiserRef = useRef<VisualiserImperativeAttributes | null>(null);
const { createEnclave, runStarlarkScript } = useEnclavesContext();
const { data } = useVariableContext();
const isDataValid = useMemo(() => Object.values(data).every((nodeData) => nodeData.isValid), [data]);
const dataIssues = useMemo(
() =>
Object.values(data)
.filter((nodeData) => !nodeData.isValid)
.map(
(nodeData) =>
`${nodeData.type} ${
(nodeData.type === "artifact" ? nodeData.artifactName : nodeData.serviceName) || "with no name"
} has invalid data`,
),
[data],
);
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<string>();
const [currentStarlarkPreview, setCurrentStarlarkPreview] = useState<string>();
Expand Down Expand Up @@ -195,15 +210,30 @@ const EnclaveBuilderModalImpl = ({
Close
</Button>
<Button onClick={handlePreview}>Preview</Button>
<Button
onClick={handleRun}
colorScheme={"green"}
isLoading={isLoading}
loadingText={"Run"}
isDisabled={!isDataValid}
<Tooltip
label={
dataIssues.length === 0 ? undefined : (
<Flex flexDirection={"column"}>
<Text>There are data issues that must be addressed before this enclave can run:</Text>
<UnorderedList>
{dataIssues.map((issue, i) => (
<ListItem key={i}>{issue}</ListItem>
))}
</UnorderedList>
</Flex>
)
}
>
Run
</Button>
<Button
onClick={handleRun}
colorScheme={"green"}
isLoading={isLoading}
loadingText={"Run"}
isDisabled={dataIssues.length > 0}
>
Run
</Button>
</Tooltip>
</ButtonGroup>
</ModalFooter>
</ModalContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export const KurtosisServiceNode = memo(
if (typeof val !== "string") {
return "Value should be a string";
}
if (!val.includes(" ")) {
if (val.includes(" ")) {
return "Application protocol cannot include spaces";
}
}}
Expand Down

0 comments on commit 02f523e

Please sign in to comment.