fix: skip unknown status and priority on edit
This commit is contained in:
@@ -10,6 +10,11 @@ export type TaskPriority = (typeof TaskPriority)[keyof typeof TaskPriority];
|
||||
|
||||
export type TaskPriorityMeta = {
|
||||
label: string;
|
||||
/**
|
||||
* Fallback value assigned when the parsed priority is invalid/missing.
|
||||
* Excluded from editing choices.
|
||||
*/
|
||||
fallback?: boolean;
|
||||
};
|
||||
|
||||
/** Explicit order for filters / grouping (critical → low → unknown). */
|
||||
@@ -26,7 +31,7 @@ export const TASK_PRIORITY_META: Record<TaskPriority, TaskPriorityMeta> = {
|
||||
[TaskPriority.HIGH]: { label: "High" },
|
||||
[TaskPriority.MEDIUM]: { label: "Medium" },
|
||||
[TaskPriority.LOW]: { label: "Low" },
|
||||
[TaskPriority.UNKNOWN]: { label: "Unknown" },
|
||||
[TaskPriority.UNKNOWN]: { label: "Unknown", fallback: true },
|
||||
};
|
||||
|
||||
export function isTaskPriority(value: unknown): value is TaskPriority {
|
||||
|
||||
@@ -15,6 +15,11 @@ export type TaskStatusMeta = {
|
||||
defaultHidden: boolean;
|
||||
/** Codicon id for tree; adapters wrap in ThemeIcon. */
|
||||
icon: string;
|
||||
/**
|
||||
* Fallback value assigned when the parsed status is invalid/missing.
|
||||
* Excluded from editing choices; hidden in tree when empty.
|
||||
*/
|
||||
fallback?: boolean;
|
||||
};
|
||||
|
||||
/** Explicit display / column order (not Object.values). */
|
||||
@@ -57,6 +62,7 @@ export const TASK_STATUS_META: Record<TaskStatus, TaskStatusMeta> = {
|
||||
label: "Unknown",
|
||||
defaultHidden: true,
|
||||
icon: "question",
|
||||
fallback: true,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import * as vscode from "vscode";
|
||||
import { addProjectTag } from "@/commands/addProjectTag";
|
||||
import { loadProjectConfig } from "@/commands/loadProjectConfig";
|
||||
import { resolveTaskLocations } from "@/commands/resolveTaskLocations";
|
||||
@@ -16,13 +15,16 @@ import {
|
||||
TASK_LANGUAGE_ID,
|
||||
} from "@/model/taskFile";
|
||||
import { IConfigProvider, IFileSystem } from "@/ports";
|
||||
import * as vscode from "vscode";
|
||||
import { getGitUserName, yamlInlineScalar } from "./getGitUserName";
|
||||
import { presentError } from "./presentError";
|
||||
import { resolveTaskFolderForPath } from "./resolveTaskFolder";
|
||||
import {
|
||||
TASK_PRIORITY_LABELS,
|
||||
TASK_PRIORITY_META,
|
||||
TASK_PRIORITY_ORDER,
|
||||
TASK_STATUS_LABELS,
|
||||
TASK_STATUS_META,
|
||||
TASK_STATUS_ORDER,
|
||||
} from "./taskLabels";
|
||||
|
||||
@@ -115,7 +117,9 @@ export async function runEditTaskStatus(uriArg?: string): Promise<void> {
|
||||
}
|
||||
|
||||
const picked = await vscode.window.showQuickPick(
|
||||
TASK_STATUS_ORDER.map((status) => ({
|
||||
TASK_STATUS_ORDER.filter(
|
||||
(status) => !TASK_STATUS_META[status].fallback,
|
||||
).map((status) => ({
|
||||
label: TASK_STATUS_LABELS[status],
|
||||
description: status,
|
||||
status,
|
||||
@@ -137,7 +141,9 @@ export async function runEditTaskPriority(uriArg?: string): Promise<void> {
|
||||
}
|
||||
|
||||
const picked = await vscode.window.showQuickPick(
|
||||
TASK_PRIORITY_ORDER.map((priority) => ({
|
||||
TASK_PRIORITY_ORDER.filter(
|
||||
(priority) => !TASK_PRIORITY_META[priority].fallback,
|
||||
).map((priority) => ({
|
||||
label: TASK_PRIORITY_LABELS[priority],
|
||||
description: priority,
|
||||
priority,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import * as vscode from "vscode";
|
||||
import { listLocatedTasks } from "@/commands/listLocatedTasks";
|
||||
import { resolveTaskLocations } from "@/commands/resolveTaskLocations";
|
||||
import { Task } from "@/model/task";
|
||||
@@ -10,6 +9,7 @@ import {
|
||||
} from "@/model/taskStatus";
|
||||
import { IConfigProvider, ITaskRepository } from "@/ports";
|
||||
import { TASK_SCOPE_LABELS, TASK_STATUS_LABELS } from "@/ui/taskLabels";
|
||||
import * as vscode from "vscode";
|
||||
import { TaskTreeItem } from "./taskTreeItem";
|
||||
|
||||
class ScopeTreeItem extends vscode.TreeItem {
|
||||
@@ -119,7 +119,10 @@ export class TaskTreeProvider implements vscode.TreeDataProvider<vscode.TreeItem
|
||||
|
||||
private getStatusGroups(scope: ScopeTreeItem): vscode.TreeItem[] {
|
||||
const tasks = scope.locatedTasks.map((item) => item.task);
|
||||
return TASK_STATUS_ORDER.map((status) => {
|
||||
return TASK_STATUS_ORDER.filter((status) => {
|
||||
const groupTasks = tasks.filter((t) => t.status === status);
|
||||
return !(groupTasks.length === 0 && TASK_STATUS_META[status].fallback);
|
||||
}).map((status) => {
|
||||
const groupTasks = tasks.filter((t) => t.status === status);
|
||||
return new TaskGroupTreeItem(status, scope.location, groupTasks);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user