|
1 | 1 | import { readFileSync } from "fs";
|
2 | 2 | import vscode from "vscode";
|
3 |
| -import { CustomUI, Field, Page, Section } from "../../api/CustomUI"; |
| 3 | +import { Button, 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 | 7 | import { getLocalCertPath, getRemoteCertificateDirectory, localClientCertExists, readRemoteCertificate, remoteServerCertificateExists, setup } from "../../api/debug/certificates";
|
8 |
| -import { DebugJob, getDebugServerJob, getDebugServiceJob, startServer, startService, stopServer, stopService } from "../../api/debug/server"; |
| 8 | +import { DebugJob, getDebugServerJob, getDebugServiceJob, getServiceConfigurationFile, startServer, startService, stopServer, stopService } from "../../api/debug/server"; |
9 | 9 | import { instance } from "../../instantiate";
|
10 | 10 | import { t } from "../../locale";
|
11 | 11 |
|
@@ -69,27 +69,27 @@ export async function openDebugStatusPanel() {
|
69 | 69 | <li>${t("listening.on.port")}: ${debbuggerInfo.server.job.port}</li>`
|
70 | 70 | : ""
|
71 | 71 | }
|
72 |
| - </ul>`); |
73 |
| - addStartStopButtons("server", summary, debbuggerInfo.server !== undefined); |
| 72 | + </ul>`) |
| 73 | + .addButtons(...getStartStopButtons("server", debbuggerInfo.server !== undefined)) |
74 | 74 |
|
75 |
| - //Debug Service summary |
76 |
| - summary.addHorizontalRule() |
| 75 | + //Debug Service summary |
| 76 | + .addHorizontalRule() |
77 | 77 | .addParagraph(/* html */`
|
78 |
| - <h4>${t("debug.service")} ${debbuggerInfo.service ? "✅" : "❌"}</h4> |
79 |
| - <ul> |
80 |
| - <li>${t("status")}: ${debbuggerInfo.service ? t("online") : t("offline")} </li> |
81 |
| - ${debbuggerInfo.service ? /* html */ ` |
82 |
| - <li>${t("job")}: ${debbuggerInfo.service.job.name}</li> |
83 |
| - <li>${t("listening.on.port")}: ${debbuggerInfo.service.job.port}</li> |
84 |
| - ` |
| 78 | + <h4>${t("debug.service")} ${debbuggerInfo.service ? "✅" : "❌"}</h4> |
| 79 | + <ul> |
| 80 | + <li>${t("status")}: ${debbuggerInfo.service ? t("online") : t("offline")} </li> |
| 81 | + ${debbuggerInfo.service ? /* html */ ` |
| 82 | + <li>${t("job")}: ${debbuggerInfo.service.job.name}</li> |
| 83 | + <li>${t("listening.on.port")}: ${debbuggerInfo.service.job.port}</li> |
| 84 | + ` |
85 | 85 | : ""
|
86 | 86 | }
|
87 |
| - </ul>`); |
| 87 | + </ul>`) |
88 | 88 |
|
89 |
| - if (debbuggerInfo.certificate.remoteExists) { |
90 |
| - //Can't start the service without a certificate |
91 |
| - addStartStopButtons("service", summary, debbuggerInfo.service !== undefined); |
92 |
| - } |
| 89 | + .addButtons( |
| 90 | + ...(debbuggerInfo.certificate.remoteExists ? getStartStopButtons("service", debbuggerInfo.service !== undefined) : []), |
| 91 | + { id: "service.openConfig", label: t("open.service.configuration") } |
| 92 | + ); |
93 | 93 |
|
94 | 94 | //Certificates summary
|
95 | 95 | const certificatesMatch = certificateMatchStatus(debbuggerInfo.certificate);
|
@@ -139,12 +139,12 @@ export async function openDebugStatusPanel() {
|
139 | 139 | }
|
140 | 140 | }
|
141 | 141 |
|
142 |
| -function addStartStopButtons(target: "server" | "service", section: Section, running: boolean) { |
143 |
| - section.addButtons( |
| 142 | +function getStartStopButtons(target: "server" | "service", running: boolean): (Button | undefined)[] { |
| 143 | + return [ |
144 | 144 | running ? undefined : { id: `${target}.start`, label: t("start") },
|
145 | 145 | running ? { id: `${target}.restart`, label: t("restart") } : undefined,
|
146 | 146 | running ? { id: `${target}.stop`, label: t("stop") } : undefined
|
147 |
| - ); |
| 147 | + ]; |
148 | 148 | }
|
149 | 149 |
|
150 | 150 | async function readActiveJob(content: IBMiContent, job: DebugJob) {
|
@@ -242,6 +242,9 @@ async function handleServiceAction(action: string): Promise<boolean> {
|
242 | 242 | }
|
243 | 243 | case "downloadCertificate":
|
244 | 244 | return await vscode.commands.executeCommand(`code-for-ibmi.debug.setup.local`);
|
| 245 | + case "openConfig": |
| 246 | + vscode.commands.executeCommand("code-for-ibmi.openEditable", getServiceConfigurationFile()); |
| 247 | + return false; |
245 | 248 | }
|
246 | 249 | }
|
247 | 250 |
|
|
0 commit comments