@@ -4,7 +4,7 @@ import { CustomUI, Field, Page, Section } from "../../api/CustomUI";
4
4
import IBMiContent from "../../api/IBMiContent" ;
5
5
import { Tools } from "../../api/Tools" ;
6
6
import { isManaged } from "../../api/debug" ;
7
- import { getLocalCertPath , getRemoteCertificateDirectory , localClientCertExists , readRemoteCertificate , remoteServerCertificateExists } from "../../api/debug/certificates" ;
7
+ import { getLocalCertPath , getRemoteCertificateDirectory , localClientCertExists , readRemoteCertificate , remoteServerCertificateExists , setup } from "../../api/debug/certificates" ;
8
8
import { DebugJob , getDebugServerJob , getDebugServiceJob , startServer , startService , stopServer , stopService } from "../../api/debug/server" ;
9
9
import { instance } from "../../instantiate" ;
10
10
import { t } from "../../locale" ;
@@ -85,7 +85,11 @@ export async function openDebugStatusPanel() {
85
85
: ""
86
86
}
87
87
</ul>` ) ;
88
- addStartStopButtons ( "service" , summary , debbuggerInfo . service !== undefined ) ;
88
+
89
+ if ( debbuggerInfo . certificate . remoteExists ) {
90
+ //Can't start the service without a certificate
91
+ addStartStopButtons ( "service" , summary , debbuggerInfo . service !== undefined ) ;
92
+ }
89
93
90
94
//Certificates summary
91
95
const certificatesMatch = certificateMatchStatus ( debbuggerInfo . certificate ) ;
@@ -103,7 +107,7 @@ export async function openDebugStatusPanel() {
103
107
</ul>` )
104
108
. addButtons (
105
109
! debbuggerInfo . certificate . remoteExists ? { id : `service.generateCertificate` , label : t ( "generate.certificate" ) } : undefined ,
106
- debbuggerInfo . certificate . remoteExists && config . debugIsSecure && ! certificatesMatch ? { id : `service.downloadCertificate` , label : t ( "download.certificate" ) } : undefined
110
+ debbuggerInfo . certificate . remoteExists && config . debugIsSecure && ! certificatesMatch && debbuggerInfo . service ?. job ? { id : `service.downloadCertificate` , label : t ( "download.certificate" ) } : undefined
107
111
) ;
108
112
109
113
const tabs = [ {
@@ -183,7 +187,7 @@ function handleAction(page: Page<DebuggerPage>) {
183
187
const actionParts = page . data ?. buttons ?. split ( '.' ) ;
184
188
const target = actionParts ?. at ( 0 ) ;
185
189
const action = actionParts ?. at ( 1 ) ;
186
- console . log ( target , action ) ;
190
+
187
191
if ( action ) {
188
192
let result ;
189
193
if ( target === "server" ) {
@@ -228,7 +232,16 @@ async function handleServiceAction(action: string): Promise<boolean> {
228
232
case "stop" :
229
233
return stop ( ) ;
230
234
case "generateCertificate" :
235
+ try {
236
+ await setup ( connection ) ;
237
+ return true ;
238
+ }
239
+ catch ( error : any ) {
240
+ vscode . window . showErrorMessage ( error ) ;
241
+ return false ;
242
+ }
231
243
case "downloadCertificate" :
244
+ return await vscode . commands . executeCommand ( `code-for-ibmi.debug.setup.local` ) ;
232
245
}
233
246
}
234
247
0 commit comments