(id: string, depth: number)
| 114 | const rows: TreeViewVisibleRow[] = []; |
| 115 | |
| 116 | const appendNode = (id: string, depth: number) => { |
| 117 | const node = nodesById.get(id); |
| 118 | if (node == null) { |
| 119 | return; |
| 120 | } |
| 121 | const childIds = node.childrenIds ?? []; |
| 122 | const hasChildren = node.isDirectory && (childIds.length > 0 || node.childrenStatus !== "loaded"); |
| 123 | const isExpanded = expandedIds.has(id); |
| 124 | rows.push({ |
| 125 | id, |
| 126 | parentId: node.parentId, |
| 127 | depth, |
| 128 | kind: "node", |
| 129 | label: normalizeLabel(node), |
| 130 | isDirectory: node.isDirectory, |
| 131 | isExpanded, |
| 132 | hasChildren, |
| 133 | icon: node.icon, |
| 134 | node, |
| 135 | }); |
| 136 | if (!isExpanded || !node.isDirectory) { |
| 137 | return; |
| 138 | } |
| 139 | const status = node.childrenStatus ?? "unloaded"; |
| 140 | if (status === "loading") { |
| 141 | rows.push({ |
| 142 | id: `${id}::__loading`, |
| 143 | parentId: id, |
| 144 | depth: depth + 1, |
| 145 | kind: "loading", |
| 146 | label: "Loading…", |
| 147 | }); |
| 148 | return; |
| 149 | } |
| 150 | if (status === "error") { |
| 151 | rows.push({ |
| 152 | id: `${id}::__error`, |
| 153 | parentId: id, |
| 154 | depth: depth + 1, |
| 155 | kind: "error", |
| 156 | label: node.staterror ? `Error: ${node.staterror}` : "Unable to load directory", |
| 157 | }); |
| 158 | return; |
| 159 | } |
| 160 | |
| 161 | const sortedChildren = sortIdsByNode(nodesById, childIds); |
| 162 | sortedChildren.forEach((childId) => appendNode(childId, depth + 1)); |
| 163 | if (status === "capped") { |
| 164 | const capMax = node.capInfo?.max ?? childIds.length; |
| 165 | rows.push({ |
| 166 | id: `${id}::__capped`, |
| 167 | parentId: id, |
| 168 | depth: depth + 1, |
| 169 | kind: "capped", |
| 170 | label: `Showing first ${capMax} entries`, |
| 171 | }); |
| 172 | } |
| 173 | }; |
no test coverage detected