AppsTree
The apps in the codebase, as a launcher: each app's status, and starting, stopping and opening it. What an app is made of is in the Codebase view (grouped by role) and the Data view; only problems that would stop it building are listed here.
import { running as running_1, session } from "#codebase/tcmts/vscode/extension"; import type { AppEntry, AppNode, RunningApp } from "#codebase/tcmts/vscode/extension"; import * as vscode from "vscode"; export class AppsTree implements vscode.TreeDataProvider<AppNode> { running: Map<string, RunningApp>; changed = new vscode.EventEmitter<AppNode | undefined | void>(); onDidChangeTreeData = this.changed.event; constructor(running: Map<string, RunningApp>) { this.running = running; } refresh() { this.changed.fire(); } async getChildren(element?: AppNode): Promise<AppNode[]> { if (!running_1()) return []; if (!element) return ((await session.client!.sendRequest("tcm/apps", {})) as AppEntry[]).map((a) => ({ ...a, kind: "app" as const })); return element.kind === "app" ? element.errors.map((label) => ({ kind: "problem" as const, label })) : []; } getTreeItem(e: AppNode): vscode.TreeItem { if (e.kind === "problem") { const item = new vscode.TreeItem(e.label); item.iconPath = new vscode.ThemeIcon("error", new vscode.ThemeColor("errorForeground")); item.tooltip = e.label; return item; } const run = this.running.get(e.path); const item = new vscode.TreeItem(e.path, e.errors.length ? vscode.TreeItemCollapsibleState.Expanded : vscode.TreeItemCollapsibleState.None); item.id = `app:${e.path}`; item.description = run?.url ? run.url : run ? "starting…" : e.errors.length ? `${e.errors.length} problem${e.errors.length > 1 ? "s" : ""}` : ""; item.iconPath = new vscode.ThemeIcon(run ? "debug-start" : "rocket", run?.url ? new vscode.ThemeColor("testing.iconPassed") : undefined); item.contextValue = run ? "app.running" : "app.stopped"; item.tooltip = new vscode.MarkdownString( `**${e.path}**${run?.url ? ` — running at ${run.url}` : ""}\n\n${e.endpoints.length} endpoint(s), ${e.browser.length} browser definition(s), ` + `${e.tables.length} table(s), ${e.schedules.length} recurring job(s). Its parts are in the Codebase and Data views.`, ); // clicking an app opens its page; running it, opening it and its source are its actions item.command = { command: "tcm.openPage", title: "Open page", arguments: [e.path] }; return item; } }
uses
- tcmts.vscode.extension.AppEntry
- tcmts.vscode.extension.AppNode
- tcmts.vscode.extension.RunningApp
- tcmts.vscode.extension.running
- tcmts.vscode.extension.session