2023-05-29 18:04:03 -06:00
|
|
|
import {
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
ActionInput,
|
|
|
|
|
Button,
|
2023-05-29 18:04:03 -06:00
|
|
|
Checkbox,
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
Header,
|
|
|
|
|
Icon,
|
|
|
|
|
IconButton,
|
|
|
|
|
IconStack,
|
|
|
|
|
Modal,
|
|
|
|
|
Placeholder,
|
|
|
|
|
Skeleton,
|
|
|
|
|
Table,
|
|
|
|
|
TextInput,
|
|
|
|
|
} from "./ui";
|
2025-12-25 09:14:00 -07:00
|
|
|
import {
|
|
|
|
|
APIButton,
|
|
|
|
|
DirectorySearch,
|
|
|
|
|
ErrorMessage,
|
|
|
|
|
FileIcon,
|
|
|
|
|
humanFileSize,
|
|
|
|
|
useIsIgnoredDirectory
|
|
|
|
|
} from "./Common";
|
2025-12-26 11:28:10 -07:00
|
|
|
import React, {useContext, useEffect, useState} from "react";
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
import {IconArrowsMove, IconChevronsUp, IconCursorText, IconTags} from "@tabler/icons-react";
|
2026-07-03 11:17:11 -06:00
|
|
|
import {useHotkeys} from "react-hotkeys-hook";
|
A directory rename is finished by the file worker, not the request (#950)
* A directory rename is finished by the file worker, not the request
A directory rename queued a move, waited for it, then removed the old
directory and updated nested Collections itself. A rename that outlasted
Sanic's RESPONSE_TIMEOUT (60 s) was cancelled while waiting: the move still
finished, but the old directory and its emptied subdirectories were left
behind, nested Collections kept their old directories, and the browser was
told the rename failed.
The move job now finishes the rename (nested Collections, then removing the
old directory, empty directories only), and the request returns once the
move is queued. A failure is reported by the job's event. An empty
directory can be renamed (it raised before). The worker status carries
`rename_from`, so the Files page progress bar labels the rename, and the
file browser fetches again when the file worker is done.
A directory rename no longer queues a refresh of its parent: the file
worker runs the newest task first, so it scanned the directory before the
rename.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A queued rename returns its job, and the file browser waits for it
Review fixes:
- The cancellation test patched `wait_for_job`, which this path no longer
calls, so it cancelled nothing. It now asserts the invariant: the
request only queues the rename (it never waits, and nothing has moved
when it returns), and the file worker alone finishes it.
- The file browser inferred the end of a rename from the file worker's
polled status. A short job can start and finish between two polls, and
the first idle poll (before the job started) spent the "fetch once"
token, so the table could keep the old name. POST /api/files/rename now
returns `{"job_id": ...}` (null when the rename is already done), GET
/api/files/jobs/<job_id> reports pending/complete/failed, and the file
browser polls that job before fetching.
- useBrowseFiles ignores a fetch that settles after a newer one, so a
listing requested before a rename cannot replace the one after it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 13:09:33 -07:00
|
|
|
import {
|
|
|
|
|
deleteFile,
|
|
|
|
|
fetchFileWorkerJobStatus,
|
|
|
|
|
ignoreDirectory,
|
|
|
|
|
makeDirectory,
|
|
|
|
|
movePaths,
|
|
|
|
|
renamePath,
|
|
|
|
|
unignoreDirectory
|
|
|
|
|
} from "../api";
|
2023-01-31 18:08:07 -07:00
|
|
|
import _ from 'lodash';
|
|
|
|
|
import {SortableTable} from "./SortableTable";
|
ui: two upload dialogs that had drifted apart (#664)
* ui: two upload dialogs that had drifted apart
The dashboard and the file browser each had their own upload component: two
dropzones, two overwrite toggles, two copies of the progress-bar rendering,
against the same `useUploadFile` state. The file browser's dialog was made
fullscreen with a drop target that grows; the dashboard's stayed a `large`
dialog with a strip to drop onto, because it was a different file.
They differ in one thing that is real: the file browser knows the destination
because the user selected it, and the dashboard has to ask. That is now the
`destination` prop -- `undefined` asks, a string uploads there, and '' is the
media directory rather than a missing destination.
Everything else is one component, so the next change to either entry point
lands on both.
* review: an upload dialog that looped on the media directory
Pressing Upload in the file browser with nothing selected passes `''` -- the
media directory. Three checks along that path read it as "no destination":
* The clearing effect ran, and `doClear` is a new function every render whose
own setState scheduled the next one. React ended it with "Maximum update
depth exceeded", 16 warnings deep, on the default Upload path. The effect
now clears only while asking, and `doClear` is stable.
* The title read `Upload to: /media/wrolpi/`.
* `doUpload` bailed, so a drop on the media root uploaded nothing.
All three predate this branch; moving the dialog is what put them behind one
component. Tests cover the title, what the hook is told, and that a fixed
destination is never the thing that empties the queue.
2026-08-13 15:14:53 -06:00
|
|
|
import {useBrowseFiles, useElementWidth, useMediaDirectory, useWROLMode} from "../hooks/customHooks";
|
2024-03-11 17:47:27 -06:00
|
|
|
import {FileRowTagIcon, FilesRefreshButton} from "./Files";
|
2023-02-15 20:58:07 -07:00
|
|
|
import {FilePreviewContext} from "./FilePreview";
|
2025-12-26 11:28:10 -07:00
|
|
|
import {DragSelectionContext, DragSelectionProvider, SettingsContext, ThemeContext} from "../contexts/contexts";
|
2025-12-06 18:07:20 -07:00
|
|
|
import {BulkTagModal} from "./BulkTagModal";
|
2025-12-25 09:14:00 -07:00
|
|
|
import {InlineErrorBoundary} from "./ErrorBoundary";
|
2026-05-03 17:28:06 -06:00
|
|
|
import {TaggedDeleteConfirmModal} from "./TaggedDeleteConfirmModal";
|
ui: two upload dialogs that had drifted apart (#664)
* ui: two upload dialogs that had drifted apart
The dashboard and the file browser each had their own upload component: two
dropzones, two overwrite toggles, two copies of the progress-bar rendering,
against the same `useUploadFile` state. The file browser's dialog was made
fullscreen with a drop target that grows; the dashboard's stayed a `large`
dialog with a strip to drop onto, because it was a different file.
They differ in one thing that is real: the file browser knows the destination
because the user selected it, and the dashboard has to ask. That is now the
`destination` prop -- `undefined` asks, a string uploads there, and '' is the
media directory rather than a missing destination.
Everything else is one component, so the next change to either entry point
lands on both.
* review: an upload dialog that looped on the media directory
Pressing Upload in the file browser with nothing selected passes `''` -- the
media directory. Three checks along that path read it as "no destination":
* The clearing effect ran, and `doClear` is a new function every render whose
own setState scheduled the next one. React ended it with "Maximum update
depth exceeded", 16 warnings deep, on the default Upload path. The effect
now clears only while asking, and `doClear` is stable.
* The title read `Upload to: /media/wrolpi/`.
* `doUpload` bailed, so a drop on the media root uploaded nothing.
All three predate this branch; moving the dialog is what put them behind one
component. Tests cover the title, what the hook is told, and that a fixed
destination is never the thing that empties the queue.
2026-08-13 15:14:53 -06:00
|
|
|
import {UploadModal} from "./Upload";
|
A directory rename is finished by the file worker, not the request (#950)
* A directory rename is finished by the file worker, not the request
A directory rename queued a move, waited for it, then removed the old
directory and updated nested Collections itself. A rename that outlasted
Sanic's RESPONSE_TIMEOUT (60 s) was cancelled while waiting: the move still
finished, but the old directory and its emptied subdirectories were left
behind, nested Collections kept their old directories, and the browser was
told the rename failed.
The move job now finishes the rename (nested Collections, then removing the
old directory, empty directories only), and the request returns once the
move is queued. A failure is reported by the job's event. An empty
directory can be renamed (it raised before). The worker status carries
`rename_from`, so the Files page progress bar labels the rename, and the
file browser fetches again when the file worker is done.
A directory rename no longer queues a refresh of its parent: the file
worker runs the newest task first, so it scanned the directory before the
rename.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A queued rename returns its job, and the file browser waits for it
Review fixes:
- The cancellation test patched `wait_for_job`, which this path no longer
calls, so it cancelled nothing. It now asserts the invariant: the
request only queues the rename (it never waits, and nothing has moved
when it returns), and the file worker alone finishes it.
- The file browser inferred the end of a rename from the file worker's
polled status. A short job can start and finish between two polls, and
the first idle poll (before the job started) spent the "fetch once"
token, so the table could keep the old name. POST /api/files/rename now
returns `{"job_id": ...}` (null when the rename is already done), GET
/api/files/jobs/<job_id> reports pending/complete/failed, and the file
browser polls that job before fetching.
- useBrowseFiles ignores a fetch that settles after a newer one, so a
listing requested before a rename cannot replace the one after it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 13:09:33 -07:00
|
|
|
import {useFileWorkerStatus} from "../contexts/FileWorkerStatusContext";
|
2023-01-31 18:08:07 -07:00
|
|
|
|
|
|
|
|
function depthIndentation(path) {
|
|
|
|
|
// Repeated spaces for every folder a path is in.
|
|
|
|
|
const depth = (path.match(/\//g) || []).length;
|
|
|
|
|
return '\xa0\xa0\xa0\xa0'.repeat(depth);
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-29 18:04:03 -06:00
|
|
|
export function pathDirectory(path) {
|
|
|
|
|
// Return the full path of the path's directory.
|
|
|
|
|
// pathDirectory('/some/directory/file.txt') -> '/some/directory'
|
|
|
|
|
return path.substring(0, path.lastIndexOf('/'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function pathName(path) {
|
|
|
|
|
// Return the file's name.
|
|
|
|
|
// pathName('/some/directory/file.txt') -> 'file.txt'
|
|
|
|
|
// pathName('/some/directory') -> 'directory'
|
|
|
|
|
if (path.endsWith('/')) {
|
|
|
|
|
// Path is a directory, return its name.
|
|
|
|
|
path = path.substring(0, path.length - 1);
|
|
|
|
|
}
|
|
|
|
|
return path.substring(path.lastIndexOf('/') + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function splitPathParentAndName(path) {
|
|
|
|
|
if (path.endsWith('/')) {
|
|
|
|
|
// Path is a directory, return its name.
|
|
|
|
|
path = path.substring(0, path.length - 1);
|
|
|
|
|
}
|
|
|
|
|
const slashIndex = path.lastIndexOf('/');
|
|
|
|
|
return [path.substring(0, slashIndex), path.substring(slashIndex + 1, path.length)];
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-03 11:17:11 -06:00
|
|
|
export function filterBrowseFiles(browseFiles, filterStr) {
|
|
|
|
|
// Reduce the file tree to the rows whose name matches `filterStr`, keeping the ancestor
|
|
|
|
|
// folders of every match. A folder whose own name matches keeps its entire subtree.
|
|
|
|
|
if (!filterStr) {
|
|
|
|
|
return browseFiles;
|
|
|
|
|
}
|
|
|
|
|
const needle = filterStr.toLowerCase();
|
|
|
|
|
const filterList = (files) => {
|
|
|
|
|
// `files` may be a dict keyed by name (from the API) or an array.
|
|
|
|
|
const fileList = Array.isArray(files) ? files : Object.values(files);
|
|
|
|
|
const matches = [];
|
|
|
|
|
for (const file of fileList) {
|
|
|
|
|
if (pathName(file.path).toLowerCase().includes(needle)) {
|
|
|
|
|
matches.push(file);
|
|
|
|
|
} else if (file.children) {
|
|
|
|
|
const children = filterList(file.children);
|
|
|
|
|
if (children.length > 0) {
|
|
|
|
|
matches.push({...file, children});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return matches;
|
|
|
|
|
};
|
|
|
|
|
return filterList(browseFiles);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-03 16:36:44 -07:00
|
|
|
function Folder({folder, onFolderClick, sortData, onFileClick, disabled, loadingFolders}) {
|
|
|
|
|
const {handleDragStart, handleDragMove, getDragState, shouldAllowClick, selectedPaths, onSelect} = useContext(DragSelectionContext);
|
2023-01-31 18:08:07 -07:00
|
|
|
// Creates a single table row for a folder, or a row for itself and indented rows for its children.
|
2024-02-19 13:45:41 -07:00
|
|
|
let {path, children, is_empty} = folder;
|
|
|
|
|
const ignored = useIsIgnoredDirectory(path);
|
2023-01-31 18:08:07 -07:00
|
|
|
const pathWithNoTrailingSlash = path.substring(0, path.length - 1);
|
|
|
|
|
const name = path.substring(pathWithNoTrailingSlash.lastIndexOf('/') + 1);
|
2025-12-26 11:28:10 -07:00
|
|
|
const isInSelectedPaths = selectedPaths.indexOf(folder['path']) >= 0;
|
|
|
|
|
const {isDragSelecting, isDragDeselecting} = getDragState(path, isInSelectedPaths);
|
|
|
|
|
// Preview selection: show checked if selecting, unchecked if deselecting
|
|
|
|
|
const showAsSelected = (isInSelectedPaths && !isDragDeselecting) || isDragSelecting;
|
|
|
|
|
// Visual highlight class
|
|
|
|
|
const dragClass = isDragSelecting ? 'drag-selecting' : (isDragDeselecting ? 'drag-deselecting' : '');
|
2026-02-03 16:36:44 -07:00
|
|
|
|
|
|
|
|
const isLoading = loadingFolders && loadingFolders.has(path);
|
|
|
|
|
const depth = (path.match(/\//g) || []).length;
|
|
|
|
|
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
const f = <Table.Row
|
2025-12-26 11:28:10 -07:00
|
|
|
key={path}
|
|
|
|
|
className={dragClass}
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
style={(isLoading || disabled) ? {opacity: 0.5, pointerEvents: 'none'} : undefined}
|
2025-12-26 11:28:10 -07:00
|
|
|
onMouseDown={(e) => handleDragStart(path, e)}
|
|
|
|
|
onMouseEnter={() => handleDragMove(path)}
|
|
|
|
|
>
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
<Table.Cell style={{width: '1%', whiteSpace: 'nowrap'}}>
|
2025-12-26 11:28:10 -07:00
|
|
|
<Checkbox checked={showAsSelected} onChange={() => onSelect(folder['path'])}/>
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
</Table.Cell>
|
|
|
|
|
<Table.Cell
|
|
|
|
|
onClick={() => shouldAllowClick() && onFolderClick(path)}
|
|
|
|
|
className='file-path'
|
|
|
|
|
colSpan={2}
|
|
|
|
|
style={is_empty ? {opacity: 0.5} : undefined}
|
|
|
|
|
>
|
2023-01-31 18:08:07 -07:00
|
|
|
{depthIndentation(pathWithNoTrailingSlash)}
|
2023-02-14 08:08:04 -07:00
|
|
|
{is_empty ? <Icon name='folder outline'/> : <Icon name='folder'/>}
|
2024-02-19 13:45:41 -07:00
|
|
|
{ignored && <Icon name='eye slash' color='red'/>}
|
2023-01-31 18:08:07 -07:00
|
|
|
{name}
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
</Table.Cell>
|
|
|
|
|
</Table.Row>;
|
2023-02-15 17:40:57 -07:00
|
|
|
if (children) {
|
2023-01-31 18:08:07 -07:00
|
|
|
// Folder has children, recursively display them.
|
|
|
|
|
children = sortData(children);
|
|
|
|
|
let childPaths = [];
|
|
|
|
|
_.forEach(children, (p, k) => {
|
|
|
|
|
childPaths = [...childPaths,
|
2025-12-25 09:14:00 -07:00
|
|
|
<InlineErrorBoundary key={k}>
|
|
|
|
|
<Path path={p} onFolderClick={onFolderClick} sortData={sortData} onFileClick={onFileClick}
|
2026-02-03 16:36:44 -07:00
|
|
|
disabled={disabled} loadingFolders={loadingFolders}/>
|
2025-12-25 09:14:00 -07:00
|
|
|
</InlineErrorBoundary>];
|
2023-01-31 18:08:07 -07:00
|
|
|
});
|
|
|
|
|
return <React.Fragment>
|
|
|
|
|
{f}
|
|
|
|
|
{childPaths}
|
|
|
|
|
</React.Fragment>
|
2026-02-03 16:36:44 -07:00
|
|
|
} else if (isLoading) {
|
|
|
|
|
// Folder is loading - show skeleton rows
|
|
|
|
|
return <React.Fragment>
|
|
|
|
|
{f}
|
|
|
|
|
<SkeletonFileRow depth={depth}/>
|
|
|
|
|
</React.Fragment>;
|
2023-01-31 18:08:07 -07:00
|
|
|
} else {
|
|
|
|
|
// Folder has no children.
|
|
|
|
|
return f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-03 16:36:44 -07:00
|
|
|
function File({file, onFileClick, disabled}) {
|
|
|
|
|
const {handleDragStart, handleDragMove, getDragState, shouldAllowClick, selectedPaths, onSelect} = useContext(DragSelectionContext);
|
2023-01-31 18:08:07 -07:00
|
|
|
const {path, size} = file;
|
2025-12-26 11:28:10 -07:00
|
|
|
const isInSelectedPaths = selectedPaths.indexOf(path) >= 0;
|
|
|
|
|
const {isDragSelecting, isDragDeselecting} = getDragState(path, isInSelectedPaths);
|
|
|
|
|
// Preview selection: show checked if selecting, unchecked if deselecting
|
|
|
|
|
const showAsSelected = (isInSelectedPaths && !isDragDeselecting) || isDragSelecting;
|
|
|
|
|
// Visual highlight class
|
|
|
|
|
const dragClass = isDragSelecting ? 'drag-selecting' : (isDragDeselecting ? 'drag-deselecting' : '');
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
return <Table.Row
|
2025-12-26 11:28:10 -07:00
|
|
|
key={path}
|
|
|
|
|
className={dragClass}
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
style={disabled ? {opacity: 0.5, pointerEvents: 'none'} : undefined}
|
2025-12-26 11:28:10 -07:00
|
|
|
onMouseDown={(e) => handleDragStart(path, e)}
|
|
|
|
|
onMouseEnter={() => handleDragMove(path)}
|
|
|
|
|
>
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
<Table.Cell style={{width: '1%', whiteSpace: 'nowrap'}}>
|
2025-12-26 11:28:10 -07:00
|
|
|
<Checkbox checked={showAsSelected} onChange={() => onSelect(path)}/>
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
</Table.Cell>
|
|
|
|
|
<Table.Cell onClick={() => shouldAllowClick() && onFileClick(file)} className='file-path'>
|
2023-01-31 18:08:07 -07:00
|
|
|
{depthIndentation(path)}
|
2023-04-01 11:52:41 -06:00
|
|
|
<FileRowTagIcon file={file}/>
|
2023-01-31 18:08:07 -07:00
|
|
|
{/*null size to make icon the correct size*/}
|
|
|
|
|
<FileIcon file={file} size={null}/>
|
2023-05-29 18:04:03 -06:00
|
|
|
{pathName(path)}
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
</Table.Cell>
|
|
|
|
|
<Table.Cell numeric style={{width: '1%', whiteSpace: 'nowrap'}}>
|
2023-01-31 18:08:07 -07:00
|
|
|
{humanFileSize(size)}
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
</Table.Cell>
|
|
|
|
|
</Table.Row>
|
2023-01-31 18:08:07 -07:00
|
|
|
}
|
|
|
|
|
|
2026-02-03 16:36:44 -07:00
|
|
|
function Path({path, onFolderClick, onFileClick, sortData, disabled, loadingFolders}) {
|
2023-01-31 18:08:07 -07:00
|
|
|
if (path['path'].endsWith('/')) {
|
|
|
|
|
return <Folder
|
|
|
|
|
folder={path}
|
|
|
|
|
onFolderClick={onFolderClick}
|
|
|
|
|
sortData={sortData}
|
|
|
|
|
onFileClick={onFileClick}
|
2023-05-29 18:04:03 -06:00
|
|
|
disabled={disabled}
|
2026-02-03 16:36:44 -07:00
|
|
|
loadingFolders={loadingFolders}
|
2023-01-31 18:08:07 -07:00
|
|
|
/>
|
|
|
|
|
} else {
|
|
|
|
|
return <File
|
|
|
|
|
file={path}
|
|
|
|
|
onFileClick={onFileClick}
|
2023-05-29 18:04:03 -06:00
|
|
|
disabled={disabled}
|
2023-01-31 18:08:07 -07:00
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-03 16:36:44 -07:00
|
|
|
function SkeletonFileRow({depth}) {
|
|
|
|
|
const indentation = '\xa0\xa0\xa0\xa0'.repeat(depth);
|
|
|
|
|
return (
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
<Table.Row>
|
|
|
|
|
<Table.Cell style={{width: '1%', whiteSpace: 'nowrap'}}>
|
2026-02-03 16:36:44 -07:00
|
|
|
<Checkbox disabled/>
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
</Table.Cell>
|
|
|
|
|
<Table.Cell className='file-path' colSpan={2}>
|
2026-02-03 16:36:44 -07:00
|
|
|
{indentation}
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
<Skeleton height={12} width={200} radius={0} animate style={{display: 'inline-block', marginLeft: '0.5em'}}/>
|
|
|
|
|
</Table.Cell>
|
|
|
|
|
</Table.Row>
|
2026-02-03 16:36:44 -07:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-01 19:52:15 -06:00
|
|
|
// Below this footer width (px) the action buttons are icon-only; at or above it they expand to show labels.
|
|
|
|
|
// The eight labeled buttons need ~1020px to fit on a single row; this leaves a small buffer.
|
|
|
|
|
const FOOTER_LABELS_MIN_WIDTH = 1050;
|
A directory rename is finished by the file worker, not the request (#950)
* A directory rename is finished by the file worker, not the request
A directory rename queued a move, waited for it, then removed the old
directory and updated nested Collections itself. A rename that outlasted
Sanic's RESPONSE_TIMEOUT (60 s) was cancelled while waiting: the move still
finished, but the old directory and its emptied subdirectories were left
behind, nested Collections kept their old directories, and the browser was
told the rename failed.
The move job now finishes the rename (nested Collections, then removing the
old directory, empty directories only), and the request returns once the
move is queued. A failure is reported by the job's event. An empty
directory can be renamed (it raised before). The worker status carries
`rename_from`, so the Files page progress bar labels the rename, and the
file browser fetches again when the file worker is done.
A directory rename no longer queues a refresh of its parent: the file
worker runs the newest task first, so it scanned the directory before the
rename.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A queued rename returns its job, and the file browser waits for it
Review fixes:
- The cancellation test patched `wait_for_job`, which this path no longer
calls, so it cancelled nothing. It now asserts the invariant: the
request only queues the rename (it never waits, and nothing has moved
when it returns), and the file worker alone finishes it.
- The file browser inferred the end of a rename from the file worker's
polled status. A short job can start and finish between two polls, and
the first idle poll (before the job started) spent the "fetch once"
token, so the table could keep the old name. POST /api/files/rename now
returns `{"job_id": ...}` (null when the rename is already done), GET
/api/files/jobs/<job_id> reports pending/complete/failed, and the file
browser polls that job before fetching.
- useBrowseFiles ignores a fetch that settles after a newer one, so a
listing requested before a rename cannot replace the one after it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 13:09:33 -07:00
|
|
|
// How often a queued rename's job is checked.
|
|
|
|
|
const RENAME_JOB_POLL_MS = 500;
|
2026-07-01 19:52:15 -06:00
|
|
|
|
2023-01-31 18:08:07 -07:00
|
|
|
export function FileBrowser() {
|
2023-05-29 18:04:03 -06:00
|
|
|
const [selectedPaths, setSelectedPaths] = React.useState([]);
|
|
|
|
|
const [renameOpen, setRenameOpen] = React.useState(false);
|
|
|
|
|
const [moveOpen, setMoveOpen] = React.useState(false);
|
|
|
|
|
const [makeDirectoryOpen, setMakeDirectoryOpen] = React.useState(false);
|
2024-02-19 13:45:41 -07:00
|
|
|
const [ignoreDirectoryOpen, setIgnoreDirectoryOpen] = React.useState(false);
|
2025-12-06 18:07:20 -07:00
|
|
|
const [bulkTagOpen, setBulkTagOpen] = React.useState(false);
|
2025-12-25 09:14:00 -07:00
|
|
|
const [uploadOpen, setUploadOpen] = React.useState(false);
|
2023-05-29 18:04:03 -06:00
|
|
|
const [pending, setPending] = React.useState(false);
|
2026-02-03 16:36:44 -07:00
|
|
|
// Tracks which folders are currently loading their children
|
|
|
|
|
const [loadingFolders, setLoadingFolders] = React.useState(new Set());
|
2024-02-19 13:45:41 -07:00
|
|
|
// Only true if only one path is selected, and it is a directory.
|
|
|
|
|
const [singleDirectorySelected, setSingleDirectorySelected] = React.useState(false);
|
|
|
|
|
// Only true if single directory is selected, and it is in settings['ignored_directories']
|
|
|
|
|
const [isDirectoryIgnored, setIsDirectoryIgnored] = React.useState(false);
|
2025-12-25 10:05:00 -07:00
|
|
|
// Tracks folder that was opened while selected - its children will be auto-selected when they load
|
|
|
|
|
const pendingAutoSelectRef = React.useRef(null);
|
2026-04-14 10:40:24 -06:00
|
|
|
// Tagged file groups that would be deleted - shown in confirmation modal
|
|
|
|
|
const [taggedFileGroups, setTaggedFileGroups] = React.useState(null);
|
2026-07-03 11:17:11 -06:00
|
|
|
// Reduces the visible rows to those matching, and their parent folders.
|
|
|
|
|
const [filterStr, setFilterStr] = React.useState('');
|
|
|
|
|
const filterInputRef = React.useRef();
|
|
|
|
|
|
|
|
|
|
// 'f' focuses the filter input, like the search inputs on other pages.
|
|
|
|
|
useHotkeys('f', (e) => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
if (filterInputRef.current) {
|
|
|
|
|
filterInputRef.current.focus();
|
|
|
|
|
}
|
|
|
|
|
}, {enableOnFormTags: false});
|
2024-02-19 13:45:41 -07:00
|
|
|
|
|
|
|
|
const {settings, fetchSettings} = React.useContext(SettingsContext);
|
2023-05-29 18:04:03 -06:00
|
|
|
|
|
|
|
|
const selectedPathsCount = selectedPaths ? selectedPaths.length : 0;
|
2023-01-31 18:08:07 -07:00
|
|
|
|
|
|
|
|
const {browseFiles, openFolders, setOpenFolders, fetchFiles} = useBrowseFiles();
|
2023-07-21 15:14:09 -06:00
|
|
|
const wrolModeEnabled = useWROLMode();
|
2023-01-31 18:08:07 -07:00
|
|
|
|
2023-04-01 11:52:41 -06:00
|
|
|
const headers = [
|
|
|
|
|
{key: 'select', text: ''},
|
|
|
|
|
{key: 'path', text: 'Path', sortBy: i => i['path'].toLowerCase()},
|
|
|
|
|
{key: 'size', text: 'Size', sortBy: 'size'},
|
|
|
|
|
];
|
2023-01-31 18:08:07 -07:00
|
|
|
|
2023-04-01 11:52:41 -06:00
|
|
|
const {setPreviewFile, setCallbacks} = React.useContext(FilePreviewContext);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
// Fetch files after tagging.
|
2023-04-10 12:27:55 -06:00
|
|
|
setCallbacks([() => fetchFiles(openFolders)]);
|
2023-04-01 11:52:41 -06:00
|
|
|
|
|
|
|
|
return () => setCallbacks(null);
|
|
|
|
|
}, []);
|
2023-01-31 18:08:07 -07:00
|
|
|
|
2024-02-19 13:45:41 -07:00
|
|
|
useEffect(() => {
|
|
|
|
|
if (selectedPaths.length === 1 && selectedPaths[0].endsWith('/')) {
|
|
|
|
|
setSingleDirectorySelected(true);
|
|
|
|
|
if (!_.isEmpty(settings)) {
|
|
|
|
|
// Used to toggle between ignore/un-ignore (eye/eye lash) icon.
|
|
|
|
|
const directory = selectedPaths[0].slice(0, -1);
|
|
|
|
|
setIsDirectoryIgnored(settings['ignored_directories'].indexOf(directory) >= 0);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
setSingleDirectorySelected(false);
|
|
|
|
|
}
|
|
|
|
|
}, [selectedPaths, settings]);
|
|
|
|
|
|
2025-12-25 10:05:00 -07:00
|
|
|
// Auto-select immediate children when a selected folder is opened
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const folderToAutoSelect = pendingAutoSelectRef.current;
|
|
|
|
|
if (folderToAutoSelect && browseFiles && typeof browseFiles === 'object') {
|
|
|
|
|
// browseFiles is a dict: {'map/': {path: 'map/', children: {...}}, ...}
|
|
|
|
|
// children is also a dict: {'file.txt': {path: 'map/file.txt', ...}, ...}
|
|
|
|
|
const findFolderChildren = (files, targetFolder) => {
|
|
|
|
|
if (!files || typeof files !== 'object') return null;
|
|
|
|
|
// Convert dict to array of values for iteration
|
|
|
|
|
const fileList = Array.isArray(files) ? files : Object.values(files);
|
|
|
|
|
for (const file of fileList) {
|
|
|
|
|
if (file.path === targetFolder && file.children) {
|
|
|
|
|
// Return children as array of values
|
|
|
|
|
return Array.isArray(file.children) ? file.children : Object.values(file.children);
|
|
|
|
|
}
|
|
|
|
|
if (file.children) {
|
|
|
|
|
const found = findFolderChildren(file.children, targetFolder);
|
|
|
|
|
if (found) return found;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const children = findFolderChildren(browseFiles, folderToAutoSelect);
|
|
|
|
|
if (children && children.length > 0) {
|
|
|
|
|
const childPaths = children.map(child => child.path);
|
|
|
|
|
const newSelectedPaths = [...new Set([...selectedPaths, ...childPaths])];
|
|
|
|
|
setSelectedPaths(newSelectedPaths);
|
|
|
|
|
}
|
|
|
|
|
pendingAutoSelectRef.current = null;
|
|
|
|
|
}
|
|
|
|
|
}, [browseFiles]);
|
|
|
|
|
|
A directory rename is finished by the file worker, not the request (#950)
* A directory rename is finished by the file worker, not the request
A directory rename queued a move, waited for it, then removed the old
directory and updated nested Collections itself. A rename that outlasted
Sanic's RESPONSE_TIMEOUT (60 s) was cancelled while waiting: the move still
finished, but the old directory and its emptied subdirectories were left
behind, nested Collections kept their old directories, and the browser was
told the rename failed.
The move job now finishes the rename (nested Collections, then removing the
old directory, empty directories only), and the request returns once the
move is queued. A failure is reported by the job's event. An empty
directory can be renamed (it raised before). The worker status carries
`rename_from`, so the Files page progress bar labels the rename, and the
file browser fetches again when the file worker is done.
A directory rename no longer queues a refresh of its parent: the file
worker runs the newest task first, so it scanned the directory before the
rename.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A queued rename returns its job, and the file browser waits for it
Review fixes:
- The cancellation test patched `wait_for_job`, which this path no longer
calls, so it cancelled nothing. It now asserts the invariant: the
request only queues the rename (it never waits, and nothing has moved
when it returns), and the file worker alone finishes it.
- The file browser inferred the end of a rename from the file worker's
polled status. A short job can start and finish between two polls, and
the first idle poll (before the job started) spent the "fetch once"
token, so the table could keep the old name. POST /api/files/rename now
returns `{"job_id": ...}` (null when the rename is already done), GET
/api/files/jobs/<job_id> reports pending/complete/failed, and the file
browser polls that job before fetching.
- useBrowseFiles ignores a fetch that settles after a newer one, so a
listing requested before a rename cannot replace the one after it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 13:09:33 -07:00
|
|
|
// A move finishes in the file worker after its request returns (the Files page shows its progress), so fetch
|
|
|
|
|
// the files again when the file worker is done.
|
|
|
|
|
const {status: fileWorkerStatus, setFastPolling} = useFileWorkerStatus();
|
|
|
|
|
const fileWorkerBusy = !!fileWorkerStatus && fileWorkerStatus.status !== 'idle';
|
|
|
|
|
const fileWorkerWasBusy = React.useRef(false);
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (fileWorkerWasBusy.current && !fileWorkerBusy) {
|
|
|
|
|
fetchFiles();
|
|
|
|
|
}
|
|
|
|
|
fileWorkerWasBusy.current = fileWorkerBusy;
|
|
|
|
|
}, [fileWorkerBusy]);
|
|
|
|
|
|
|
|
|
|
// A queued rename (a directory) returns its job; wait for that job, rather than inferring it from the file
|
|
|
|
|
// worker's status (a short job can start and finish between two polls).
|
|
|
|
|
const mountedRef = React.useRef(true);
|
|
|
|
|
useEffect(() => () => {
|
|
|
|
|
mountedRef.current = false;
|
|
|
|
|
}, []);
|
|
|
|
|
const afterRename = async (jobId) => {
|
|
|
|
|
if (!jobId) {
|
|
|
|
|
await reset();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
setSelectedPaths([]);
|
|
|
|
|
setFastPolling(true); // Update the progress bar while the rename runs.
|
|
|
|
|
try {
|
|
|
|
|
while (mountedRef.current) {
|
|
|
|
|
await new Promise(resolve => setTimeout(resolve, RENAME_JOB_POLL_MS));
|
|
|
|
|
if (await fetchFileWorkerJobStatus(jobId) !== 'pending') {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
setFastPolling(false);
|
|
|
|
|
}
|
|
|
|
|
if (mountedRef.current) {
|
|
|
|
|
await reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-03 16:36:44 -07:00
|
|
|
// Clear loading states when file data updates
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (loadingFolders.size > 0) {
|
|
|
|
|
setLoadingFolders(new Set());
|
|
|
|
|
}
|
|
|
|
|
}, [browseFiles]);
|
|
|
|
|
|
2024-02-19 13:45:41 -07:00
|
|
|
const onIgnore = async () => {
|
|
|
|
|
setIgnoreDirectoryOpen(false);
|
|
|
|
|
await fetchSettings();
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-14 10:40:24 -06:00
|
|
|
const handleDeleteComplete = async () => {
|
2025-12-25 09:44:11 -07:00
|
|
|
// Remove deleted directories from openFolders to prevent fetching non-existent directories
|
|
|
|
|
const deletedDirs = selectedPaths.filter(p => p.endsWith('/'));
|
|
|
|
|
if (deletedDirs.length > 0 && openFolders && openFolders.length > 0) {
|
|
|
|
|
const newOpenFolders = openFolders.filter(folder =>
|
|
|
|
|
!deletedDirs.some(deleted => folder === deleted || folder.startsWith(deleted))
|
|
|
|
|
);
|
|
|
|
|
setOpenFolders(newOpenFolders.length > 0 ? newOpenFolders : null);
|
|
|
|
|
}
|
2023-05-29 18:04:03 -06:00
|
|
|
await reset();
|
2023-01-31 18:08:07 -07:00
|
|
|
};
|
|
|
|
|
|
2026-04-14 10:40:24 -06:00
|
|
|
const onDelete = async () => {
|
|
|
|
|
const result = await deleteFile(selectedPaths);
|
|
|
|
|
if (result && result.tagged) {
|
|
|
|
|
// Show modal with tagged file groups for user to confirm.
|
|
|
|
|
setTaggedFileGroups(result.file_groups);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
await handleDeleteComplete();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const onForceDelete = async () => {
|
|
|
|
|
setTaggedFileGroups(null);
|
|
|
|
|
const result = await deleteFile(selectedPaths, true);
|
|
|
|
|
if (result && result.tagged) return; // unexpected tagged response
|
|
|
|
|
if (result && !result.ok) return; // error already toasted
|
|
|
|
|
await handleDeleteComplete();
|
|
|
|
|
};
|
|
|
|
|
|
2023-05-29 18:04:03 -06:00
|
|
|
const handleMakeDirectory = async () => {
|
|
|
|
|
setMakeDirectoryOpen(false);
|
|
|
|
|
await reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const reset = async () => {
|
|
|
|
|
setSelectedPaths([]);
|
|
|
|
|
setPending(true);
|
|
|
|
|
try {
|
|
|
|
|
await fetchFiles();
|
|
|
|
|
} finally {
|
|
|
|
|
setPending(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-01 19:52:15 -06:00
|
|
|
const [footerRef, footerWidth] = useElementWidth();
|
|
|
|
|
// Expand icon-only buttons to include labels once the footer is wide enough to fit them.
|
|
|
|
|
const showLabels = footerWidth >= FOOTER_LABELS_MIN_WIDTH;
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
// Show a label alongside the icon once there's room; otherwise the icon carries the meaning alone.
|
|
|
|
|
const label = (text) => showLabels ? text : null;
|
2026-07-01 19:52:15 -06:00
|
|
|
|
test: one place for fixtures, real providers instead of mocked context modules
Specs had no shared vocabulary for the app's data or its contexts, so each one
rebuilt both. A settings object was written out by hand wherever one was needed,
twenty-odd keys at a time, and nothing held those copies to each other or to the
API. Contexts were worse: to render a consumer a spec mocked the whole context
module, which replaces every export including the providers, so each spec
reinvented the pieces it still needed. One supplies a `Media` that always
reports desktop -- quietly leaving that component's mobile branch untested -- and
one hand-writes a context as a bare `_currentValue` with no provider, working only
because useContext reads that React internal.
test-fixtures.js is now the single definition of both, shared by jest, the
Cypress component specs, and e2e intercept bodies, so the three cannot disagree
about what the API returns. Every fixture is a function taking overrides; a
shared mutable object lets one test change what the next one sees.
The drift this prevents was already real. The theme fixture supplied `i`, `s`
and `t` holding hardcoded Semantic greys for months after ThemeProvider stopped
supplying them, and ThemeContext still declared all four. So the fixture agreed
with the tests, and with nothing else: FileBrowser was reading `inverted` off the
context and pasting the resulting `undefined` into a className, which is why the
file browser's footer -- near-white #f9fafb, with a `.inverted` dark variant that
nothing could select any more -- stayed light in dark, night and amber. A white
bar pinned to the bottom of the screen in night mode costs the user exactly the
dark adaptation the theme exists to protect. It takes tokens now.
test-fixtures.test.js holds each fixture to its context's declared shape in both
directions, so a property added to one and forgotten in the other fails a test.
Two failed attempts are recorded in test-utils.js because both were instructive.
Importing Tags.js and FileWorkerStatusContext.js so the harness could supply
those providers broke eight suites: it put both into the module graph of every
spec ahead of that spec's own mocks, and components bound to a second instance of
a mocked module -- a different jest.fn() than the test had configured, so a hook
mocked to return a value returned undefined, in a file no test mentions.
Requiring them lazily fixed that and not its mirror image: useContext read a
different TagsContext than the harness had required, so the provider was ignored
and the context default won. A harness must not change what a spec imports, so
it owns only contexts/contexts.js and a spec passes any other context itself.
DomainTagging is converted off the `_currentValue` fake as proof, and now asserts
the tag name a user sees rather than a test id its own mock invented. The five
remaining specs are listed in a ratchet so the count can only fall.
974 jest, 15 browser component, 46 e2e, clean cache-busted build, tsc clean.
Fixtures are confirmed absent from the shipped bundle.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 16:30:49 -06:00
|
|
|
const footer = <div className='sticky-footer' ref={footerRef}>
|
2026-07-01 19:52:15 -06:00
|
|
|
<FilesRefreshButton paths={selectedPaths} showLabel={showLabels}/>
|
2025-12-07 09:17:30 -07:00
|
|
|
<APIButton
|
|
|
|
|
icon='trash'
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
role='danger'
|
2025-12-07 09:17:30 -07:00
|
|
|
confirmContent='Are you sure you want to delete these files?'
|
|
|
|
|
confirmButton='Delete'
|
|
|
|
|
onClick={onDelete}
|
|
|
|
|
disabled={selectedPathsCount === 0}
|
|
|
|
|
obeyWROLMode={true}
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
>{label('Delete')}</APIButton>
|
|
|
|
|
<Button icon={IconCursorText}
|
2025-12-07 09:17:30 -07:00
|
|
|
color='yellow'
|
|
|
|
|
onClick={() => setRenameOpen(true)}
|
|
|
|
|
disabled={wrolModeEnabled || selectedPathsCount !== 1}
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
>{label('Rename')}</Button>
|
2025-12-07 09:17:30 -07:00
|
|
|
{selectedPathsCount === 1 ?
|
|
|
|
|
<RenameModal
|
|
|
|
|
open={renameOpen}
|
|
|
|
|
onClose={() => setRenameOpen(false)}
|
|
|
|
|
onPending={setPending}
|
|
|
|
|
path={selectedPaths[0]}
|
A directory rename is finished by the file worker, not the request (#950)
* A directory rename is finished by the file worker, not the request
A directory rename queued a move, waited for it, then removed the old
directory and updated nested Collections itself. A rename that outlasted
Sanic's RESPONSE_TIMEOUT (60 s) was cancelled while waiting: the move still
finished, but the old directory and its emptied subdirectories were left
behind, nested Collections kept their old directories, and the browser was
told the rename failed.
The move job now finishes the rename (nested Collections, then removing the
old directory, empty directories only), and the request returns once the
move is queued. A failure is reported by the job's event. An empty
directory can be renamed (it raised before). The worker status carries
`rename_from`, so the Files page progress bar labels the rename, and the
file browser fetches again when the file worker is done.
A directory rename no longer queues a refresh of its parent: the file
worker runs the newest task first, so it scanned the directory before the
rename.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A queued rename returns its job, and the file browser waits for it
Review fixes:
- The cancellation test patched `wait_for_job`, which this path no longer
calls, so it cancelled nothing. It now asserts the invariant: the
request only queues the rename (it never waits, and nothing has moved
when it returns), and the file worker alone finishes it.
- The file browser inferred the end of a rename from the file worker's
polled status. A short job can start and finish between two polls, and
the first idle poll (before the job started) spent the "fetch once"
token, so the table could keep the old name. POST /api/files/rename now
returns `{"job_id": ...}` (null when the rename is already done), GET
/api/files/jobs/<job_id> reports pending/complete/failed, and the file
browser polls that job before fetching.
- useBrowseFiles ignores a fetch that settles after a newer one, so a
listing requested before a rename cannot replace the one after it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 13:09:33 -07:00
|
|
|
onSubmit={afterRename}
|
2025-12-07 09:17:30 -07:00
|
|
|
/> : null}
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
<Button icon={IconArrowsMove}
|
2025-12-07 09:17:30 -07:00
|
|
|
color='teal'
|
|
|
|
|
disabled={wrolModeEnabled || selectedPathsCount === 0}
|
|
|
|
|
onClick={() => setMoveOpen(true)}
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
>{label('Move')}</Button>
|
2025-12-07 09:17:30 -07:00
|
|
|
{selectedPathsCount > 0 ?
|
|
|
|
|
<MoveModal open={moveOpen}
|
|
|
|
|
onClose={() => setMoveOpen(false)}
|
|
|
|
|
paths={selectedPaths}
|
|
|
|
|
onSubmit={reset}
|
|
|
|
|
/> : null}
|
|
|
|
|
<Button
|
|
|
|
|
color='blue'
|
|
|
|
|
onClick={() => setMakeDirectoryOpen(true)}
|
|
|
|
|
disabled={wrolModeEnabled}
|
2026-07-01 19:52:15 -06:00
|
|
|
style={{paddingLeft: '1em', paddingRight: showLabels ? '1em' : '0.8em'}}
|
2025-12-07 09:17:30 -07:00
|
|
|
>
|
test: act on review — the skeleton guard was reading the wrong layer
The "separates the skeleton from the panel" cases could not fail. A Skeleton
is three layers: the element paints nothing, ::before paints
--mantine-color-body (`--bg`) at z-index 10, and ::after paints the bar the
user actually sees (`--head` in light, `--border` in dark) at z-index 11, on
top. `paintedBackground` walked outward from the element and returned the
first paint, which is ::before -- so all four cases compared the page
background to the panel. Those differ by design in every theme, so the bars
could have collapsed into the panel entirely and every assertion stayed green.
My planted regression did not catch it because the plant was broader than the
claim: it forced all three layers to the panel colour, so the test went red
for a reason the fix did not depend on. The plant now sets only ::after, and
a second plant sets only ::before and must stay GREEN.
The layer order is now the caller's argument, since "the background" is
ambiguous once pseudo-elements are involved and guessing makes a test vacuous
rather than wrong.
Also from review:
The disc on a filled button was pinned to `--blue` at the call site, but WROL
mode disables that button and Mantine repaints it `--mantine-color-disabled`
-- a blue chip on a grey button, the original hole inverted. The surface now
comes from the cascade (`--button-bg`, and the disabled colour for any
variant), so the call site says nothing at all and cannot be wrong about a
state it does not control. Keying on `[data-variant="filled"]` alone matched
none of our buttons: Mantine omits the attribute when a call site names a
colour but no variant, which is how every filled button here is written.
The Checkbox behaviour test asserted only that a handler fired, against a box
held at `checked={false}` that could never change. It is now uncontrolled and
asserts the box is checked, plus a second test that the handler sees the new
state -- read inside the handler, because `currentTarget` is null by the time
a mock is inspected.
The empty-caption test counted every div in the container; it counts the
loader's siblings now. Two comments corrected: Pill emits no `--pill-radius`
at all and its own stylesheet falls back to `1000rem`, and the nav bar no
longer relies on the default surface.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:05:29 -06:00
|
|
|
{/* The corner disc follows the button's fill on its own -- including when WROL
|
|
|
|
|
mode disables it and Mantine repaints it grey. See ui.css. */}
|
|
|
|
|
<IconStack corner={<Icon name='add'/>} label='New folder'>
|
2025-12-07 09:17:30 -07:00
|
|
|
<Icon name='folder'/>
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
</IconStack>
|
2026-07-01 19:52:15 -06:00
|
|
|
{showLabels ? <> New Folder</> : null}
|
2025-12-07 09:17:30 -07:00
|
|
|
</Button>
|
|
|
|
|
<MakeDirectoryModal
|
|
|
|
|
open={makeDirectoryOpen}
|
|
|
|
|
onClose={() => setMakeDirectoryOpen(false)}
|
|
|
|
|
parent={selectedPaths.length ? selectedPaths[0] : null}
|
|
|
|
|
onSubmit={handleMakeDirectory}
|
|
|
|
|
/>
|
2025-12-25 09:14:00 -07:00
|
|
|
<Button
|
|
|
|
|
icon='upload'
|
|
|
|
|
color='green'
|
|
|
|
|
disabled={wrolModeEnabled || (selectedPathsCount > 0 && !singleDirectorySelected)}
|
|
|
|
|
onClick={() => setUploadOpen(true)}
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
>{label('Upload')}</Button>
|
ui: two upload dialogs that had drifted apart (#664)
* ui: two upload dialogs that had drifted apart
The dashboard and the file browser each had their own upload component: two
dropzones, two overwrite toggles, two copies of the progress-bar rendering,
against the same `useUploadFile` state. The file browser's dialog was made
fullscreen with a drop target that grows; the dashboard's stayed a `large`
dialog with a strip to drop onto, because it was a different file.
They differ in one thing that is real: the file browser knows the destination
because the user selected it, and the dashboard has to ask. That is now the
`destination` prop -- `undefined` asks, a string uploads there, and '' is the
media directory rather than a missing destination.
Everything else is one component, so the next change to either entry point
lands on both.
* review: an upload dialog that looped on the media directory
Pressing Upload in the file browser with nothing selected passes `''` -- the
media directory. Three checks along that path read it as "no destination":
* The clearing effect ran, and `doClear` is a new function every render whose
own setState scheduled the next one. React ended it with "Maximum update
depth exceeded", 16 warnings deep, on the default Upload path. The effect
now clears only while asking, and `doClear` is stable.
* The title read `Upload to: /media/wrolpi/`.
* `doUpload` bailed, so a drop on the media root uploaded nothing.
All three predate this branch; moving the dialog is what put them behind one
component. Tests cover the title, what the hook is told, and that a fixed
destination is never the thing that empties the queue.
2026-08-13 15:14:53 -06:00
|
|
|
<UploadModal
|
2025-12-25 09:14:00 -07:00
|
|
|
open={uploadOpen}
|
|
|
|
|
onClose={() => setUploadOpen(false)}
|
|
|
|
|
destination={singleDirectorySelected && selectedPaths[0] ? selectedPaths[0].slice(0, -1) : ''}
|
|
|
|
|
onComplete={reset}
|
|
|
|
|
/>
|
2025-12-07 09:17:30 -07:00
|
|
|
<Button
|
|
|
|
|
color='grey'
|
|
|
|
|
icon={isDirectoryIgnored ? 'eye' : 'eye slash'}
|
|
|
|
|
disabled={!singleDirectorySelected || wrolModeEnabled}
|
|
|
|
|
onClick={() => setIgnoreDirectoryOpen(true)}
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
>{label(isDirectoryIgnored ? 'Unignore' : 'Ignore')}</Button>
|
2025-12-07 09:17:30 -07:00
|
|
|
<IgnoreDirectoryModal
|
|
|
|
|
open={ignoreDirectoryOpen}
|
|
|
|
|
onClose={onIgnore}
|
|
|
|
|
onSubmit={onIgnore}
|
|
|
|
|
directory={selectedPaths.length === 1 ? selectedPaths[0] : null}
|
|
|
|
|
ignored={isDirectoryIgnored}
|
|
|
|
|
/>
|
|
|
|
|
<Button
|
|
|
|
|
color='violet'
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
icon={IconTags}
|
2025-12-07 09:17:30 -07:00
|
|
|
disabled={selectedPathsCount === 0}
|
|
|
|
|
onClick={() => setBulkTagOpen(true)}
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
>{label('Tag')}</Button>
|
2025-12-07 09:17:30 -07:00
|
|
|
<BulkTagModal
|
|
|
|
|
open={bulkTagOpen}
|
|
|
|
|
onClose={() => setBulkTagOpen(false)}
|
|
|
|
|
paths={selectedPaths}
|
|
|
|
|
onComplete={reset}
|
|
|
|
|
/>
|
2026-05-03 17:28:06 -06:00
|
|
|
<TaggedDeleteConfirmModal
|
2026-04-14 10:40:24 -06:00
|
|
|
open={taggedFileGroups !== null}
|
2026-05-03 17:28:06 -06:00
|
|
|
taggedFileGroups={taggedFileGroups}
|
|
|
|
|
onCancel={() => setTaggedFileGroups(null)}
|
|
|
|
|
onConfirm={onForceDelete}
|
|
|
|
|
/>
|
2025-12-07 09:17:30 -07:00
|
|
|
</div>;
|
2023-01-31 18:08:07 -07:00
|
|
|
|
2026-07-03 11:17:11 -06:00
|
|
|
const onCollapseAll = () => {
|
|
|
|
|
if (!openFolders) return;
|
|
|
|
|
// Deselect any paths that will no longer be visible (descendants of the open folders).
|
|
|
|
|
const newSelectedPaths = selectedPaths.filter(p =>
|
|
|
|
|
!openFolders.some(folder => p.startsWith(folder) && p !== folder));
|
|
|
|
|
if (newSelectedPaths.length !== selectedPaths.length) {
|
|
|
|
|
setSelectedPaths(newSelectedPaths);
|
|
|
|
|
}
|
|
|
|
|
setOpenFolders(null);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-31 18:08:07 -07:00
|
|
|
const onFolderClick = async (folder) => {
|
|
|
|
|
let newFolders;
|
|
|
|
|
if (openFolders.indexOf(folder) >= 0) {
|
|
|
|
|
// Remove the folder that was clicked on, as well as its sub-folders.
|
|
|
|
|
newFolders = openFolders.filter(i => !i.startsWith(folder));
|
2025-12-25 10:05:00 -07:00
|
|
|
// Unselect any children of the closed folder (they're no longer visible)
|
|
|
|
|
const newSelectedPaths = selectedPaths.filter(p => !p.startsWith(folder) || p === folder);
|
|
|
|
|
if (newSelectedPaths.length !== selectedPaths.length) {
|
|
|
|
|
setSelectedPaths(newSelectedPaths);
|
|
|
|
|
}
|
2023-01-31 18:08:07 -07:00
|
|
|
} else {
|
|
|
|
|
// Add the new folder to the opened folders.
|
|
|
|
|
newFolders = [...openFolders, folder];
|
2026-02-03 16:36:44 -07:00
|
|
|
// Mark folder as loading so skeleton rows show
|
|
|
|
|
setLoadingFolders(prev => new Set([...prev, folder]));
|
2025-12-25 10:05:00 -07:00
|
|
|
// If folder is selected, mark it for auto-selection of its children
|
|
|
|
|
if (selectedPaths.includes(folder)) {
|
|
|
|
|
pendingAutoSelectRef.current = folder;
|
|
|
|
|
}
|
2023-01-31 18:08:07 -07:00
|
|
|
}
|
|
|
|
|
console.debug(`newFolders=${newFolders}`);
|
|
|
|
|
setOpenFolders(newFolders);
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-03 11:17:11 -06:00
|
|
|
const filteredFiles = React.useMemo(
|
|
|
|
|
() => browseFiles ? filterBrowseFiles(browseFiles, filterStr) : browseFiles,
|
|
|
|
|
[browseFiles, filterStr],
|
|
|
|
|
);
|
|
|
|
|
|
2023-01-31 18:08:07 -07:00
|
|
|
if (browseFiles === null) {
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
return <Placeholder lines={2}/>;
|
2023-09-07 20:13:36 -06:00
|
|
|
} else if (browseFiles === undefined) {
|
|
|
|
|
return <ErrorMessage>Could not fetch files</ErrorMessage>
|
2023-01-31 18:08:07 -07:00
|
|
|
}
|
|
|
|
|
|
2025-12-26 11:28:10 -07:00
|
|
|
return <DragSelectionProvider
|
|
|
|
|
selectedPaths={selectedPaths}
|
|
|
|
|
setSelectedPaths={setSelectedPaths}
|
2026-07-03 11:17:11 -06:00
|
|
|
browseFiles={filteredFiles}
|
2025-12-26 11:28:10 -07:00
|
|
|
openFolders={openFolders}
|
|
|
|
|
>
|
2026-07-03 11:17:11 -06:00
|
|
|
<div className='file-browser-filter-container'>
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
<ActionInput
|
|
|
|
|
leftSection={<Icon name='filter'/>}
|
2026-07-03 11:17:11 -06:00
|
|
|
placeholder='Filter files...'
|
|
|
|
|
value={filterStr}
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
onChange={(e) => setFilterStr(e.target.value)}
|
2026-07-03 11:17:11 -06:00
|
|
|
aria-label='Filter files'
|
|
|
|
|
className='file-browser-filter'
|
|
|
|
|
ref={filterInputRef}
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
action={<IconButton
|
2026-07-03 11:17:11 -06:00
|
|
|
icon='close'
|
|
|
|
|
type='button'
|
|
|
|
|
onClick={() => setFilterStr('')}
|
|
|
|
|
disabled={!filterStr}
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
label='Clear filter'
|
2026-07-03 11:17:11 -06:00
|
|
|
/>}
|
|
|
|
|
/>
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
<IconButton
|
|
|
|
|
icon={IconChevronsUp}
|
2026-07-03 11:17:11 -06:00
|
|
|
type='button'
|
|
|
|
|
onClick={onCollapseAll}
|
|
|
|
|
disabled={!openFolders || openFolders.length === 0}
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
label='Close all folders'
|
2026-07-03 11:17:11 -06:00
|
|
|
/>
|
|
|
|
|
</div>
|
2025-12-26 11:28:10 -07:00
|
|
|
<FileBrowserContent
|
2026-07-03 11:17:11 -06:00
|
|
|
browseFiles={filteredFiles}
|
2025-12-26 11:28:10 -07:00
|
|
|
headers={headers}
|
|
|
|
|
onFolderClick={onFolderClick}
|
|
|
|
|
setPreviewFile={setPreviewFile}
|
|
|
|
|
pending={pending}
|
2026-02-03 16:36:44 -07:00
|
|
|
loadingFolders={loadingFolders}
|
2025-12-26 11:28:10 -07:00
|
|
|
/>
|
|
|
|
|
{footer}
|
|
|
|
|
</DragSelectionProvider>
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-03 16:36:44 -07:00
|
|
|
function FileBrowserContent({browseFiles, headers, onFolderClick, setPreviewFile, pending, loadingFolders}) {
|
2025-12-26 11:28:10 -07:00
|
|
|
const {isDragging} = useContext(DragSelectionContext);
|
|
|
|
|
const containerClassName = isDragging ? 'file-browser-dragging' : '';
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div style={{marginBottom: '4em'}} className={containerClassName}>
|
2025-12-07 09:17:30 -07:00
|
|
|
<SortableTable
|
|
|
|
|
data={browseFiles}
|
|
|
|
|
tableHeaders={headers}
|
|
|
|
|
defaultSortColumn='path'
|
|
|
|
|
rowKey='path'
|
2025-12-26 11:28:10 -07:00
|
|
|
rowFunc={(i, sortData) => (
|
|
|
|
|
<Path
|
|
|
|
|
key={i['key']}
|
|
|
|
|
path={i}
|
|
|
|
|
onFolderClick={onFolderClick}
|
|
|
|
|
onFileClick={(file) => setPreviewFile(file)}
|
|
|
|
|
sortData={sortData}
|
|
|
|
|
disabled={pending}
|
2026-02-03 16:36:44 -07:00
|
|
|
loadingFolders={loadingFolders}
|
2025-12-26 11:28:10 -07:00
|
|
|
/>
|
|
|
|
|
)}
|
2025-12-07 09:17:30 -07:00
|
|
|
/>
|
|
|
|
|
</div>
|
2025-12-26 11:28:10 -07:00
|
|
|
);
|
2023-01-31 18:08:07 -07:00
|
|
|
}
|
2023-05-29 18:04:03 -06:00
|
|
|
|
|
|
|
|
export function RenameModal({open, onClose, path, onSubmit, onPending}) {
|
|
|
|
|
const [parent, name] = splitPathParentAndName(path);
|
|
|
|
|
const [value, setValue] = React.useState(name);
|
|
|
|
|
const disabled = value === name;
|
|
|
|
|
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
const handleInputChange = (e) => {
|
|
|
|
|
setValue(e.target.value);
|
2023-05-29 18:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleSubmit = async (e) => {
|
|
|
|
|
if (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
A directory rename is finished by the file worker, not the request (#950)
* A directory rename is finished by the file worker, not the request
A directory rename queued a move, waited for it, then removed the old
directory and updated nested Collections itself. A rename that outlasted
Sanic's RESPONSE_TIMEOUT (60 s) was cancelled while waiting: the move still
finished, but the old directory and its emptied subdirectories were left
behind, nested Collections kept their old directories, and the browser was
told the rename failed.
The move job now finishes the rename (nested Collections, then removing the
old directory, empty directories only), and the request returns once the
move is queued. A failure is reported by the job's event. An empty
directory can be renamed (it raised before). The worker status carries
`rename_from`, so the Files page progress bar labels the rename, and the
file browser fetches again when the file worker is done.
A directory rename no longer queues a refresh of its parent: the file
worker runs the newest task first, so it scanned the directory before the
rename.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A queued rename returns its job, and the file browser waits for it
Review fixes:
- The cancellation test patched `wait_for_job`, which this path no longer
calls, so it cancelled nothing. It now asserts the invariant: the
request only queues the rename (it never waits, and nothing has moved
when it returns), and the file worker alone finishes it.
- The file browser inferred the end of a rename from the file worker's
polled status. A short job can start and finish between two polls, and
the first idle poll (before the job started) spent the "fetch once"
token, so the table could keep the old name. POST /api/files/rename now
returns `{"job_id": ...}` (null when the rename is already done), GET
/api/files/jobs/<job_id> reports pending/complete/failed, and the file
browser polls that job before fetching.
- useBrowseFiles ignores a fetch that settles after a newer one, so a
listing requested before a rename cannot replace the one after it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 13:09:33 -07:00
|
|
|
let jobId = null;
|
2023-05-29 18:04:03 -06:00
|
|
|
try {
|
|
|
|
|
console.log(`Renaming: ${path} to ${value}`);
|
|
|
|
|
onPending(true);
|
A directory rename is finished by the file worker, not the request (#950)
* A directory rename is finished by the file worker, not the request
A directory rename queued a move, waited for it, then removed the old
directory and updated nested Collections itself. A rename that outlasted
Sanic's RESPONSE_TIMEOUT (60 s) was cancelled while waiting: the move still
finished, but the old directory and its emptied subdirectories were left
behind, nested Collections kept their old directories, and the browser was
told the rename failed.
The move job now finishes the rename (nested Collections, then removing the
old directory, empty directories only), and the request returns once the
move is queued. A failure is reported by the job's event. An empty
directory can be renamed (it raised before). The worker status carries
`rename_from`, so the Files page progress bar labels the rename, and the
file browser fetches again when the file worker is done.
A directory rename no longer queues a refresh of its parent: the file
worker runs the newest task first, so it scanned the directory before the
rename.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A queued rename returns its job, and the file browser waits for it
Review fixes:
- The cancellation test patched `wait_for_job`, which this path no longer
calls, so it cancelled nothing. It now asserts the invariant: the
request only queues the rename (it never waits, and nothing has moved
when it returns), and the file worker alone finishes it.
- The file browser inferred the end of a rename from the file worker's
polled status. A short job can start and finish between two polls, and
the first idle poll (before the job started) spent the "fetch once"
token, so the table could keep the old name. POST /api/files/rename now
returns `{"job_id": ...}` (null when the rename is already done), GET
/api/files/jobs/<job_id> reports pending/complete/failed, and the file
browser polls that job before fetching.
- useBrowseFiles ignores a fetch that settles after a newer one, so a
listing requested before a rename cannot replace the one after it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 13:09:33 -07:00
|
|
|
jobId = await renamePath(path, value);
|
2023-05-29 18:04:03 -06:00
|
|
|
} finally {
|
|
|
|
|
onClose();
|
|
|
|
|
onPending(false);
|
|
|
|
|
if (onSubmit) {
|
A directory rename is finished by the file worker, not the request (#950)
* A directory rename is finished by the file worker, not the request
A directory rename queued a move, waited for it, then removed the old
directory and updated nested Collections itself. A rename that outlasted
Sanic's RESPONSE_TIMEOUT (60 s) was cancelled while waiting: the move still
finished, but the old directory and its emptied subdirectories were left
behind, nested Collections kept their old directories, and the browser was
told the rename failed.
The move job now finishes the rename (nested Collections, then removing the
old directory, empty directories only), and the request returns once the
move is queued. A failure is reported by the job's event. An empty
directory can be renamed (it raised before). The worker status carries
`rename_from`, so the Files page progress bar labels the rename, and the
file browser fetches again when the file worker is done.
A directory rename no longer queues a refresh of its parent: the file
worker runs the newest task first, so it scanned the directory before the
rename.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A queued rename returns its job, and the file browser waits for it
Review fixes:
- The cancellation test patched `wait_for_job`, which this path no longer
calls, so it cancelled nothing. It now asserts the invariant: the
request only queues the rename (it never waits, and nothing has moved
when it returns), and the file worker alone finishes it.
- The file browser inferred the end of a rename from the file worker's
polled status. A short job can start and finish between two polls, and
the first idle poll (before the job started) spent the "fetch once"
token, so the table could keep the old name. POST /api/files/rename now
returns `{"job_id": ...}` (null when the rename is already done), GET
/api/files/jobs/<job_id> reports pending/complete/failed, and the file
browser polls that job before fetching.
- useBrowseFiles ignores a fetch that settles after a newer one, so a
listing requested before a rename cannot replace the one after it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 13:09:33 -07:00
|
|
|
await onSubmit(jobId);
|
2023-05-29 18:04:03 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setValue(pathName(path));
|
|
|
|
|
}, [path]);
|
|
|
|
|
|
ui: size the five modals that had never been sized
These five carried no `size` at all, so they rendered at Mantine's 440px default
-- a width nobody had chosen, inherited from the library rather than decided.
Roland audited them:
FileBrowser rename small (440, unchanged)
FileBrowser move large (620)
FileBrowser ignore small (440, unchanged)
FileBrowser make directory large (620)
Files filter small (440, unchanged)
The three "unchanged" ones are written down rather than left implicit, so the
decision lives in the source and a future change to Mantine's default cannot
move them.
Roland asked for `medium` on the ignore dialog and there is no such modal size:
the vocabulary is mini/tiny/small/large/fullscreen, and Mantine has no token
between 440 and 620. An unknown name would have passed through untranslated,
rendered at 440 anyway, and left the source claiming otherwise -- which is what
the size guard in ui.test.js was added to catch. Asked rather than guessed;
`small` was the answer, and the guard would have failed the build either way.
Verified in the browser rather than from the props: move 620, make directory 620,
ignore 440, rename 440. Move and ignore need a selection before they can be
opened, so a directory was selected first.
1134 jest / 64 suites, clean npm run build. The full suite needs
`--maxWorkers=2` on this machine at the moment: at load average 38 four unrelated
suites (ControllerPage, CollectionReorganizeModal, CollectionTagModal, Flasher)
time out and the run takes 183s instead of 5s. They pass in isolation and with
reduced parallelism; nothing in this change touches them.
2026-08-02 19:21:49 -06:00
|
|
|
// Audited: unchanged at `small` (440px), written down so the default cannot move it.
|
|
|
|
|
return <Modal size='small'
|
2023-05-29 18:04:03 -06:00
|
|
|
open={open}
|
|
|
|
|
onClose={onClose}
|
|
|
|
|
>
|
2025-12-07 11:32:07 -07:00
|
|
|
<Modal.Header>Rename: {name}</Modal.Header>
|
|
|
|
|
<Modal.Content>
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
<form onSubmit={handleSubmit}>
|
2024-05-19 16:04:45 -06:00
|
|
|
<Header as='h4'>New Name</Header>
|
|
|
|
|
<pre>{parent ? parent + '/' : null}{value}</pre>
|
|
|
|
|
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
<TextInput
|
2026-07-06 15:35:23 -06:00
|
|
|
autoFocus
|
2024-05-19 16:04:45 -06:00
|
|
|
label='Name'
|
|
|
|
|
value={value}
|
|
|
|
|
onChange={handleInputChange}
|
|
|
|
|
/>
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
</form>
|
2025-12-07 11:32:07 -07:00
|
|
|
</Modal.Content>
|
|
|
|
|
<Modal.Actions>
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
<Button
|
|
|
|
|
onClick={() => setValue(name)}
|
|
|
|
|
style={{marginRight: 'auto'}}
|
|
|
|
|
>
|
|
|
|
|
Reset
|
|
|
|
|
</Button>
|
2023-05-29 18:04:03 -06:00
|
|
|
<Button
|
|
|
|
|
color='violet'
|
|
|
|
|
disabled={disabled}
|
|
|
|
|
onClick={handleSubmit}
|
|
|
|
|
>
|
|
|
|
|
Rename
|
|
|
|
|
</Button>
|
2025-12-07 11:32:07 -07:00
|
|
|
</Modal.Actions>
|
2023-05-29 18:04:03 -06:00
|
|
|
</Modal>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function MoveModal({open, paths, onClose, onSubmit}) {
|
|
|
|
|
const [destination, setDestination] = React.useState('');
|
|
|
|
|
const [pending, setPending] = React.useState(false);
|
|
|
|
|
|
|
|
|
|
const handleDirectory = (value) => {
|
|
|
|
|
setDestination(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleMove = async () => {
|
|
|
|
|
try {
|
|
|
|
|
setPending(true);
|
|
|
|
|
await movePaths(destination, paths);
|
|
|
|
|
onClose();
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error(e);
|
|
|
|
|
setPending(false);
|
|
|
|
|
}
|
|
|
|
|
if (onSubmit) {
|
|
|
|
|
await onSubmit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
const fileCell = i => <Table.Cell>
|
2023-05-29 18:04:03 -06:00
|
|
|
<pre style={{marginTop: 0, marginBottom: 0}}>{i}</pre>
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
</Table.Cell>;
|
2023-05-29 18:04:03 -06:00
|
|
|
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
const destinationRows = paths.map(i => <Table.Row key={i}>
|
2023-05-29 18:04:03 -06:00
|
|
|
{fileCell(i)}
|
|
|
|
|
{destination ? fileCell(destination + '/' + pathName(i)) : fileCell(pathName(i))}
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
</Table.Row>);
|
2023-05-29 18:04:03 -06:00
|
|
|
|
review: record why make-directory is wider than rename
Acting on the review of #628. No bugs; one suggestion and one nit, and the
suggestion is answered with a measurement rather than a change.
The review asked whether MakeDirectoryModal should drop back to `small`, on the
grounds that its body -- a path, one field and a button -- is the same shape as
RenameModal's, which is `small`. The shapes are the same; the content is not.
Rename shows a RELATIVE path, make-directory shows the absolute one including the
media directory, and a bare `<pre>` is `white-space: pre`, so it scrolls out of
sight rather than wrapping.
Measured in the browser at both widths: 440px holds 42 characters, 620px holds 61.
`/media/wrolpi/videos/Practical Engineering/Season 2024/` is 55. So an ordinary
channel-and-season path is unreadable at 440 and fits at 620, which is exactly
the condition the review set for keeping it. The dev tree hides this -- its
paths are around 22 characters and fit either way.
Both `large` call sites now carry the audit comment the other three had, which
was the nit. Make-directory's records the measurement, because it does read like
an inconsistency beside rename and the next person to notice should see the
numbers before narrowing it back.
1134 jest / 64 suites (--maxWorkers=2; see the previous commit), clean build.
2026-08-02 19:46:41 -06:00
|
|
|
/*
|
ui: an upload target smaller than the dialog around it (#663)
The upload dialog was 682x367 on a 1440x900 desktop -- 47% of the width, 41% of the
height -- and the drop target inside it was a strip about 90px tall. A small thing to
drag a file onto, with the file browser it came from covering most of the screen behind.
Upload and Move ask for `fullScreen`, which is edge to edge on a phone and 90% above the
tablet breakpoint: filling a desktop reads as the app having been replaced rather than as
something opened over it. Move holds a DirectorySearch above a row per path being moved,
which grows with the selection; 620px showed a handful and scrolled the rest.
Two things had to follow. Mantine sizes a fullscreen dialog's content to the viewport but
leaves the body at its content height, so the footer landed two thirds up the screen with
a quarter of the viewport empty beneath it -- the body takes the leftover now and the
actions ride to the bottom of it. And the drop target itself grows into the room, with a
floor so it stays large once progress bars claim their own space.
Rename and the confirmations keep their sizes: a fullscreen dialog for one text field or
one sentence reads as broken. New Folder keeps `large` too -- it is a text field and a
path preview, the same shape as rename, not the directory picker its name suggests.
`size='fullscreen'` is a DIFFERENT thing -- full width, height from the content, which is
what a log or a preview wants. Both are documented where the sizes are declared, and the
gallery grows a fullscreen example so the difference is visible in all four themes.
339 component tests pass, 69 suites / 1214 jest tests pass, npm run build is clean.
2026-08-13 13:06:18 -06:00
|
|
|
* Fullscreen: a DirectorySearch above a two-column Source/Destination table of every
|
|
|
|
|
* path being moved, which grows with the selection. 620px showed a handful of rows and
|
|
|
|
|
* scrolled the rest.
|
review: record why make-directory is wider than rename
Acting on the review of #628. No bugs; one suggestion and one nit, and the
suggestion is answered with a measurement rather than a change.
The review asked whether MakeDirectoryModal should drop back to `small`, on the
grounds that its body -- a path, one field and a button -- is the same shape as
RenameModal's, which is `small`. The shapes are the same; the content is not.
Rename shows a RELATIVE path, make-directory shows the absolute one including the
media directory, and a bare `<pre>` is `white-space: pre`, so it scrolls out of
sight rather than wrapping.
Measured in the browser at both widths: 440px holds 42 characters, 620px holds 61.
`/media/wrolpi/videos/Practical Engineering/Season 2024/` is 55. So an ordinary
channel-and-season path is unreadable at 440 and fits at 620, which is exactly
the condition the review set for keeping it. The dev tree hides this -- its
paths are around 22 characters and fit either way.
Both `large` call sites now carry the audit comment the other three had, which
was the nit. Make-directory's records the measurement, because it does read like
an inconsistency beside rename and the next person to notice should see the
numbers before narrowing it back.
1134 jest / 64 suites (--maxWorkers=2; see the previous commit), clean build.
2026-08-02 19:46:41 -06:00
|
|
|
*/
|
ui: an upload target smaller than the dialog around it (#663)
The upload dialog was 682x367 on a 1440x900 desktop -- 47% of the width, 41% of the
height -- and the drop target inside it was a strip about 90px tall. A small thing to
drag a file onto, with the file browser it came from covering most of the screen behind.
Upload and Move ask for `fullScreen`, which is edge to edge on a phone and 90% above the
tablet breakpoint: filling a desktop reads as the app having been replaced rather than as
something opened over it. Move holds a DirectorySearch above a row per path being moved,
which grows with the selection; 620px showed a handful and scrolled the rest.
Two things had to follow. Mantine sizes a fullscreen dialog's content to the viewport but
leaves the body at its content height, so the footer landed two thirds up the screen with
a quarter of the viewport empty beneath it -- the body takes the leftover now and the
actions ride to the bottom of it. And the drop target itself grows into the room, with a
floor so it stays large once progress bars claim their own space.
Rename and the confirmations keep their sizes: a fullscreen dialog for one text field or
one sentence reads as broken. New Folder keeps `large` too -- it is a text field and a
path preview, the same shape as rename, not the directory picker its name suggests.
`size='fullscreen'` is a DIFFERENT thing -- full width, height from the content, which is
what a log or a preview wants. Both are documented where the sizes are declared, and the
gallery grows a fullscreen example so the difference is visible in all four themes.
339 component tests pass, 69 suites / 1214 jest tests pass, npm run build is clean.
2026-08-13 13:06:18 -06:00
|
|
|
return <Modal fullScreen
|
2023-05-29 18:04:03 -06:00
|
|
|
onClose={onClose}
|
|
|
|
|
open={open}
|
|
|
|
|
>
|
2025-12-07 11:32:07 -07:00
|
|
|
<Modal.Header>Move Files/Directories</Modal.Header>
|
|
|
|
|
<Modal.Content>
|
2023-05-29 18:04:03 -06:00
|
|
|
<p>Search for a directory to move your files into:</p>
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
<DirectorySearch onSelect={handleDirectory} disabled={pending} autoFocus/>
|
2023-05-29 18:04:03 -06:00
|
|
|
|
|
|
|
|
<Table>
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
<Table.Header>
|
|
|
|
|
<Table.Row>
|
|
|
|
|
<Table.HeaderCell>Source</Table.HeaderCell>
|
|
|
|
|
<Table.HeaderCell>Destination</Table.HeaderCell>
|
|
|
|
|
</Table.Row>
|
|
|
|
|
</Table.Header>
|
|
|
|
|
<Table.Body>
|
2023-05-29 18:04:03 -06:00
|
|
|
{destinationRows}
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
</Table.Body>
|
2023-05-29 18:04:03 -06:00
|
|
|
</Table>
|
2025-12-07 11:32:07 -07:00
|
|
|
</Modal.Content>
|
|
|
|
|
<Modal.Actions>
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
<Button
|
|
|
|
|
onClick={() => setDestination(null)}
|
|
|
|
|
style={{marginRight: 'auto'}}
|
|
|
|
|
disabled={pending}
|
|
|
|
|
>Reset</Button>
|
2023-05-29 18:04:03 -06:00
|
|
|
<Button
|
|
|
|
|
color='violet'
|
|
|
|
|
onClick={handleMove}
|
|
|
|
|
disabled={pending}
|
|
|
|
|
>Move</Button>
|
2025-12-07 11:32:07 -07:00
|
|
|
</Modal.Actions>
|
2023-05-29 18:04:03 -06:00
|
|
|
</Modal>
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-19 13:45:41 -07:00
|
|
|
export function IgnoreDirectoryModal({open, onClose, onSubmit, directory, ignored}) {
|
|
|
|
|
const mediaDirectory = useMediaDirectory();
|
|
|
|
|
const [pending, setPending] = React.useState(false);
|
|
|
|
|
|
|
|
|
|
const handleIgnore = async () => {
|
|
|
|
|
try {
|
|
|
|
|
setPending(true);
|
|
|
|
|
if (ignored) {
|
|
|
|
|
await unignoreDirectory(`${mediaDirectory}/${directory}`);
|
|
|
|
|
} else {
|
|
|
|
|
await ignoreDirectory(`${mediaDirectory}/${directory}`);
|
|
|
|
|
}
|
|
|
|
|
if (onSubmit) {
|
|
|
|
|
onSubmit();
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
setPending(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const header = ignored ? 'Remove Ignore Directory' : 'Ignore Directory';
|
|
|
|
|
const content = ignored ?
|
|
|
|
|
'Remove ignore of the following directory? You must refresh your files after this.'
|
|
|
|
|
: 'Ignore the following directory? The files within will not be indexed and will not show in search results.';
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
let submitButton = <Button role='primary'
|
2024-02-19 13:45:41 -07:00
|
|
|
disabled={pending}
|
|
|
|
|
onClick={handleIgnore}
|
|
|
|
|
>{ignored ? 'Un-ignore' : 'Ignore'}</Button>;
|
|
|
|
|
|
ui: size the five modals that had never been sized
These five carried no `size` at all, so they rendered at Mantine's 440px default
-- a width nobody had chosen, inherited from the library rather than decided.
Roland audited them:
FileBrowser rename small (440, unchanged)
FileBrowser move large (620)
FileBrowser ignore small (440, unchanged)
FileBrowser make directory large (620)
Files filter small (440, unchanged)
The three "unchanged" ones are written down rather than left implicit, so the
decision lives in the source and a future change to Mantine's default cannot
move them.
Roland asked for `medium` on the ignore dialog and there is no such modal size:
the vocabulary is mini/tiny/small/large/fullscreen, and Mantine has no token
between 440 and 620. An unknown name would have passed through untranslated,
rendered at 440 anyway, and left the source claiming otherwise -- which is what
the size guard in ui.test.js was added to catch. Asked rather than guessed;
`small` was the answer, and the guard would have failed the build either way.
Verified in the browser rather than from the props: move 620, make directory 620,
ignore 440, rename 440. Move and ignore need a selection before they can be
opened, so a directory was selected first.
1134 jest / 64 suites, clean npm run build. The full suite needs
`--maxWorkers=2` on this machine at the moment: at load average 38 four unrelated
suites (ControllerPage, CollectionReorganizeModal, CollectionTagModal, Flasher)
time out and the run takes 183s instead of 5s. They pass in isolation and with
reduced parallelism; nothing in this change touches them.
2026-08-02 19:21:49 -06:00
|
|
|
// Audited: `small` (440px), which is the width it already had.
|
|
|
|
|
return <Modal size='small' open={open} onClose={onClose}>
|
2025-12-07 11:32:07 -07:00
|
|
|
<Modal.Header>{header}</Modal.Header>
|
|
|
|
|
<Modal.Content>
|
2024-02-19 13:45:41 -07:00
|
|
|
{content}
|
|
|
|
|
<pre>{mediaDirectory}/{directory}</pre>
|
2025-12-07 11:32:07 -07:00
|
|
|
</Modal.Content>
|
|
|
|
|
<Modal.Actions>
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
<Button role='cancel' style={{marginRight: 'auto'}} onClick={onClose}>Close</Button>
|
2024-02-19 13:45:41 -07:00
|
|
|
{submitButton}
|
2025-12-07 11:32:07 -07:00
|
|
|
</Modal.Actions>
|
2024-02-19 13:45:41 -07:00
|
|
|
</Modal>
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-29 18:04:03 -06:00
|
|
|
export function MakeDirectoryModal({open, onClose, parent, onSubmit}) {
|
|
|
|
|
const [value, setValue] = useState('');
|
|
|
|
|
const mediaDirectory = useMediaDirectory();
|
|
|
|
|
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
const handleInputChange = (e) => {
|
|
|
|
|
setValue(e.target.value);
|
2023-05-29 18:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleSubmit = async (e) => {
|
|
|
|
|
if (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
const path = parent ? `${parent}/${value}` : value;
|
|
|
|
|
await makeDirectory(path);
|
|
|
|
|
setValue('');
|
|
|
|
|
if (onSubmit) {
|
|
|
|
|
await onSubmit();
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
review: record why make-directory is wider than rename
Acting on the review of #628. No bugs; one suggestion and one nit, and the
suggestion is answered with a measurement rather than a change.
The review asked whether MakeDirectoryModal should drop back to `small`, on the
grounds that its body -- a path, one field and a button -- is the same shape as
RenameModal's, which is `small`. The shapes are the same; the content is not.
Rename shows a RELATIVE path, make-directory shows the absolute one including the
media directory, and a bare `<pre>` is `white-space: pre`, so it scrolls out of
sight rather than wrapping.
Measured in the browser at both widths: 440px holds 42 characters, 620px holds 61.
`/media/wrolpi/videos/Practical Engineering/Season 2024/` is 55. So an ordinary
channel-and-season path is unreadable at 440 and fits at 620, which is exactly
the condition the review set for keeping it. The dev tree hides this -- its
paths are around 22 characters and fit either way.
Both `large` call sites now carry the audit comment the other three had, which
was the nit. Make-directory's records the measurement, because it does read like
an inconsistency beside rename and the next person to notice should see the
numbers before narrowing it back.
1134 jest / 64 suites (--maxWorkers=2; see the previous commit), clean build.
2026-08-02 19:46:41 -06:00
|
|
|
/*
|
|
|
|
|
* Audited: `large` (620px), deliberately wider than RenameModal's `small` even though
|
|
|
|
|
* the form is the same shape -- one field and a button. The difference is the path
|
|
|
|
|
* above it: rename shows a RELATIVE path, this shows the absolute one including the
|
|
|
|
|
* media directory, and a bare `<pre>` is `white-space: pre`, so it scrolls rather
|
|
|
|
|
* than wraps. Measured in the browser: 440px holds 42 characters and 620px holds
|
|
|
|
|
* 61. `/media/wrolpi/videos/Practical Engineering/Season 2024/` is 55, so an
|
|
|
|
|
* ordinary channel-and-season path scrolls out of sight at 440 and fits at 620.
|
|
|
|
|
*
|
|
|
|
|
* Written out because it reads like an inconsistency next to rename, and the next
|
|
|
|
|
* person to notice that should see the measurement before narrowing it back.
|
|
|
|
|
*/
|
ui: size the five modals that had never been sized
These five carried no `size` at all, so they rendered at Mantine's 440px default
-- a width nobody had chosen, inherited from the library rather than decided.
Roland audited them:
FileBrowser rename small (440, unchanged)
FileBrowser move large (620)
FileBrowser ignore small (440, unchanged)
FileBrowser make directory large (620)
Files filter small (440, unchanged)
The three "unchanged" ones are written down rather than left implicit, so the
decision lives in the source and a future change to Mantine's default cannot
move them.
Roland asked for `medium` on the ignore dialog and there is no such modal size:
the vocabulary is mini/tiny/small/large/fullscreen, and Mantine has no token
between 440 and 620. An unknown name would have passed through untranslated,
rendered at 440 anyway, and left the source claiming otherwise -- which is what
the size guard in ui.test.js was added to catch. Asked rather than guessed;
`small` was the answer, and the guard would have failed the build either way.
Verified in the browser rather than from the props: move 620, make directory 620,
ignore 440, rename 440. Move and ignore need a selection before they can be
opened, so a directory was selected first.
1134 jest / 64 suites, clean npm run build. The full suite needs
`--maxWorkers=2` on this machine at the moment: at load average 38 four unrelated
suites (ControllerPage, CollectionReorganizeModal, CollectionTagModal, Flasher)
time out and the run takes 183s instead of 5s. They pass in isolation and with
reduced parallelism; nothing in this change touches them.
2026-08-02 19:21:49 -06:00
|
|
|
return <Modal size='large' open={open} onClose={onClose}>
|
2025-12-07 11:32:07 -07:00
|
|
|
<Modal.Header>Make Directory</Modal.Header>
|
|
|
|
|
<Modal.Content>
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
<form onSubmit={handleSubmit}>
|
2024-05-19 16:04:45 -06:00
|
|
|
<pre>{mediaDirectory}/{parent}{value}</pre>
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
<TextInput
|
2026-07-06 15:35:23 -06:00
|
|
|
autoFocus
|
2024-05-19 16:04:45 -06:00
|
|
|
label='Name'
|
|
|
|
|
value={value}
|
|
|
|
|
onChange={handleInputChange}
|
|
|
|
|
/>
|
ui: FileBrowser.js and FilePreview.js off Semantic
Migrated both files onto the token-driven ./ui component library: Table,
Modal, Button/IconButton, Checkbox, Header, Panel, Progress, Placeholder,
Skeleton, ActionInput/TextInput, IconStack, Menu/ButtonGroup for the slicer
split-button, and native <img>/<form> in place of Semantic's Image/Form.
Notable adaptations:
- Semantic's per-row `disabled` styling (no visual equivalent in the new
Table) is reproduced with inline opacity/pointer-events instead.
- DirectorySearch's autoFocus now passes straight through as a prop instead
of a nested `input={{autoFocus}}` object, matching SearchBox's API.
- The responsive icon+label footer buttons keep a single Button and toggle
children instead of swapping component type.
- FileBrowser.test.js: two upload-button assertions keyed off a literal
Semantic `.green` class; broadened to also match on the icon, mirroring
the sibling assertion already using that fallback.
Preserved as-is (reported, not fixed): getVideoPreviewModal's
`<Header as='h5'>{path['path']}</Header>` indexes a string with `['path']`,
which was already dead/undefined before this migration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 13:11:01 -06:00
|
|
|
</form>
|
2025-12-07 11:32:07 -07:00
|
|
|
</Modal.Content>
|
|
|
|
|
<Modal.Actions>
|
2023-05-29 18:04:03 -06:00
|
|
|
<Button color='violet' onClick={handleSubmit}>Create</Button>
|
2025-12-07 11:32:07 -07:00
|
|
|
</Modal.Actions>
|
2023-05-29 18:04:03 -06:00
|
|
|
</Modal>
|
2025-12-07 09:17:30 -07:00
|
|
|
}
|