feat: add dashboard ui view
This commit is contained in:
+20
-5
@@ -4,6 +4,7 @@ import { FsTaskRepository } from "@/storage/FsTaskRepository";
|
||||
import { NodeFileSystem } from "@/storage/NodeFileSystem";
|
||||
import { VscodeConfigProvider } from "@/storage/VscodeConfigProvider";
|
||||
import { registerTaskCommands } from "@/ui/taskCommands";
|
||||
import { TaskDashboardPanel } from "@/views/taskDashboardPanel";
|
||||
import { TaskTreeProvider } from "@/views/taskTreeProvider";
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
@@ -12,6 +13,11 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
const repo = new FsTaskRepository(fileSystem, config.getFileExtension());
|
||||
const tree = new TaskTreeProvider(repo, config);
|
||||
|
||||
const onTasksMutated = (): void => {
|
||||
tree.refresh();
|
||||
TaskDashboardPanel.refreshIfOpen();
|
||||
};
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.window.registerTreeDataProvider("projectTasks.tasks", tree),
|
||||
);
|
||||
@@ -21,9 +27,9 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
const ext = config.getFileExtension();
|
||||
const taskPattern = path.join(projectPath, `*${ext}`).replace(/\\/g, "/");
|
||||
const watcher = vscode.workspace.createFileSystemWatcher(taskPattern);
|
||||
watcher.onDidCreate(() => tree.refresh());
|
||||
watcher.onDidChange(() => tree.refresh());
|
||||
watcher.onDidDelete(() => tree.refresh());
|
||||
watcher.onDidCreate(onTasksMutated);
|
||||
watcher.onDidChange(onTasksMutated);
|
||||
watcher.onDidDelete(onTasksMutated);
|
||||
context.subscriptions.push(watcher);
|
||||
}
|
||||
|
||||
@@ -36,11 +42,20 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
statusBarItem.show();
|
||||
context.subscriptions.push(statusBarItem);
|
||||
|
||||
registerTaskCommands(context, { repo, config, tree });
|
||||
registerTaskCommands(context, {
|
||||
repo,
|
||||
config,
|
||||
tree,
|
||||
onTasksMutated: () => TaskDashboardPanel.refreshIfOpen(),
|
||||
});
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand("projectTasks.openDashboard", () => {
|
||||
void vscode.window.showInformationMessage("Dashboard coming soon!");
|
||||
TaskDashboardPanel.show({
|
||||
repo,
|
||||
config,
|
||||
onTasksMutated: () => tree.refresh(),
|
||||
});
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user