feat(console): confirm removing filled editor rows

Filter conditions and groups, delivery targets, saved fragments and forge
hosts vanished on a single click, taking whatever had been typed with
them. Rows holding content now ask first, while empty, never-filled
rows (`isBlankNode`: default operator, no path, no values, not negated)
are still removed directly.
This commit is contained in:
翅膀 committed 2026-10-17 00:58:24 +08:00
1 parent 85f8cb74bc
commit 84fc63663e
8 files changed
+104 -12

No files matched your search

+15
View File
@@ -116,6 +116,21 @@ export function nodeFormToRouteFilters(nf: NodeForm): { filters: Filter[]; ast?:
return { filters: [], ast: ast ?? undefined };
}
/**
* Whether a node holds nothing worth confirming before it is removed: an
* untouched condition (default operator, no path, no values, not negated) or
* groups made only of those. A changed operator counts as content, since
* e.g. `exists` is a complete condition without values.
*/
export function isBlankNode(nf: NodeForm): boolean {
if (nf.kind === "leaf") {
const { exclude, op, path, values } = nf.leaf;
return !exclude && op === "eq" && !path.trim() && values.every((v) => !v.trim());
}
if (nf.kind === "all" || nf.kind === "any") return nf.children.every(isBlankNode);
return !nf.child || isBlankNode(nf.child);
}
export function collectEvents(node: FilterNode): string[] {
const out: string[] = [];
const walk = (n: FilterNode): void => {