Fix review findings in file picker

This commit is contained in:
“Naeel”
2026-09-05 10:00:14 +03:00
parent 6fea5bce49
commit 8f775e34a9
6 changed files with 67 additions and 19 deletions
+5 -5
View File
@@ -9,9 +9,9 @@ function renderNode(node, depth) {
? `<button class="tree-name tree-group tree-${node.kind}" style="padding-left:${padding}ch" data-toggle="${node.id}" `
+ `aria-expanded="${node.expanded}"><span class="tree-chevron">${node.expanded ? '▼' : '▶'}</span>${name}</button>`
: `<span class="tree-name" style="padding-left:${padding}ch">${name}</span>`;
const indent = isGroup ? '' : ` style="padding-left:${padding}ch"`;
const remove = `<button class="remove-btn" type="button" data-remove="${node.id}" aria-label="Удалить ${name}">×</button>`;
const row = `<tr class="tree-row tree-${node.kind}"><td${indent}>${action}</td>`
const pathAttribute = node.kind === 'file' ? ` data-path="${esc(node.path)}"` : '';
const row = `<tr class="tree-row tree-${node.kind}"${pathAttribute}><td>${action}</td>`
+ `<td>${node.kind === 'file' ? fs(node.file.size) : ''}</td>`
+ `<td>${node.error ? esc(node.error) : node.kind === 'file' ? 'готов' : ''}</td><td>${remove}</td></tr>`;
if (!isGroup || !node.expanded) return row;
@@ -31,10 +31,10 @@ export function render(state, elements) {
elements.countEl.textContent = `${files.length} файлов · ${fs(files.reduce((sum, node) => sum + node.file.size, 0))}`;
}
export function findNode(nodes, id, parent = null) {
export function findNode(nodes, id) {
for (const node of nodes) {
if (node.id === id) return { node, parent, nodes };
const found = findNode(node.children || [], id, node);
if (node.id === id) return { node, nodes };
const found = findNode(node.children || [], id);
if (found) return found;
}
return null;