From a5e59e423500fa97b84932cbc3b70bd3eb01a54a Mon Sep 17 00:00:00 2001
From: arcticfly <41524992+arcticfly@users.noreply.github.com>
Date: Fri, 18 Aug 2023 00:08:32 -0700
Subject: [PATCH] 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
---
.../OutputsTable/ScenarioEditor.tsx | 89 ++++++++++---------
.../OutputsTable/ScenarioEditorModal.tsx | 4 +-
2 files changed, 49 insertions(+), 44 deletions(-)
diff --git a/app/src/components/OutputsTable/ScenarioEditor.tsx b/app/src/components/OutputsTable/ScenarioEditor.tsx
index 51770aa..8e2872f 100644
--- a/app/src/components/OutputsTable/ScenarioEditor.tsx
+++ b/app/src/components/OutputsTable/ScenarioEditor.tsx
@@ -111,25 +111,23 @@ export default function ScenarioEditor({
onDrop={onReorder}
backgroundColor={isDragTarget ? "gray.100" : "transparent"}
>
- {variableLabels.length === 0 ? (
-
- {vars.data ? "No scenario variables configured" : "Loading..."}
-
- ) : (
+ {
Scenario
-
- }
- onClick={() => setScenarioEditorModalOpen(true)}
- size="xs"
- colorScheme="gray"
- color="gray.500"
- variant="ghost"
- />
-
+ {variableLabels.length && (
+
+ }
+ onClick={() => setScenarioEditorModalOpen(true)}
+ size="xs"
+ colorScheme="gray"
+ color="gray.500"
+ variant="ghost"
+ />
+
+ )}
{canModify && props.canHide && (
)}
- {variableLabels.map((key) => {
- const value = values[key] ?? "";
- return (
- {
- setValues((prev) => ({ ...prev, [key]: e.target.value }));
- }}
- onKeyDown={(e) => {
- if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
- e.preventDefault();
- e.currentTarget.blur();
- onSave();
- }
- }}
- onMouseEnter={() => setVariableInputHovered(true)}
- onMouseLeave={() => setVariableInputHovered(false)}
- />
- );
- })}
+
+ {variableLabels.length === 0 ? (
+
+ {vars.data ? "No scenario variables configured" : "Loading..."}
+
+ ) : (
+ variableLabels.map((key) => {
+ const value = values[key] ?? "";
+ return (
+ {
+ setValues((prev) => ({ ...prev, [key]: e.target.value }));
+ }}
+ onKeyDown={(e) => {
+ if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
+ e.preventDefault();
+ e.currentTarget.blur();
+ onSave();
+ }
+ }}
+ onMouseEnter={() => setVariableInputHovered(true)}
+ onMouseLeave={() => setVariableInputHovered(false)}
+ />
+ );
+ })
+ )}
{hasChanged && (
- )}
+ }
{scenarioEditorModalOpen && (
-
+ Edit Scenario