From dbcbbf489ecee10c0692d210af83fd2c8d44ea48 Mon Sep 17 00:00:00 2001 From: abhimazu <mail.abhijeetmazumdar@gmail.com> Date: Wed, 5 Mar 2025 13:16:07 -0500 Subject: [PATCH] Added a way to hide the second field of folder_name until the user faces a ValueError --- .../components/Data/LocalDatasets.tsx | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/renderer/components/Data/LocalDatasets.tsx b/src/renderer/components/Data/LocalDatasets.tsx index 5ccf9afe..4248e601 100644 --- a/src/renderer/components/Data/LocalDatasets.tsx +++ b/src/renderer/components/Data/LocalDatasets.tsx @@ -43,6 +43,7 @@ export default function LocalDatasets() { const [searchText, setSearchText] = useState(''); const [newDatasetModalOpen, setNewDatasetModalOpen] = useState(false); const [downloadingDataset, setDownloadingDataset] = useState(null); + const [showConfig, setShowConfig] = useState(false); const { data, error, isLoading, mutate } = useSWR( chatAPI.Endpoints.Dataset.LocalList(false), @@ -153,16 +154,18 @@ export default function LocalDatasets() { // Setting model_id text field to 70% of the width, as they are longer sx={{ flex: 7 }} /> - <Input - placeholder="Config name" - name="download-config-name" - // Setting config name text field to 30% of the width, as they are folder names - sx={{ flex: 3 }} - /> + {showConfig && ( + <Input + placeholder="folder_name" + name="download-config-name" + // Setting config name text field to 30% of the width, as they are folder names + sx={{ flex: 3 }} + /> + )} <Button onClick={async (e) => { const dataset = document.getElementsByName('download-dataset-name')[0].value; - const configName = document.getElementsByName('download-config-name')[0]?.value; + const configName = showConfig? document.getElementsByName('download-config-name')[0]?.value : undefined; // only download if valid model is entered if (dataset) { // this triggers UI changes while download is in progress @@ -185,6 +188,10 @@ export default function LocalDatasets() { }) .catch((error) => { setDownloadingDataset(null); + // Check if the error message asks for folder_name and automatically show the config field + if (error.message.includes("folder_name")) { + setShowConfig(true); + } alert('Download failed:\n' + error); }); } -- GitLab