@@ -8,6 +8,7 @@ import { Button } from './ui/button';
88import { ScriptInstallationCard } from './ScriptInstallationCard' ;
99import { ConfirmationModal } from './ConfirmationModal' ;
1010import { ErrorModal } from './ErrorModal' ;
11+ import { LoadingModal } from './LoadingModal' ;
1112import { getContrastColor } from '../../lib/colorUtils' ;
1213import {
1314 DropdownMenu ,
@@ -84,6 +85,12 @@ export function InstalledScriptsTab() {
8485 type ?: 'error' | 'success' ;
8586 } | null > ( null ) ;
8687
88+ // Loading modal state
89+ const [ loadingModal , setLoadingModal ] = useState < {
90+ isOpen : boolean ;
91+ action : string ;
92+ } | null > ( null ) ;
93+
8794 // Fetch installed scripts
8895 const { data : scriptsData , refetch : refetchScripts , isLoading } = api . installedScripts . getAllInstalledScripts . useQuery ( ) ;
8996 const { data : statsData } = api . installedScripts . getInstallationStats . useQuery ( ) ;
@@ -247,6 +254,7 @@ export function InstalledScriptsTab() {
247254
248255 const controlContainerMutation = api . installedScripts . controlContainer . useMutation ( {
249256 onSuccess : ( data , variables ) => {
257+ setLoadingModal ( null ) ;
250258 setControllingScriptId ( null ) ;
251259
252260 if ( data . success ) {
@@ -287,6 +295,7 @@ export function InstalledScriptsTab() {
287295 } ,
288296 onError : ( error ) => {
289297 console . error ( 'Container control error:' , error ) ;
298+ setLoadingModal ( null ) ;
290299 setControllingScriptId ( null ) ;
291300
292301 // Show detailed error message
@@ -302,6 +311,7 @@ export function InstalledScriptsTab() {
302311
303312 const destroyContainerMutation = api . installedScripts . destroyContainer . useMutation ( {
304313 onSuccess : ( data ) => {
314+ setLoadingModal ( null ) ;
305315 setControllingScriptId ( null ) ;
306316
307317 if ( data . success ) {
@@ -326,6 +336,7 @@ export function InstalledScriptsTab() {
326336 } ,
327337 onError : ( error ) => {
328338 console . error ( 'Container destroy error:' , error ) ;
339+ setLoadingModal ( null ) ;
329340 setControllingScriptId ( null ) ;
330341
331342 // Show detailed error message
@@ -515,6 +526,7 @@ export function InstalledScriptsTab() {
515526 message : `Are you sure you want to ${ action } container ${ script . container_id } (${ script . script_name } )?` ,
516527 onConfirm : ( ) => {
517528 setControllingScriptId ( script . id ) ;
529+ setLoadingModal ( { isOpen : true , action : `${ action === 'start' ? 'Starting' : 'Stopping' } container ${ script . container_id } ...` } ) ;
518530 void controlContainerMutation . mutate ( { id : script . id , action } ) ;
519531 setConfirmationModal ( null ) ;
520532 }
@@ -535,6 +547,7 @@ export function InstalledScriptsTab() {
535547 confirmText : script . container_id ,
536548 onConfirm : ( ) => {
537549 setControllingScriptId ( script . id ) ;
550+ setLoadingModal ( { isOpen : true , action : `Destroying container ${ script . container_id } ...` } ) ;
538551 void destroyContainerMutation . mutate ( { id : script . id } ) ;
539552 setConfirmationModal ( null ) ;
540553 }
@@ -1566,6 +1579,14 @@ export function InstalledScriptsTab() {
15661579 type = { errorModal . type ?? 'error' }
15671580 />
15681581 ) }
1582+
1583+ { /* Loading Modal */ }
1584+ { loadingModal && (
1585+ < LoadingModal
1586+ isOpen = { loadingModal . isOpen }
1587+ action = { loadingModal . action }
1588+ />
1589+ ) }
15691590 </ div >
15701591 ) ;
15711592}
0 commit comments