Allow user to delete scenario without variables (#172)

* Allow user to delete scenario without variables

* Hide expand button for empty scenario editor

* Add header to scenario modal
This commit is contained in:
arcticfly
2023-08-18 00:08:32 -07:00
committed by GitHub
parent d0102e3202
commit a5e59e4235
2 changed files with 49 additions and 44 deletions

View File

@@ -111,14 +111,11 @@ export default function ScenarioEditor({
onDrop={onReorder} onDrop={onReorder}
backgroundColor={isDragTarget ? "gray.100" : "transparent"} backgroundColor={isDragTarget ? "gray.100" : "transparent"}
> >
{variableLabels.length === 0 ? ( {
<Box color="gray.500">
{vars.data ? "No scenario variables configured" : "Loading..."}
</Box>
) : (
<VStack spacing={4} flex={1} py={2}> <VStack spacing={4} flex={1} py={2}>
<HStack justifyContent="space-between" w="100%" align="center" spacing={0}> <HStack justifyContent="space-between" w="100%" align="center" spacing={0}>
<Text flex={1}>Scenario</Text> <Text flex={1}>Scenario</Text>
{variableLabels.length && (
<Tooltip label="Expand" hasArrow> <Tooltip label="Expand" hasArrow>
<IconButton <IconButton
aria-label="Expand" aria-label="Expand"
@@ -130,6 +127,7 @@ export default function ScenarioEditor({
variant="ghost" variant="ghost"
/> />
</Tooltip> </Tooltip>
)}
{canModify && props.canHide && ( {canModify && props.canHide && (
<Tooltip label="Delete" hasArrow> <Tooltip label="Delete" hasArrow>
<IconButton <IconButton
@@ -150,7 +148,13 @@ export default function ScenarioEditor({
</Tooltip> </Tooltip>
)} )}
</HStack> </HStack>
{variableLabels.map((key) => {
{variableLabels.length === 0 ? (
<Box color="gray.500">
{vars.data ? "No scenario variables configured" : "Loading..."}
</Box>
) : (
variableLabels.map((key) => {
const value = values[key] ?? ""; const value = values[key] ?? "";
return ( return (
<FloatingLabelInput <FloatingLabelInput
@@ -174,7 +178,8 @@ export default function ScenarioEditor({
onMouseLeave={() => setVariableInputHovered(false)} onMouseLeave={() => setVariableInputHovered(false)}
/> />
); );
})} })
)}
{hasChanged && ( {hasChanged && (
<HStack justify="right"> <HStack justify="right">
<Button <Button
@@ -192,7 +197,7 @@ export default function ScenarioEditor({
</HStack> </HStack>
)} )}
</VStack> </VStack>
)} }
</HStack> </HStack>
{scenarioEditorModalOpen && ( {scenarioEditorModalOpen && (
<ScenarioEditorModal <ScenarioEditorModal

View File

@@ -65,11 +65,11 @@ export const ScenarioEditorModal = ({
<Modal <Modal
isOpen isOpen
onClose={onClose} onClose={onClose}
size={{ base: "xl", sm: "2xl", md: "3xl", lg: "5xl", xl: "7xl" }} size={{ base: "xl", sm: "2xl", md: "3xl", lg: "4xl", xl: "5xl" }}
> >
<ModalOverlay /> <ModalOverlay />
<ModalContent w={1200}> <ModalContent w={1200}>
<ModalHeader /> <ModalHeader>Edit Scenario</ModalHeader>
<ModalCloseButton /> <ModalCloseButton />
<ModalBody maxW="unset"> <ModalBody maxW="unset">
<VStack spacing={8}> <VStack spacing={8}>