Skip to content

Commit

Permalink
Added "Open service configuration" button
Browse files Browse the repository at this point in the history
Signed-off-by: Seb Julliand <[email protected]>
  • Loading branch information
sebjulliand committed Mar 27, 2024
1 parent 41e1331 commit a0f1007
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 24 deletions.
4 changes: 4 additions & 0 deletions src/api/debug/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,8 @@ export async function stopServer() {
}
}
return true;
}

export function getServiceConfigurationFile(){
return path.posix.join(serverDirectory, "DebugService.env");
}
3 changes: 2 additions & 1 deletion src/locale/ids/da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,5 +382,6 @@ export const da: Locale = {
'start.debug.service.failed': 'Failed to start debug service: {0}',
'stop.debug.service.task': 'Stopping debug service...',
'stop.debug.service.succeeded': 'Debug service stopped.',
'stop.debug.service.failed': 'Failed to stop debug service: {0}'
'stop.debug.service.failed': 'Failed to stop debug service: {0}',
'open.service.configuration': 'Open configuration'
};
3 changes: 2 additions & 1 deletion src/locale/ids/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,5 +382,6 @@ export const en: Locale = {
'start.debug.service.failed': 'Failed to start debug service: {0}',
'stop.debug.service.task': 'Stopping debug service...',
'stop.debug.service.succeeded': 'Debug service stopped.',
'stop.debug.service.failed': 'Failed to stop debug service: {0}'
'stop.debug.service.failed': 'Failed to stop debug service: {0}',
'open.service.configuration': 'Open configuration'
};
3 changes: 2 additions & 1 deletion src/locale/ids/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,5 +382,6 @@ export const fr: Locale = {
'start.debug.service.failed': 'Échec du démarrage du service de débogage: {0}',
'stop.debug.service.task': 'Arrêt du service de débogage...',
'stop.debug.service.succeeded': 'Service de débogage arrêté.',
'stop.debug.service.failed': 'Échec de l\'arrêt du service de débogage: {0}'
'stop.debug.service.failed': 'Échec de l\'arrêt du service de débogage: {0}',
'open.service.configuration': 'Ouvrir la configuration'
};
45 changes: 24 additions & 21 deletions src/webviews/debugger/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { readFileSync } from "fs";
import vscode from "vscode";
import { CustomUI, Field, Page, Section } from "../../api/CustomUI";
import { Button, CustomUI, Field, Page, Section } from "../../api/CustomUI";
import IBMiContent from "../../api/IBMiContent";
import { Tools } from "../../api/Tools";
import { isManaged } from "../../api/debug";
import { getLocalCertPath, getRemoteCertificateDirectory, localClientCertExists, readRemoteCertificate, remoteServerCertificateExists, setup } from "../../api/debug/certificates";
import { DebugJob, getDebugServerJob, getDebugServiceJob, startServer, startService, stopServer, stopService } from "../../api/debug/server";
import { DebugJob, getDebugServerJob, getDebugServiceJob, getServiceConfigurationFile, startServer, startService, stopServer, stopService } from "../../api/debug/server";
import { instance } from "../../instantiate";
import { t } from "../../locale";

Expand Down Expand Up @@ -69,27 +69,27 @@ export async function openDebugStatusPanel() {
<li>${t("listening.on.port")}: ${debbuggerInfo.server.job.port}</li>`
: ""
}
</ul>`);
addStartStopButtons("server", summary, debbuggerInfo.server !== undefined);
</ul>`)
.addButtons(...getStartStopButtons("server", debbuggerInfo.server !== undefined))

//Debug Service summary
summary.addHorizontalRule()
//Debug Service summary
.addHorizontalRule()
.addParagraph(/* html */`
<h4>${t("debug.service")} ${debbuggerInfo.service ? "✅" : "❌"}</h4>
<ul>
<li>${t("status")}: ${debbuggerInfo.service ? t("online") : t("offline")} </li>
${debbuggerInfo.service ? /* html */ `
<li>${t("job")}: ${debbuggerInfo.service.job.name}</li>
<li>${t("listening.on.port")}: ${debbuggerInfo.service.job.port}</li>
`
<h4>${t("debug.service")} ${debbuggerInfo.service ? "✅" : "❌"}</h4>
<ul>
<li>${t("status")}: ${debbuggerInfo.service ? t("online") : t("offline")} </li>
${debbuggerInfo.service ? /* html */ `
<li>${t("job")}: ${debbuggerInfo.service.job.name}</li>
<li>${t("listening.on.port")}: ${debbuggerInfo.service.job.port}</li>
`
: ""
}
</ul>`);
</ul>`)

if (debbuggerInfo.certificate.remoteExists) {
//Can't start the service without a certificate
addStartStopButtons("service", summary, debbuggerInfo.service !== undefined);
}
.addButtons(
...(debbuggerInfo.certificate.remoteExists ? getStartStopButtons("service", debbuggerInfo.service !== undefined) : []),
{ id: "service.openConfig", label: t("open.service.configuration") }
);

//Certificates summary
const certificatesMatch = certificateMatchStatus(debbuggerInfo.certificate);
Expand Down Expand Up @@ -139,12 +139,12 @@ export async function openDebugStatusPanel() {
}
}

function addStartStopButtons(target: "server" | "service", section: Section, running: boolean) {
section.addButtons(
function getStartStopButtons(target: "server" | "service", running: boolean): (Button | undefined)[] {
return [
running ? undefined : { id: `${target}.start`, label: t("start") },
running ? { id: `${target}.restart`, label: t("restart") } : undefined,
running ? { id: `${target}.stop`, label: t("stop") } : undefined
);
];
}

async function readActiveJob(content: IBMiContent, job: DebugJob) {
Expand Down Expand Up @@ -242,6 +242,9 @@ async function handleServiceAction(action: string): Promise<boolean> {
}
case "downloadCertificate":
return await vscode.commands.executeCommand(`code-for-ibmi.debug.setup.local`);
case "openConfig":
vscode.commands.executeCommand("code-for-ibmi.openEditable", getServiceConfigurationFile());
return false;
}
}

Expand Down

0 comments on commit a0f1007

Please sign in to comment.