feat: add buttons - open task in dashboard, open dashboard
This commit is contained in:
@@ -23,6 +23,11 @@ export type TaskDashboardDeps = {
|
||||
onTasksMutated?: () => void;
|
||||
};
|
||||
|
||||
export type TaskDashboardShowOptions = {
|
||||
/** Pre-select this task after load (e.g. open from tree). */
|
||||
selectedId?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Host adapter for the Task Dashboard webview.
|
||||
* Owns panel lifecycle and message wiring; business rules stay in use-cases.
|
||||
@@ -30,16 +35,23 @@ export type TaskDashboardDeps = {
|
||||
export class TaskDashboardPanel {
|
||||
static #current: TaskDashboardPanel | undefined;
|
||||
|
||||
static show(deps: TaskDashboardDeps): void {
|
||||
static show(
|
||||
deps: TaskDashboardDeps,
|
||||
options: TaskDashboardShowOptions = {},
|
||||
): void {
|
||||
if (TaskDashboardPanel.#current) {
|
||||
TaskDashboardPanel.#current.#panel.reveal(vscode.ViewColumn.One);
|
||||
void TaskDashboardPanel.#current.reloadTasks();
|
||||
const current = TaskDashboardPanel.#current;
|
||||
if (options.selectedId !== undefined) {
|
||||
current.#selectedId = options.selectedId;
|
||||
}
|
||||
current.#panel.reveal(vscode.ViewColumn.One);
|
||||
void current.reloadTasks();
|
||||
return;
|
||||
}
|
||||
|
||||
const panel = vscode.window.createWebviewPanel(
|
||||
"xboctFlow.dashboard",
|
||||
"Task Dashboard",
|
||||
"XBOCT flow",
|
||||
vscode.ViewColumn.One,
|
||||
{
|
||||
enableScripts: true,
|
||||
@@ -47,7 +59,11 @@ export class TaskDashboardPanel {
|
||||
},
|
||||
);
|
||||
|
||||
TaskDashboardPanel.#current = new TaskDashboardPanel(panel, deps);
|
||||
TaskDashboardPanel.#current = new TaskDashboardPanel(
|
||||
panel,
|
||||
deps,
|
||||
options.selectedId,
|
||||
);
|
||||
}
|
||||
|
||||
static refreshIfOpen(): void {
|
||||
@@ -63,9 +79,14 @@ export class TaskDashboardPanel {
|
||||
#selectedId: string | undefined;
|
||||
#disposed = false;
|
||||
|
||||
constructor(panel: vscode.WebviewPanel, deps: TaskDashboardDeps) {
|
||||
constructor(
|
||||
panel: vscode.WebviewPanel,
|
||||
deps: TaskDashboardDeps,
|
||||
selectedId?: string,
|
||||
) {
|
||||
this.#panel = panel;
|
||||
this.#deps = deps;
|
||||
this.#selectedId = selectedId;
|
||||
|
||||
const nonce = createNonce();
|
||||
this.#panel.webview.html = getTaskDashboardHtml(this.#panel.webview, nonce);
|
||||
@@ -140,6 +161,11 @@ export class TaskDashboardPanel {
|
||||
case "saveDescription":
|
||||
await this.#saveDescription(message.id, message.description);
|
||||
return;
|
||||
|
||||
case "createTask":
|
||||
await vscode.commands.executeCommand("xboctFlow.createTask");
|
||||
await this.reloadTasks();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user