Skip to content

Commit 1e84547

Browse files
committed
Added Generate and Import certificate to dashboard
Signed-off-by: Seb Julliand <[email protected]>
1 parent c742db5 commit 1e84547

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/api/debug/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ export async function initialize(context: ExtensionContext) {
319319
copyFileSync(selectedFile[0].fsPath, certificates.getLocalCertPath(connection));
320320
localCertsOk = true;
321321
vscode.window.showInformationMessage(`Certificate imported.`);
322+
return true;
322323
}
323324
}
324325
}
@@ -340,6 +341,7 @@ export async function initialize(context: ExtensionContext) {
340341
vscode.window.showErrorMessage(`Debug PTF not installed.`);
341342
}
342343
}
344+
return false;
343345
}),
344346

345347
vscode.commands.registerCommand(`code-for-ibmi.debug.start`, async () => {

src/webviews/debugger/index.ts

+17-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { CustomUI, Field, Page, Section } from "../../api/CustomUI";
44
import IBMiContent from "../../api/IBMiContent";
55
import { Tools } from "../../api/Tools";
66
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";
88
import { DebugJob, getDebugServerJob, getDebugServiceJob, startServer, startService, stopServer, stopService } from "../../api/debug/server";
99
import { instance } from "../../instantiate";
1010
import { t } from "../../locale";
@@ -85,7 +85,11 @@ export async function openDebugStatusPanel() {
8585
: ""
8686
}
8787
</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+
}
8993

9094
//Certificates summary
9195
const certificatesMatch = certificateMatchStatus(debbuggerInfo.certificate);
@@ -103,7 +107,7 @@ export async function openDebugStatusPanel() {
103107
</ul>`)
104108
.addButtons(
105109
!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
107111
);
108112

109113
const tabs = [{
@@ -183,7 +187,7 @@ function handleAction(page: Page<DebuggerPage>) {
183187
const actionParts = page.data?.buttons?.split('.');
184188
const target = actionParts?.at(0);
185189
const action = actionParts?.at(1);
186-
console.log(target, action);
190+
187191
if (action) {
188192
let result;
189193
if (target === "server") {
@@ -228,7 +232,16 @@ async function handleServiceAction(action: string): Promise<boolean> {
228232
case "stop":
229233
return stop();
230234
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+
}
231243
case "downloadCertificate":
244+
return await vscode.commands.executeCommand(`code-for-ibmi.debug.setup.local`);
232245
}
233246
}
234247

0 commit comments

Comments
 (0)