({
entry,
rowKey,
namespace,
protocol,
rootPath,
backendType,
depth,
locale,
searchValue,
onOpenFile,
})
| 406 | searchValue: string; |
| 407 | onOpenFile: (info: OpenFileInfo) => void; |
| 408 | }> = ({ |
| 409 | entry, |
| 410 | rowKey, |
| 411 | namespace, |
| 412 | protocol, |
| 413 | rootPath, |
| 414 | backendType, |
| 415 | depth, |
| 416 | locale, |
| 417 | searchValue, |
| 418 | onOpenFile, |
| 419 | }) => { |
| 420 | const [isExpanded, setIsExpanded] = useState(false); |
| 421 | const { entriesByPath } = useStorage(); |
| 422 | const addCodeToNewCell = useAddCodeToNewCell(); |
| 423 | const isDir = entry.kind === "directory"; |
| 424 | const name = displayName(entry.path); |
| 425 | const hasSearch = !!searchValue.trim(); |
| 426 | |
| 427 | const selfMatches = |
| 428 | isDir && |
| 429 | hasSearch && |
| 430 | name.toLowerCase().includes(searchValue.trim().toLowerCase()); |
| 431 | |
| 432 | // During a search, auto-expand directories whose loaded descendants match |
| 433 | const hasMatchingDescendants = |
| 434 | isDir && |
| 435 | hasSearch && |
| 436 | !!entriesByPath |
| 437 | .get(storagePathKey(namespace, directoryPrefix(entry.path))) |
| 438 | ?.some((child) => |
| 439 | entryMatchesSearch(child, { namespace, searchValue, entriesByPath }), |
| 440 | ); |
| 441 | |
| 442 | // Folder is shown expanded by manual toggle OR by search auto-expand |
| 443 | const effectiveExpanded = isExpanded || hasMatchingDescendants; |
| 444 | |
| 445 | const handleDownload = useCallback(async () => { |
| 446 | try { |
| 447 | const result = await DownloadStorage.request({ |
| 448 | namespace, |
| 449 | path: entry.path, |
| 450 | }); |
| 451 | if (result.error) { |
| 452 | toast({ |
| 453 | title: "Download failed", |
| 454 | description: result.error, |
| 455 | variant: "danger", |
| 456 | }); |
| 457 | return; |
| 458 | } |
| 459 | if (result.url) { |
| 460 | downloadByURL(result.url, result.filename ?? "download"); |
| 461 | } |
| 462 | } catch (error) { |
| 463 | Logger.error("Failed to download storage entry", error); |
| 464 | toast({ |
| 465 | title: "Download failed", |
nothing calls this directly
no test coverage detected
searching dependent graphs…