test: update tests, add eslint rules
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import * as vscode from "vscode";
|
||||
import { Task, TaskStatus } from "@/model/task";
|
||||
import { IConfigProvider, ITaskRepository } from "@/ports";
|
||||
import * as vscode from "vscode";
|
||||
|
||||
const STATUS_ORDER: TaskStatus[] = ["todo", "in-progress", "done", "cancelled"];
|
||||
|
||||
@@ -12,30 +12,32 @@ const STATUS_ICONS: Record<TaskStatus, vscode.ThemeIcon> = {
|
||||
};
|
||||
|
||||
class TaskGroupTreeItem extends vscode.TreeItem {
|
||||
constructor(
|
||||
label: string,
|
||||
public readonly tasks: Task[],
|
||||
icon: vscode.ThemeIcon,
|
||||
) {
|
||||
readonly tasks: Task[];
|
||||
|
||||
constructor(label: string, tasks: Task[], icon: vscode.ThemeIcon) {
|
||||
super(label, vscode.TreeItemCollapsibleState.Collapsed);
|
||||
this.iconPath = icon;
|
||||
this.tasks = tasks;
|
||||
this.description = `(${tasks.length})`;
|
||||
}
|
||||
}
|
||||
|
||||
export class TaskTreeProvider implements vscode.TreeDataProvider<vscode.TreeItem> {
|
||||
private _onDidChangeTreeData = new vscode.EventEmitter<
|
||||
#onDidChangeTreeData = new vscode.EventEmitter<
|
||||
vscode.TreeItem | undefined | null | void
|
||||
>();
|
||||
readonly onDidChangeTreeData = this._onDidChangeTreeData.event;
|
||||
readonly onDidChangeTreeData = this.#onDidChangeTreeData.event;
|
||||
|
||||
constructor(
|
||||
private taskStore: ITaskRepository,
|
||||
private configStore: IConfigProvider,
|
||||
) {}
|
||||
#taskStore: ITaskRepository;
|
||||
#configStore: IConfigProvider;
|
||||
|
||||
constructor(taskStore: ITaskRepository, configStore: IConfigProvider) {
|
||||
this.#taskStore = taskStore;
|
||||
this.#configStore = configStore;
|
||||
}
|
||||
|
||||
refresh(): void {
|
||||
this._onDidChangeTreeData.fire();
|
||||
this.#onDidChangeTreeData.fire();
|
||||
}
|
||||
|
||||
getTreeItem(element: vscode.TreeItem): vscode.TreeItem {
|
||||
@@ -50,19 +52,23 @@ export class TaskTreeProvider implements vscode.TreeDataProvider<vscode.TreeItem
|
||||
}
|
||||
|
||||
private async getRootChildren(): Promise<vscode.TreeItem[]> {
|
||||
const projectPath = this.configStore.getProjectTaskPath();
|
||||
const projectPath = this.#configStore.getProjectTaskPath();
|
||||
if (!projectPath) {
|
||||
return [new vscode.TreeItem("Open a workspace folder to start")];
|
||||
}
|
||||
|
||||
const tasks = await this.taskStore.list(projectPath);
|
||||
const tasks = await this.#taskStore.list(projectPath);
|
||||
|
||||
return STATUS_ORDER.map((status) => {
|
||||
const groupTasks = tasks.filter((t) => t.status === status);
|
||||
const label = status === "todo" ? "To Do"
|
||||
: status === "in-progress" ? "In Progress"
|
||||
: status === "done" ? "Done"
|
||||
: "Cancelled";
|
||||
const label =
|
||||
status === "todo"
|
||||
? "To Do"
|
||||
: status === "in-progress"
|
||||
? "In Progress"
|
||||
: status === "done"
|
||||
? "Done"
|
||||
: "Cancelled";
|
||||
const item = new TaskGroupTreeItem(
|
||||
label,
|
||||
groupTasks,
|
||||
|
||||
Reference in New Issue
Block a user