1+ import { skipToken } from '@reduxjs/toolkit/query' ;
12import { useState } from "react" ;
23import { Button , Form } from "react-bootstrap" ;
34import ListFiltersHeader from "../../shared/ListFiltersHeader" ;
5+ import useAppParams from '../../shared/hooks/useAppParams' ;
46import { LogMessage } from '../../shared/types/LogMessage' ;
57import {
68 useGetDoNotLoadConfigOnNextBootQuery ,
@@ -17,9 +19,10 @@ import { useFilteredMessages } from "./hooks/useFilteredMessages";
1719const DebugConsole = ( { messages, isConnected, join, stop, clear} : DebugConsoleProps ) => {
1820 //* HOOKS ***********************************************************/
1921 const [ showModal , setShowModal ] = useState ( false ) ;
22+ const { appId } = useAppParams ( ) ;
2023
2124 const { data : doNotLoadConfigOnNextBoot } =
22- useGetDoNotLoadConfigOnNextBootQuery ( ) ;
25+ useGetDoNotLoadConfigOnNextBootQuery ( appId ? { appId } : skipToken ) ;
2326
2427 const [ setDoNotLoadConfig ] = useSetDoNotLoadConfigOnNextBootMutation ( ) ;
2528 const [ restart ] = useSetRestartMutation ( ) ;
@@ -33,11 +36,12 @@ const DebugConsole = ({messages, isConnected, join, stop, clear}: DebugConsolePr
3336 } ;
3437
3538 const clickLoadConfig = ( ) => {
39+ if ( ! appId ) return ;
3640 console . log ( "Loading config" ) ;
37- loadConfig ( ) ;
41+ loadConfig ( { appId } ) ;
3842 } ;
3943
40- if ( ! doNotLoadConfigOnNextBoot ) return null ;
44+ if ( ! doNotLoadConfigOnNextBoot || ! appId ) return null ;
4145
4246 //* RENDER **********************************************************/
4347 return (
@@ -48,12 +52,12 @@ const DebugConsole = ({messages, isConnected, join, stop, clear}: DebugConsolePr
4852 </ div >
4953 < div className = "d-flex align-items-center justify-content-start mb-2" >
5054 { ! isConnected ? (
51- < Button className = "mx-1" variant = "primary" size = "sm" onClick = { join } >
55+ < Button className = "mx-1" variant = "primary" size = "sm" onClick = { ( ) => join ( appId ) } >
5256 Start Debug Session
5357 </ Button >
5458 )
5559 : (
56- < Button className = "mx-1" variant = "primary" size = "sm" onClick = { stop } >
60+ < Button className = "mx-1" variant = "primary" size = "sm" onClick = { ( ) => stop ( appId ) } >
5761 Stop Debug Session
5862 </ Button >
5963 ) }
@@ -65,11 +69,12 @@ const DebugConsole = ({messages, isConnected, join, stop, clear}: DebugConsolePr
6569 name = "doNotLoadConfig"
6670 id = "doNotLoadConfig"
6771 checked = { doNotLoadConfigOnNextBoot ?. doNotLoadConfigOnNextBoot }
68- onChange = { ( ) =>
72+ onChange = { ( ) => {
73+ if ( ! appId ) return ;
6974 setDoNotLoadConfig (
70- ! doNotLoadConfigOnNextBoot ?. doNotLoadConfigOnNextBoot
75+ { appId , doNotLoadConfigOnNextBoot : ! doNotLoadConfigOnNextBoot ?. doNotLoadConfigOnNextBoot }
7176 )
72- }
77+ } }
7378 />
7479 { doNotLoadConfigOnNextBoot ?. doNotLoadConfigOnNextBoot && (
7580 < Button
@@ -107,7 +112,8 @@ const DebugConsole = ({messages, isConnected, join, stop, clear}: DebugConsolePr
107112 show = { showModal }
108113 handleClose = { ( ) => setShowModal ( false ) }
109114 handleConfirm = { ( ) => {
110- restart ( ) ;
115+ if ( ! appId ) return ;
116+ restart ( { appId } ) ;
111117 setShowModal ( false ) ;
112118 } }
113119 />
@@ -121,8 +127,8 @@ export default DebugConsole;
121127interface DebugConsoleProps {
122128 messages : LogMessage [ ] ;
123129 isConnected : boolean ;
124- join : ( ) => void ;
125- stop : ( ) => void ;
130+ join : ( appId : string ) => void ;
131+ stop : ( appId : string ) => void ;
126132 clear : ( ) => void ;
127133}
128134
0 commit comments