refactor: move from union type to object enum

This commit is contained in:
2026-07-15 02:41:17 +05:00
parent 35465f581f
commit 84f64af62d
30 changed files with 490 additions and 193 deletions
+10 -9
View File
@@ -6,14 +6,17 @@ import { openTask } from "@/commands/openTask";
import { resolveTaskLocations } from "@/commands/resolveTaskLocations";
import { appError, AppErrorVariant } from "@/error";
import { TaskLocation } from "@/model/taskLocation";
import { TaskStatus } from "@/model/task";
import { IConfigProvider, ITaskRepository } from "@/ports";
import { TaskDashboardPanel } from "@/views/taskDashboardPanel";
import { TaskKanbanPanel } from "@/views/taskKanbanPanel";
import { TaskTreeProvider } from "@/views/taskTreeProvider";
import { presentError } from "./presentError";
import { resolveTaskRef } from "./resolveTaskRef";
import { TASK_SCOPE_LABELS, TASK_STATUS_LABELS, TASK_STATUS_ORDER } from "./taskLabels";
import {
TASK_SCOPE_LABELS,
TASK_STATUS_LABELS,
TASK_STATUS_ORDER,
} from "./taskLabels";
export type TaskCommandDeps = {
repo: ITaskRepository;
@@ -163,7 +166,7 @@ export async function runChangeStatus(
const picked = await vscode.window.showQuickPick(
TASK_STATUS_ORDER.map((value) => ({
label: TASK_STATUS_LABELS[value],
status: value as TaskStatus,
status: value,
})),
{ placeHolder: "New status" },
);
@@ -226,13 +229,11 @@ export function registerTaskCommands(
vscode.commands.registerCommand("xboctFlow.createTask", () =>
runCreateTask(deps),
),
vscode.commands.registerCommand(
"xboctFlow.openTask",
(item?: unknown) => runOpenTask(deps, item),
vscode.commands.registerCommand("xboctFlow.openTask", (item?: unknown) =>
runOpenTask(deps, item),
),
vscode.commands.registerCommand(
"xboctFlow.deleteTask",
(item?: unknown) => runDeleteTask(deps, item),
vscode.commands.registerCommand("xboctFlow.deleteTask", (item?: unknown) =>
runDeleteTask(deps, item),
),
vscode.commands.registerCommand(
"xboctFlow.changeStatus",
+24 -14
View File
@@ -1,22 +1,32 @@
import { TaskStatus } from "@/model/task";
import {
TASK_PRIORITY_META,
TASK_PRIORITY_ORDER,
type TaskPriority,
} from "@/model/taskPriority";
import {
TASK_STATUS_META,
TASK_STATUS_ORDER,
type TaskStatus,
} from "@/model/taskStatus";
import { TaskScope } from "@/model/taskLocation";
export const TASK_STATUS_ORDER: TaskStatus[] = [
"todo",
"in-progress",
"done",
"cancelled",
];
export { TASK_STATUS_ORDER, TASK_STATUS_META } from "@/model/taskStatus";
export { TASK_PRIORITY_ORDER, TASK_PRIORITY_META } from "@/model/taskPriority";
export const TASK_STATUS_LABELS: Record<TaskStatus, string> = {
todo: "To Do",
"in-progress": "In Progress",
done: "Done",
cancelled: "Cancelled",
};
export const TASK_STATUS_LABELS: Record<TaskStatus, string> =
Object.fromEntries(
TASK_STATUS_ORDER.map((status) => [status, TASK_STATUS_META[status].label]),
) as Record<TaskStatus, string>;
export const TASK_PRIORITY_LABELS: Record<TaskPriority, string> =
Object.fromEntries(
TASK_PRIORITY_ORDER.map((priority) => [
priority,
TASK_PRIORITY_META[priority].label,
]),
) as Record<TaskPriority, string>;
export const TASK_SCOPE_LABELS: Record<TaskScope, string> = {
project: "Project",
global: "Global",
};