Fully autonomous AI Agents system capable of performing complex penetration testing tasks
Go ai-agentsai-security-toolanthropicautonomous-agentsgolanggptgraphqlmulti-agent-systemoffensive-securityopen-sourceopenaipenetration-testingpenetration-testing-toolsreactsecurity-automationsecurity-testingsecurity-toolsself-hosted
feat(file-manager): expand/collapse all toggle in header
Sergey Kozyrenkod97b355ce2a8
diff --git a/frontend/src/components/shared/file-manager/file-manager-skeleton.tsx b/frontend/src/components/shared/file-manager/file-manager-skeleton.tsxindex 8ae2e5e0..584e1785 100644--- a/frontend/src/components/shared/file-manager/file-manager-skeleton.tsx+++ b/frontend/src/components/shared/file-manager/file-manager-skeleton.tsx@@ -53,7 +53,10 @@ export const FileManagerSkeleton = ({className="size-4"/>)}- <Skeleton className="h-3 w-12" />+ <div className="flex items-center gap-1.5">+ <Skeleton className="size-4 shrink-0 rounded-sm" />+ <Skeleton className="h-3 w-12" />+ </div>{isSizeVisible && <Skeleton className="h-3 w-10" />}{isModifiedVisible && <Skeleton className="h-3 w-16" />}{hasActions && (diff --git a/frontend/src/components/shared/file-manager/file-manager-types.ts b/frontend/src/components/shared/file-manager/file-manager-types.tsindex 23ad33e8..4124cd6c 100644--- a/frontend/src/components/shared/file-manager/file-manager-types.ts+++ b/frontend/src/components/shared/file-manager/file-manager-types.ts@@ -139,9 +139,13 @@ export interface FileManagerLabels {bulkCancel?: string;/** Trigger label / aria-label for the trailing overflow `…` menu in the bulk bar. */bulkMoreActions?: string;+ /** aria-label for the header "expand/collapse all" toggle when the tree is fully expanded. */+ collapseAllAriaLabel?: string;columnModified?: string;columnName?: string;columnSize?: string;+ /** aria-label for the header "expand/collapse all" toggle when at least one directory is collapsed. */+ expandAllAriaLabel?: string;/*** Custom formatter for the "Modified" column. Receives the raw `modifiedAt`* and must return a display string (or empty string for no value). When omitted,diff --git a/frontend/src/components/shared/file-manager/file-manager.tsx b/frontend/src/components/shared/file-manager/file-manager.tsxindex 9d52858e..7615db5c 100644--- a/frontend/src/components/shared/file-manager/file-manager.tsx+++ b/frontend/src/components/shared/file-manager/file-manager.tsx@@ -1,4 +1,4 @@-import { ArrowDown, ArrowUp } from 'lucide-react';+import { ArrowDown, ArrowUp, ChevronRight } from 'lucide-react';import {type MouseEvent as ReactMouseEvent,type ReactNode,@@ -36,6 +36,7 @@ import { FileManagerBulkActionsBar } from './file-manager-bulk-actions-bar';import { FileManagerSkeleton } from './file-manager-skeleton';import { FileManagerTreeNode } from './file-manager-tree-node';import {+ collectDirectoryPaths,collectVisibleFlat,computeDirSelectionState,computeSelectionTotalBytes,@@ -172,12 +173,40 @@ export const FileManager = ({sorting,});- const { expandedPaths, toggleExpand } = useFileManagerExpansion({+ const { expandedPaths, setExpansion, toggleExpand } = useFileManagerExpansion({isFiltering,normalizedRootGroups,visibleTree,});+ // Universe of every directory path in the *full* tree (filter-independent).+ // Powers the header "expand/collapse all" toggle: per the consumer-facing+ // contract the gesture always operates on the entire tree, even when a+ // search filter is active and only matching dirs are visible.+ const allDirPaths = useMemo(() => collectDirectoryPaths(fullTree), [fullTree]);++ const isAllExpanded = useMemo(() => {+ if (allDirPaths.length === 0) {+ return false;+ }++ for (const path of allDirPaths) {+ if (!expandedPaths.has(path)) {+ return false;+ }+ }++ return true;+ }, [allDirPaths, expandedPaths]);++ const toggleExpandAll = useCallback(() => {+ if (allDirPaths.length === 0) {+ return;+ }++ setExpansion(allDirPaths, !isAllExpanded);+ }, [allDirPaths, isAllExpanded, setExpansion]);+// Owned by the host (not the data hook) because it depends on `expandedPaths`,// which in turn depends on `visibleTree` from the data hook — moving it inside// would form a circular hook dependency.@@ -502,7 +531,31 @@ export const FileManager = ({className="size-4"/>)}- {renderSortableHeader('name', effectiveLabels.columnName ?? 'Name', isNameSortable)}+ <div className="flex min-w-0 items-center gap-1.5">+ {allDirPaths.length > 0 ? (+ <button+ aria-expanded={isAllExpanded}+ aria-label={+ isAllExpanded+ ? (effectiveLabels.collapseAllAriaLabel ?? 'Collapse all')+ : (effectiveLabels.expandAllAriaLabel ?? 'Expand all')+ }+ className="text-muted-foreground hover:bg-muted hover:text-primary focus-visible:ring-ring -mx-0.5 inline-flex size-4 shrink-0 items-center justify-center rounded transition-colors outline-none focus-visible:ring-1"+ onClick={toggleExpandAll}+ type="button"+ >+ <ChevronRight+ className={cn('size-3.5 transition-transform', isAllExpanded && 'rotate-90')}+ />+ </button>+ ) : (+ <span+ aria-hidden="true"+ className="-mx-0.5 size-4 shrink-0"+ />+ )}+ {renderSortableHeader('name', effectiveLabels.columnName ?? 'Name', isNameSortable)}+ </div>{isSizeVisible && renderSortableHeader('size', effectiveLabels.columnSize ?? 'Size', isSizeSortable)}{isModifiedVisible &&renderSortableHeader('modified', effectiveLabels.columnModified ?? 'Modified', isModifiedSortable)}diff --git a/frontend/src/components/shared/file-manager/use-file-manager-expansion.ts b/frontend/src/components/shared/file-manager/use-file-manager-expansion.tsindex 3b47bd54..0002c2f6 100644--- a/frontend/src/components/shared/file-manager/use-file-manager-expansion.ts+++ b/frontend/src/components/shared/file-manager/use-file-manager-expansion.ts@@ -7,6 +7,12 @@ import { collectDirectoryPaths } from './file-manager-utils';interface UseFileManagerExpansion {/** Effective set of expanded directory paths (auto-expansion + user overrides). */expandedPaths: Set<string>;+ /**+ * Bulk override for "expand all" / "collapse all" gestures. Each path in+ * `paths` gets its override set to `isExpanded`, replacing any previous+ * per-path value. Passing an empty iterable is a no-op.+ */+ setExpansion: (paths: Iterable<string>, isExpanded: boolean) => void;/*** Toggle expansion of a directory based on the state the caller is currently* displaying. Passing `wasExpanded` is intentional — it captures the user's@@ -75,5 +81,21 @@ export const useFileManagerExpansion = ({});}, []);- return { expandedPaths, toggleExpand };+ const setExpansion = useCallback((paths: Iterable<string>, isExpanded: boolean) => {+ setOverrides((prev) => {+ const next = new Map(prev);+ let didChange = false;++ for (const path of paths) {+ if (next.get(path) !== isExpanded) {+ next.set(path, isExpanded);+ didChange = true;+ }+ }++ return didChange ? next : prev;+ });+ }, []);++ return { expandedPaths, setExpansion, toggleExpand };};