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:
@@ -111,25 +111,23 @@ 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>
|
||||||
<Tooltip label="Expand" hasArrow>
|
{variableLabels.length && (
|
||||||
<IconButton
|
<Tooltip label="Expand" hasArrow>
|
||||||
aria-label="Expand"
|
<IconButton
|
||||||
icon={<Icon as={BsArrowsAngleExpand} boxSize={3} />}
|
aria-label="Expand"
|
||||||
onClick={() => setScenarioEditorModalOpen(true)}
|
icon={<Icon as={BsArrowsAngleExpand} boxSize={3} />}
|
||||||
size="xs"
|
onClick={() => setScenarioEditorModalOpen(true)}
|
||||||
colorScheme="gray"
|
size="xs"
|
||||||
color="gray.500"
|
colorScheme="gray"
|
||||||
variant="ghost"
|
color="gray.500"
|
||||||
/>
|
variant="ghost"
|
||||||
</Tooltip>
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
{canModify && props.canHide && (
|
{canModify && props.canHide && (
|
||||||
<Tooltip label="Delete" hasArrow>
|
<Tooltip label="Delete" hasArrow>
|
||||||
<IconButton
|
<IconButton
|
||||||
@@ -150,31 +148,38 @@ export default function ScenarioEditor({
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
</HStack>
|
</HStack>
|
||||||
{variableLabels.map((key) => {
|
|
||||||
const value = values[key] ?? "";
|
{variableLabels.length === 0 ? (
|
||||||
return (
|
<Box color="gray.500">
|
||||||
<FloatingLabelInput
|
{vars.data ? "No scenario variables configured" : "Loading..."}
|
||||||
key={key}
|
</Box>
|
||||||
label={key}
|
) : (
|
||||||
isDisabled={!canModify}
|
variableLabels.map((key) => {
|
||||||
style={{ width: "100%" }}
|
const value = values[key] ?? "";
|
||||||
maxHeight={32}
|
return (
|
||||||
value={value}
|
<FloatingLabelInput
|
||||||
onChange={(e) => {
|
key={key}
|
||||||
setValues((prev) => ({ ...prev, [key]: e.target.value }));
|
label={key}
|
||||||
}}
|
isDisabled={!canModify}
|
||||||
onKeyDown={(e) => {
|
style={{ width: "100%" }}
|
||||||
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
maxHeight={32}
|
||||||
e.preventDefault();
|
value={value}
|
||||||
e.currentTarget.blur();
|
onChange={(e) => {
|
||||||
onSave();
|
setValues((prev) => ({ ...prev, [key]: e.target.value }));
|
||||||
}
|
}}
|
||||||
}}
|
onKeyDown={(e) => {
|
||||||
onMouseEnter={() => setVariableInputHovered(true)}
|
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
||||||
onMouseLeave={() => setVariableInputHovered(false)}
|
e.preventDefault();
|
||||||
/>
|
e.currentTarget.blur();
|
||||||
);
|
onSave();
|
||||||
})}
|
}
|
||||||
|
}}
|
||||||
|
onMouseEnter={() => setVariableInputHovered(true)}
|
||||||
|
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
|
||||||
|
|||||||
@@ -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}>
|
||||||
|
|||||||
Reference in New Issue
Block a user