From ccf6ed4bc815261c33a80dda9eeddec821973e1c Mon Sep 17 00:00:00 2001 From: SaelixCode Date: Tue, 3 Mar 2026 12:47:41 -0500 Subject: [PATCH] refactor: rename isActionLoading to loadingAction for clarity and consistency --- frontend/src/components/EditorLayout.tsx | 52 ++++++++++++------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/frontend/src/components/EditorLayout.tsx b/frontend/src/components/EditorLayout.tsx index 7a1f6ce8..0a24a258 100644 --- a/frontend/src/components/EditorLayout.tsx +++ b/frontend/src/components/EditorLayout.tsx @@ -64,7 +64,7 @@ export default function EditorLayout() { const [newStackName, setNewStackName] = useState(''); const [stackToDelete, setStackToDelete] = useState(null); const [isLoading, setIsLoading] = useState(false); - const [isActionLoading, setIsActionLoading] = useState(false); + const [loadingAction, setLoadingAction] = useState(null); const [isFileLoading, setIsFileLoading] = useState(false); const [isDarkMode, setIsDarkMode] = useState(() => { const saved = localStorage.getItem('sencho-theme'); @@ -347,9 +347,9 @@ export default function EditorLayout() { const deployStack = async (e: React.MouseEvent) => { e.preventDefault(); e.stopPropagation(); - if (!selectedFile || isActionLoading) return; + if (!selectedFile || loadingAction !== null) return; const stackName = selectedFile.replace(/\.(yml|yaml)$/, ''); - setIsActionLoading(true); + setLoadingAction('deploy'); try { await apiFetch(`/stacks/${stackName}/deploy`, { method: 'POST', @@ -364,16 +364,16 @@ export default function EditorLayout() { console.error('Failed to deploy:', error); toast.error(error.message || "Failed to deploy stack"); } finally { - setIsActionLoading(false); + setLoadingAction(null); } }; const stopStack = async (e: React.MouseEvent) => { e.preventDefault(); e.stopPropagation(); - if (!selectedFile || isActionLoading) return; + if (!selectedFile || loadingAction !== null) return; const stackName = selectedFile.replace(/\.(yml|yaml)$/, ''); - setIsActionLoading(true); + setLoadingAction('stop'); try { await apiFetch(`/stacks/${stackName}/stop`, { method: 'POST', @@ -386,16 +386,16 @@ export default function EditorLayout() { } catch (error) { console.error('Failed to stop:', error); } finally { - setIsActionLoading(false); + setLoadingAction(null); } }; const restartStack = async (e: React.MouseEvent) => { e.preventDefault(); e.stopPropagation(); - if (!selectedFile || isActionLoading) return; + if (!selectedFile || loadingAction !== null) return; const stackName = selectedFile.replace(/\.(yml|yaml)$/, ''); - setIsActionLoading(true); + setLoadingAction('restart'); try { await apiFetch(`/stacks/${stackName}/restart`, { method: 'POST', @@ -408,16 +408,16 @@ export default function EditorLayout() { } catch (error) { console.error('Failed to restart:', error); } finally { - setIsActionLoading(false); + setLoadingAction(null); } }; const updateStack = async (e: React.MouseEvent) => { e.preventDefault(); e.stopPropagation(); - if (!selectedFile || isActionLoading) return; + if (!selectedFile || loadingAction !== null) return; const stackName = selectedFile.replace(/\.(yml|yaml)$/, ''); - setIsActionLoading(true); + setLoadingAction('update'); try { await apiFetch(`/stacks/${stackName}/update`, { method: 'POST', @@ -430,13 +430,13 @@ export default function EditorLayout() { } catch (error) { console.error('Failed to update:', error); } finally { - setIsActionLoading(false); + setLoadingAction(null); } }; const deleteStack = async () => { if (!stackToDelete) return; - setIsActionLoading(true); + setLoadingAction('delete'); try { const response = await apiFetch(`/stacks/${stackToDelete}`, { method: 'DELETE', @@ -459,7 +459,7 @@ export default function EditorLayout() { console.error('Failed to delete stack:', error); toast.error('Failed to delete stack'); } finally { - setIsActionLoading(false); + setLoadingAction(null); } }; @@ -817,38 +817,38 @@ export default function EditorLayout() {
{isRunning ? ( <> - - ) : ( - )} -
@@ -983,7 +983,7 @@ export default function EditorLayout() { Save Only -