ui: thirty-five files off Semantic, leaving fifteen

Phase 2, part 4.  Baseline 50 -> 15.

Migrated: all eight calculators, the rest of inventory and collections, the
Map/Zim/Docs cluster, Videos, Files, Search, Archive, DashboardPage,
DatesSelector, HelpModal, Events, Tags, Flasher's neighbours, admin Settings
and Status, Download, and App.

Also the three shared modules everything imports: api.js and customHooks.js
swap the Semantic toast library for the library's shim (same call shape), and
useForm.js renders the library's Message.  useForm accepts both the old
`{content, header, positive|negative}` shape and the new `{kind, title}`,
because the pages building those objects migrate separately.

Two library gaps closed, both found by call sites needing them:

  ActionInput is a forwardRef now.  Its ref reaches the input rather than the
  wrapper, because callers use it to focus or select the field -- a ref to the
  surrounding div would do neither, which is why one call site had resorted to
  hand-copying the component's markup.

  Header takes a `color` token name.  Three separate call sites had reached for
  an inline style to colour a heading that carries meaning ("3 items to add"
  against "2 to remove"), which is how a hex ends up in markup.

Two files needed repair after being interrupted mid-edit: MapViewer had a
Segment left in its error branch, and VideoPlayer had lost the useContext
import its own code still used.  Neither jest nor tsc noticed; only
`npm run build` did, which is the whole reason that check exists.

Fifteen files remain: Archive, BulkTagModal, Channels, Docs, FileBrowser,
FilePreview, Flasher, Nav, Playlists, Theme.tsx, Upload, VideoPlayer, Zim,
ControllerPage, admin/Downloads.  Theme.tsx is deliberately last -- the
unmigrated files still import its Semantic-backed wrappers, so it can only go
once they have.
This commit is contained in:
Roland 2026-07-30 12:21:30 -06:00 • committed by lrnselfreliance
parent 16bdffbac7
commit 906705e5b4
48 changed files with 3273 additions and 3877 deletions

View file

@ -1,8 +1,6 @@
import React, {useCallback, useEffect, useState} from 'react';
import {Link} from 'react-router';
import {Grid, Icon, Label, Progress, Button as SButton} from 'semantic-ui-react';
import Message from 'semantic-ui-react/dist/commonjs/collections/Message';
import {Button, Modal, Table} from '../Theme';
import {Button, Icon, Label, Loading, Message, Modal, Progress, Stack, Table} from '../ui';
import {APIButton} from '../Common';
import {
executeBatchReorganization,
@ -200,72 +198,63 @@ export function BatchReorganizeModal({
if (!preview) return null;
return (
<Grid columns={1}>
<Grid.Row>
<Grid.Column>
<p>
<strong>{preview.total_collections}</strong> {kindLabelPlural.toLowerCase()} need reorganization,
with <strong>{preview.total_files_needing_move}</strong> total files to move.
</p>
<p>
<strong>New format:</strong> <Label>{preview.new_file_format}</Label>
</p>
</Grid.Column>
</Grid.Row>
<Stack>
<div>
<p>
<strong>{preview.total_collections}</strong> {kindLabelPlural.toLowerCase()} need reorganization,
with <strong>{preview.total_files_needing_move}</strong> total files to move.
</p>
<p>
<strong>New format:</strong> <Label>{preview.new_file_format}</Label>
</p>
</div>
{preview.collections && preview.collections.length > 0 && (
<Grid.Row>
<Grid.Column>
<strong>{kindLabelPlural} to reorganize:</strong>
<Table basic='very' compact size='small'>
<Table.Header>
<Table.Row>
<Table.HeaderCell>{kindLabel}</Table.HeaderCell>
<Table.HeaderCell>Files to Move</Table.HeaderCell>
<Table.HeaderCell>Sample</Table.HeaderCell>
<div>
<strong>{kindLabelPlural} to reorganize:</strong>
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>{kindLabel}</Table.HeaderCell>
<Table.HeaderCell>Files to Move</Table.HeaderCell>
<Table.HeaderCell>Sample</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
{preview.collections.slice(0, 10).map((collection, idx) => (
<Table.Row key={idx}>
<Table.Cell>{collection.collection_name}</Table.Cell>
<Table.Cell>
{collection.total_files}
</Table.Cell>
<Table.Cell style={{wordBreak: 'break-all', fontSize: '0.9em'}}>
{collection.sample_move ? (
<>
<span style={{color: 'var(--muted)'}}>{collection.sample_move.old_path}</span>
<br/>
<Icon name='arrow right' size='small'/>
<span>{collection.sample_move.new_path}</span>
</>
) : '-'}
</Table.Cell>
</Table.Row>
</Table.Header>
<Table.Body>
{preview.collections.slice(0, 10).map((collection, idx) => (
<Table.Row key={idx}>
<Table.Cell>{collection.collection_name}</Table.Cell>
<Table.Cell>
{collection.total_files}
</Table.Cell>
<Table.Cell style={{wordBreak: 'break-all', fontSize: '0.9em'}}>
{collection.sample_move ? (
<>
<span style={{color: '#888'}}>{collection.sample_move.old_path}</span>
<br/>
<Icon name='arrow right' size='small'/>
<span>{collection.sample_move.new_path}</span>
</>
) : '-'}
</Table.Cell>
</Table.Row>
))}
</Table.Body>
</Table>
{preview.collections.length > 10 && (
<p style={{fontStyle: 'italic'}}>
...and {preview.collections.length - 10} more {kindLabelPlural.toLowerCase()}
</p>
)}
</Grid.Column>
</Grid.Row>
))}
</Table.Body>
</Table>
{preview.collections.length > 10 && (
<p style={{fontStyle: 'italic'}}>
...and {preview.collections.length - 10} more {kindLabelPlural.toLowerCase()}
</p>
)}
</div>
)}
{preview.total_collections === 0 && (
<Grid.Row>
<Grid.Column>
<Message info>
<Message.Header>No {kindLabelPlural} Need Reorganization</Message.Header>
<p>All {kindLabelPlural.toLowerCase()} are already organized according to the current format.</p>
</Message>
</Grid.Column>
</Grid.Row>
<Message kind='info' title={`No ${kindLabelPlural} Need Reorganization`}>
<p>All {kindLabelPlural.toLowerCase()} are already organized according to the current format.</p>
</Message>
)}
</Grid>
</Stack>
);
};
@ -273,83 +262,60 @@ export function BatchReorganizeModal({
if (!status) return null;
const currentCollection = status.current_collection;
const overallColor = status.status === 'complete' ? 'green' : status.status === 'failed' ? 'red' : 'blue';
return (
<Grid columns={1}>
<Grid.Row>
<Grid.Column>
<p>
<strong>Overall Status:</strong> {status.status}
</p>
<strong>Overall Progress:</strong>
<Progress
percent={status.overall_percent || 0}
progress
indicating={status.status !== 'complete' && status.status !== 'failed'}
success={status.status === 'complete'}
error={status.status === 'failed'}
/>
<p>
{status.completed_collections || 0} of {status.total_collections || 0} {kindLabelPlural.toLowerCase()} completed
</p>
</Grid.Column>
</Grid.Row>
<Stack>
<div>
<p>
<strong>Overall Status:</strong> {status.status}
</p>
<strong>Overall Progress:</strong>
<Progress percent={status.overall_percent || 0} color={overallColor}/>
<p>
{status.completed_collections || 0} of {status.total_collections || 0} {kindLabelPlural.toLowerCase()} completed
</p>
</div>
{currentCollection && (
<Grid.Row>
<Grid.Column>
<strong>Currently Processing:</strong> {currentCollection.name}
<Progress
percent={currentCollection.percent || 0}
progress
indicating
size='small'
color='blue'
/>
<p style={{fontSize: '0.9em'}}>
{currentCollection.completed || 0} of {currentCollection.total || 0} files
</p>
</Grid.Column>
</Grid.Row>
<div>
<strong>Currently Processing:</strong> {currentCollection.name}
<Progress percent={currentCollection.percent || 0} color='blue'/>
<p style={{fontSize: '0.9em'}}>
{currentCollection.completed || 0} of {currentCollection.total || 0} files
</p>
</div>
)}
{status.status === 'complete' && (
<Grid.Row>
<Grid.Column>
<Message success>
<Message.Header>Batch Reorganization Complete</Message.Header>
<p>All {kindLabelPlural.toLowerCase()} have been reorganized successfully.</p>
</Message>
</Grid.Column>
</Grid.Row>
<Message kind='success' title='Batch Reorganization Complete'>
<p>All {kindLabelPlural.toLowerCase()} have been reorganized successfully.</p>
</Message>
)}
{status.status === 'failed' && status.failed_collection && (
<Grid.Row>
<Grid.Column>
<Message negative>
<Message.Header>Reorganization Failed</Message.Header>
<p>
Failed on {kindLabel.toLowerCase()}: <strong>{status.failed_collection.name}</strong>
</p>
<SButton
as={Link}
to={kind === 'channel'
? `/videos/channel/${status.failed_collection.channel_id || status.failed_collection.id}/edit`
: `/archives/domain/${status.failed_collection.id}/edit`
}
size='small'
>
<Icon name='eye'/> View {kindLabel}
</SButton>
{status.error && (
<p style={{whiteSpace: 'pre-wrap'}}>Error: {status.error}</p>
)}
</Message>
</Grid.Column>
</Grid.Row>
<Message kind='error' title='Reorganization Failed'>
<p>
Failed on {kindLabel.toLowerCase()}: <strong>{status.failed_collection.name}</strong>
</p>
<Button
component={Link}
to={kind === 'channel'
? `/videos/channel/${status.failed_collection.channel_id || status.failed_collection.id}/edit`
: `/archives/domain/${status.failed_collection.id}/edit`
}
role='cancel'
icon='eye'
size='sm'
>
View {kindLabel}
</Button>
{status.error && (
<p style={{whiteSpace: 'pre-wrap'}}>Error: {status.error}</p>
)}
</Message>
)}
</Grid>
</Stack>
);
};
@ -361,7 +327,7 @@ export function BatchReorganizeModal({
open={open}
onClose={handleClose}
closeIcon={true}
closeOnDimmerClick={!isInProgress}
closeOnClickOutside={!isInProgress}
closeOnEscape={!isInProgress}
size='large'
>
@ -369,19 +335,10 @@ export function BatchReorganizeModal({
Reorganize All {kindLabelPlural}
</Modal.Header>
<Modal.Content scrolling>
{loading && (
<Message icon>
<Icon name='circle notched' loading/>
<Message.Content>
<Message.Header>Loading Preview</Message.Header>
Analyzing {kindLabelPlural.toLowerCase()}...
</Message.Content>
</Message>
)}
{loading && <Loading>Analyzing {kindLabelPlural.toLowerCase()}...</Loading>}
{error && !status?.failed_collection && (
<Message negative>
<Message.Header>Error</Message.Header>
<Message kind='error' title='Error'>
<p>{error}</p>
</Message>
)}
@ -390,12 +347,12 @@ export function BatchReorganizeModal({
{batchJobId && renderProgress()}
</Modal.Content>
<Modal.Actions>
<Button onClick={handleClose}>
<Button role='cancel' onClick={handleClose}>
{status?.status === 'complete' ? 'Close' : isInProgress ? 'Hide' : 'Cancel'}
</Button>
{canReorganize && (
<APIButton
color='violet'
role='primary'
onClick={handleReorganize}
obeyWROLMode={true}
>

View file

@ -68,7 +68,7 @@ describe('BatchReorganizeModal', () => {
renderWithProviders(<BatchReorganizeModal {...defaultProps} />);
// Should show loading initially
expect(screen.getByText(/Loading Preview/i)).toBeInTheDocument();
expect(screen.getByText(/Analyzing channels/i)).toBeInTheDocument();
// Wait for preview to load
await waitFor(() => {

View file

@ -1,7 +1,5 @@
import React, {useCallback, useEffect, useState} from 'react';
import {Button as SButton, Grid, Icon, Label, Progress} from 'semantic-ui-react';
import Message from 'semantic-ui-react/dist/commonjs/collections/Message';
import {Button, Modal, Table} from '../Theme';
import {Button, Icon, Label, Loading, Message, Modal, Progress, Stack, Table} from '../ui';
import {APIButton} from '../Common';
import {
executeCollectionReorganization,
@ -271,154 +269,124 @@ export function CollectionReorganizeModal({
if (!preview) return null;
return (
<Grid columns={1}>
<Stack>
{/* Warning when collection appears organized but has files to move */}
{preview.files_needing_move > 0 && !needsReorganization && (
<Grid.Row>
<Grid.Column>
<Message warning>
<Message.Header>Collection Appears Organized</Message.Header>
<p>
This collection's format matches the current configuration, but
{' '}<strong>{preview.files_needing_move}</strong> files don't match the expected
layout.
This can happen if a previous reorganization was interrupted.
</p>
</Message>
</Grid.Column>
</Grid.Row>
<Message kind='warning' title='Collection Appears Organized'>
<p>
This collection's format matches the current configuration, but
{' '}<strong>{preview.files_needing_move}</strong> files don't match the expected
layout.
This can happen if a previous reorganization was interrupted.
</p>
</Message>
)}
<Grid.Row>
<Grid.Column>
<div>
<p>
<strong>{preview.files_needing_move}</strong> of <strong>{preview.total_files}</strong> files
will be reorganized.
</p>
{preview.current_file_format && (
<p>
<strong>{preview.files_needing_move}</strong> of <strong>{preview.total_files}</strong> files
will be reorganized.
<strong>Current format:</strong> <code>{preview.current_file_format}</code>
</p>
{preview.current_file_format && (
<p>
<strong>Current format:</strong> <code>{preview.current_file_format}</code>
</p>
)}
<p>
<strong>New format:</strong> <Label>{preview.new_file_format}</Label>
</p>
</Grid.Column>
</Grid.Row>
)}
<p>
<strong>New format:</strong> <Label>{preview.new_file_format}</Label>
</p>
</div>
{/* Conflict warning */}
{preview.has_conflicts && (
<Grid.Row>
<Grid.Column>
<Message error>
<Message.Header>
<Icon name='warning sign'/> Conflicts Detected
</Message.Header>
<p>
<strong>{preview.conflicts.length}</strong> destination{' '}
{preview.conflicts.length === 1 ? 'path has' : 'paths have'}{' '}
multiple files that would collide.
You must resolve these conflicts before reorganizing.
</p>
<SButton
color='yellow'
onClick={handleResolveConflicts}
loading={loadingConflicts}
disabled={loadingConflicts}
>
<Icon name='wrench'/> Resolve Conflicts
</SButton>
</Message>
</Grid.Column>
</Grid.Row>
<Message kind='error' icon='warning sign' title='Conflicts Detected'>
<p>
<strong>{preview.conflicts.length}</strong> destination{' '}
{preview.conflicts.length === 1 ? 'path has' : 'paths have'}{' '}
multiple files that would collide.
You must resolve these conflicts before reorganizing.
</p>
<Button
role='retry'
icon='wrench'
onClick={handleResolveConflicts}
loading={loadingConflicts}
disabled={loadingConflicts}
>
Resolve Conflicts
</Button>
</Message>
)}
{preview.sample_moves && preview.sample_moves.length > 0 && (
<Grid.Row>
<Grid.Column>
<strong>Sample moves:</strong>
<Table basic='very' compact size='small'>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Current Path</Table.HeaderCell>
<Table.HeaderCell/>
<Table.HeaderCell>New Path</Table.HeaderCell>
<div>
<strong>Sample moves:</strong>
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Current Path</Table.HeaderCell>
<Table.HeaderCell/>
<Table.HeaderCell>New Path</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
{preview.sample_moves.map((move, idx) => (
<Table.Row key={idx}>
<Table.Cell style={{wordBreak: 'break-all'}}>
{move.old_path}
</Table.Cell>
<Table.Cell>
<Icon name='arrow right'/>
</Table.Cell>
<Table.Cell style={{wordBreak: 'break-all'}}>
{move.new_path}
</Table.Cell>
</Table.Row>
</Table.Header>
<Table.Body>
{preview.sample_moves.map((move, idx) => (
<Table.Row key={idx}>
<Table.Cell style={{wordBreak: 'break-all'}}>
{move.old_path}
</Table.Cell>
<Table.Cell>
<Icon name='arrow right'/>
</Table.Cell>
<Table.Cell style={{wordBreak: 'break-all'}}>
{move.new_path}
</Table.Cell>
</Table.Row>
))}
</Table.Body>
</Table>
{preview.files_needing_move > preview.sample_moves.length && (
<p style={{fontStyle: 'italic'}}>
...and {preview.files_needing_move - preview.sample_moves.length} more files
</p>
)}
</Grid.Column>
</Grid.Row>
))}
</Table.Body>
</Table>
{preview.files_needing_move > preview.sample_moves.length && (
<p style={{fontStyle: 'italic'}}>
...and {preview.files_needing_move - preview.sample_moves.length} more files
</p>
)}
</div>
)}
{preview.files_needing_move === 0 && (
<Grid.Row>
<Grid.Column>
<Message info>
<Message.Header>No Files Need Reorganization</Message.Header>
<p>
All files are already organized according to the current format.
{needsReorganization && ' Click "Mark as Organized" to dismiss the warning.'}
</p>
</Message>
</Grid.Column>
</Grid.Row>
<Message kind='info' title='No Files Need Reorganization'>
<p>
All files are already organized according to the current format.
{needsReorganization && ' Click "Mark as Organized" to dismiss the warning.'}
</p>
</Message>
)}
</Grid>
</Stack>
);
};
const renderProgress = () => {
if (!status) return null;
const progressColor = status.status === 'complete' ? 'green' : status.status === 'error' ? 'red' : 'blue';
return (
<Grid columns={1}>
<Grid.Row>
<Grid.Column>
<p>
<strong>Status:</strong> {status.status}
</p>
<Progress
percent={status.percent || 0}
progress
indicating={status.status !== 'complete'}
success={status.status === 'complete'}
/>
<p>
{status.completed || 0} of {status.total || 0} files processed
</p>
</Grid.Column>
</Grid.Row>
<Stack>
<div>
<p>
<strong>Status:</strong> {status.status}
</p>
<Progress percent={status.percent || 0} color={progressColor}/>
<p>
{status.completed || 0} of {status.total || 0} files processed
</p>
</div>
{status.status === 'complete' && (
<Grid.Row>
<Grid.Column>
<Message success>
<Message.Header>Reorganization Complete</Message.Header>
<p>All files have been reorganized successfully.</p>
</Message>
</Grid.Column>
</Grid.Row>
<Message kind='success' title='Reorganization Complete'>
<p>All files have been reorganized successfully.</p>
</Message>
)}
</Grid>
</Stack>
);
};
@ -433,7 +401,7 @@ export function CollectionReorganizeModal({
open={open}
onClose={handleClose}
closeIcon={true}
closeOnDimmerClick={!isInProgress}
closeOnClickOutside={!isInProgress}
closeOnEscape={!isInProgress}
size='fullscreen'
>
@ -441,19 +409,10 @@ export function CollectionReorganizeModal({
Reorganize Files: {collectionName}
</Modal.Header>
<Modal.Content>
{loading && (
<Message icon>
<Icon name='circle notched' loading/>
<Message.Content>
<Message.Header>Loading Preview</Message.Header>
Analyzing files...
</Message.Content>
</Message>
)}
{loading && <Loading>Analyzing files...</Loading>}
{error && (
<Message negative>
<Message.Header>Error</Message.Header>
<Message kind='error' title='Error'>
<p style={{whiteSpace: 'pre-wrap'}}>{error}</p>
</Message>
)}
@ -462,12 +421,12 @@ export function CollectionReorganizeModal({
{status && renderProgress()}
</Modal.Content>
<Modal.Actions>
<Button onClick={handleClose}>
<Button role='cancel' onClick={handleClose}>
{status?.status === 'complete' ? 'Close' : isInProgress ? 'Hide' : 'Cancel'}
</Button>
{canReorganize && (
<APIButton
color='violet'
role='primary'
onClick={handleReorganize}
obeyWROLMode={true}
>
@ -476,7 +435,7 @@ export function CollectionReorganizeModal({
)}
{canMarkAsOrganized && (
<APIButton
color='green'
role='save'
onClick={handleReorganize}
obeyWROLMode={true}
>

View file

@ -65,7 +65,7 @@ describe('CollectionReorganizeModal', () => {
renderWithProviders(<CollectionReorganizeModal {...defaultProps} />);
// Should show loading initially
expect(screen.getByText(/Loading Preview/i)).toBeInTheDocument();
expect(screen.getByText(/Analyzing files/i)).toBeInTheDocument();
// Wait for preview to load
await waitFor(() => {

View file

@ -1,11 +1,10 @@
import React, {useContext} from 'react';
import {Link} from 'react-router';
import {Message, PlaceholderHeader, PlaceholderLine, TableCell, TableRow} from 'semantic-ui-react';
import {Placeholder, Table} from '../Theme';
import {Button, Message, Placeholder, Table} from '../ui';
import _ from 'lodash';
import {SortableTable} from '../SortableTable';
import {formatFrequency, humanFileSize} from '../Common';
import {Media, ThemeContext} from '../../contexts/contexts';
import {Media} from '../../contexts/contexts';
import {TagsContext} from '../../Tags';
/**
@ -46,17 +45,25 @@ function getCollectionSearchLink(collection, routes, primaryKey) {
return null;
}
/**
* Convert a Semantic-style relative column width (1-16) into a CSS percentage.
* @param {number} width - Relative width, 1-16
* @returns {Object|undefined} A style object, or undefined when no width is configured
*/
function widthStyle(width) {
return width ? {width: `${(width / 16) * 100}%`} : undefined;
}
/**
* Render a single table row for desktop view.
*
* @param {Object} collection - The collection data
* @param {Array} columns - Column configurations
* @param {Object} routes - Routes configuration
* @param {string} inverted - Inverted theme class
* @param {Function} SingleTag - Tag component from context
* @param {Function} onRowClick - Optional click handler
*/
function renderRow(collection, columns, routes, inverted, SingleTag, onRowClick) {
function renderRow(collection, columns, routes, SingleTag, onRowClick) {
const cells = columns.map((col) => {
let value = collection[col.key];
@ -64,9 +71,8 @@ function renderRow(collection, columns, routes, inverted, SingleTag, onRowClick)
if (col.type === 'actions') {
const idField = getIdField(routes);
const editRoute = routes?.edit?.replace(':id', collection[idField]);
const buttonClass = `ui button secondary ${inverted}`;
return <Table.Cell key={col.key} textAlign={col.align || 'right'} width={col.width}>
{editRoute && <Link className={buttonClass} to={editRoute}>Edit</Link>}
return <Table.Cell key={col.key} style={{textAlign: col.align || 'right', ...widthStyle(col.width)}}>
{editRoute && <Button role='cancel' component={Link} to={editRoute} size='sm'>Edit</Button>}
</Table.Cell>;
}
@ -90,7 +96,7 @@ function renderRow(collection, columns, routes, inverted, SingleTag, onRowClick)
}
}
return <Table.Cell key={col.key} textAlign={col.align || 'left'} width={col.width}>
return <Table.Cell key={col.key} style={{textAlign: col.align || 'left', ...widthStyle(col.width)}}>
{value || '-'}
</Table.Cell>;
});
@ -114,8 +120,8 @@ function MobileCollectionRow({collection, mobileColumns, routes}) {
const editRoute = routes?.edit?.replace(':id', collection[idField]);
const searchLink = getCollectionSearchLink(collection, routes, primaryColumn.key);
return <TableRow verticalAlign='top'>
<TableCell>
return <Table.Row style={{verticalAlign: 'top'}}>
<Table.Cell>
{searchLink ? (
<Link to={searchLink}>
<strong>{collection[primaryColumn.key]}</strong>
@ -140,11 +146,11 @@ function MobileCollectionRow({collection, mobileColumns, routes}) {
);
})
}
</TableCell>
<TableCell textAlign='right'>
{editRoute && <Link className="ui button secondary" to={editRoute}>Edit</Link>}
</TableCell>
</TableRow>;
</Table.Cell>
<Table.Cell style={{textAlign: 'right'}}>
{editRoute && <Button role='cancel' component={Link} to={editRoute} size='sm'>Edit</Button>}
</Table.Cell>
</Table.Row>;
}
/**
@ -165,38 +171,26 @@ export function CollectionTable({
onRowClick,
emptyMessage = 'No items yet'
}) {
const {inverted} = useContext(ThemeContext);
const {SingleTag} = useContext(TagsContext);
// Loading state
if (collections === null) {
return <Placeholder>
<PlaceholderHeader>
<PlaceholderLine/>
<PlaceholderLine/>
</PlaceholderHeader>
</Placeholder>;
return <Placeholder lines={2}/>;
}
// Error state
if (collections === undefined) {
return <Message error>
<Message.Header>Could not fetch collections</Message.Header>
</Message>;
return <Message kind='error' title='Could not fetch collections'/>;
}
// Empty state
if (collections && collections.length === 0) {
return <Message>
<Message.Header>{emptyMessage}</Message.Header>
</Message>;
return <Message title={emptyMessage}/>;
}
// No columns configured
if (!columns || columns.length === 0) {
return <Message warning>
<Message.Header>No columns configured</Message.Header>
</Message>;
return <Message kind='warning' title='No columns configured'/>;
}
// Filter collections by search string
@ -244,7 +238,7 @@ export function CollectionTable({
return <>
<Media at='mobile'>
<SortableTable
tableProps={{striped: true, size: 'small', unstackable: true}}
tableProps={{striped: true, size: 'sm'}}
data={filteredCollections}
rowFunc={(collection) => <MobileCollectionRow key={collection.id} collection={collection}
mobileColumns={mobileColumns} routes={routes}/>}
@ -255,9 +249,9 @@ export function CollectionTable({
</Media>
<Media greaterThanOrEqual='tablet'>
<SortableTable
tableProps={{striped: true, size: 'large', unstackable: true, compact: true}}
tableProps={{striped: true, size: 'lg', verticalSpacing: 'xs'}}
data={filteredCollections}
rowFunc={(collection) => renderRow(collection, columns, routes, inverted, SingleTag, onRowClick)}
rowFunc={(collection) => renderRow(collection, columns, routes, SingleTag, onRowClick)}
rowKey='id'
tableHeaders={headers}
defaultSortColumn={defaultSortColumn}

View file

@ -26,23 +26,28 @@ jest.mock('../../contexts/contexts', () => ({
},
}));
// Mock SortableTable to simplify testing
jest.mock('../SortableTable', () => ({
SortableTable: ({data, rowFunc, tableHeaders}) => (
<table data-testid="sortable-table">
<thead>
<tr>
{tableHeaders.map(h => (
<th key={h.key} data-width={h.width}>{h.text}</th>
))}
</tr>
</thead>
<tbody>
{data.map(item => rowFunc(item))}
</tbody>
</table>
),
}));
// Mock SortableTable to simplify testing. Uses the real `Table` compound
// components (rather than raw <table>/<tr>/<td>) because `rowFunc` returns
// `Table.Row`/`Table.Cell` elements that read Mantine's table context.
jest.mock('../SortableTable', () => {
const {Table} = jest.requireActual('../ui');
return {
SortableTable: ({data, rowFunc, tableHeaders}) => (
<Table data-testid="sortable-table">
<Table.Header>
<Table.Row>
{tableHeaders.map(h => (
<Table.HeaderCell key={h.key} data-width={h.width}>{h.text}</Table.HeaderCell>
))}
</Table.Row>
</Table.Header>
<Table.Body>
{data.map(item => rowFunc(item))}
</Table.Body>
</Table>
),
};
});
// Test column and routes configurations
const DOMAIN_COLUMNS = [
@ -73,7 +78,7 @@ describe('CollectionTable', () => {
/>
);
expect(container.querySelector('.ui.placeholder')).toBeInTheDocument();
expect(container.querySelector('.mantine-Skeleton-root')).toBeInTheDocument();
});
it('renders error message when collections is undefined', () => {

View file

@ -1,7 +1,6 @@
import React, {useEffect, useState} from 'react';
import {Card, Grid, Icon, Image, Label, Segment, Button as SButton} from 'semantic-ui-react';
import Message from 'semantic-ui-react/dist/commonjs/collections/Message';
import {Button, Modal} from '../Theme';
import {IconVideo} from '@tabler/icons-react';
import {Button, Icon, IconButton, Label, Message, Modal, Panel, Stack} from '../ui';
import {deleteFileGroups} from '../../api';
import {humanFileSize, isoDatetimeToString} from '../Common';
import {TaggedDeleteConfirmModal} from '../TaggedDeleteConfirmModal';
@ -57,92 +56,91 @@ function ConflictFileCard({file, onDelete, isRecommended}) {
};
return (
<Card fluid>
<Card.Content>
{localError && (
<Message negative size='small' style={{marginBottom: '0.5em'}}>
<Icon name='warning'/> {localError}
<Panel style={{marginBottom: '0.5em'}}>
{localError && (
<div style={{marginBottom: '0.5em'}}>
<Message kind='error' icon='warning'>
{localError}
</Message>
)}
<Grid>
<Grid.Row>
{/* Poster/Thumbnail column */}
<Grid.Column width={4}>
{file.poster_path ? (
<Image
src={`/media/${file.poster_path}`}
size='small'
style={{maxHeight: '100px', objectFit: 'cover'}}
/>
) : (
<Segment placeholder style={{height: '80px'}}>
<Icon
name={file.model_type === 'video' ? 'video' : 'file'}
size='large'
disabled
/>
</Segment>
)}
</Grid.Column>
</div>
)}
<div style={{display: 'flex', gap: '1em', alignItems: 'center'}}>
{/* Poster/Thumbnail column */}
<div style={{flex: '0 0 100px'}}>
{file.poster_path ? (
<img
src={`/media/${file.poster_path}`}
alt=''
style={{width: '100%', height: '80px', objectFit: 'cover'}}
/>
) : (
<div style={{
height: '80px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
border: '1px solid var(--border)',
color: 'var(--muted)',
}}>
{file.model_type === 'video'
? <Icon component={IconVideo} size='large'/>
: <Icon name='file' size='large'/>}
</div>
)}
</div>
{/* File info column */}
<Grid.Column width={10}>
<Card.Header style={{marginBottom: '0.5em'}}>
{file.title || 'Untitled'}
{isRecommended && (
<Label color='green' size='small' style={{marginLeft: '0.5em'}}>
<Icon name='star'/> Recommended to Keep
</Label>
)}
</Card.Header>
<Card.Meta style={{wordBreak: 'break-all'}}>
<Icon name='folder open outline'/> {file.current_path}
</Card.Meta>
<Card.Description>
<div style={{marginTop: '0.5em'}}>
{file.size > 0 && (
<Label size='small'>
<Icon name='hdd'/> {humanFileSize(file.size)}
</Label>
)}
{file.published_datetime && (
<Label size='small'>
<Icon name='calendar'/> {isoDatetimeToString(file.published_datetime)}
</Label>
)}
{file.source_id && (
<Label size='small'>
<Icon name='linkify'/> {file.source_id}
</Label>
)}
{file.quality_rank !== null && file.quality_rank !== undefined && (
<Label size='small' color='purple'>
<Icon name='star outline'/> {file.quality_rank}
</Label>
)}
<Label size='small' color={file.model_type === 'video' ? 'blue' : 'orange'}>
{file.model_type}
</Label>
</div>
</Card.Description>
</Grid.Column>
{/* File info column */}
<div style={{flex: '1 1 auto', minWidth: 0}}>
<div style={{marginBottom: '0.5em', fontWeight: 600}}>
{file.title || 'Untitled'}
{isRecommended && (
<Label color='green' style={{marginLeft: '0.5em'}}>
<Icon name='star'/> Recommended to Keep
</Label>
)}
</div>
<div style={{wordBreak: 'break-all', color: 'var(--muted)', fontSize: '0.9em'}}>
<Icon name='folder open outline'/> {file.current_path}
</div>
<div style={{marginTop: '0.5em', display: 'flex', flexWrap: 'wrap', gap: '0.4em'}}>
{file.size > 0 && (
<Label>
<Icon name='hdd'/> {humanFileSize(file.size)}
</Label>
)}
{file.published_datetime && (
<Label>
<Icon name='calendar'/> {isoDatetimeToString(file.published_datetime)}
</Label>
)}
{file.source_id && (
<Label>
<Icon name='linkify'/> {file.source_id}
</Label>
)}
{file.quality_rank !== null && file.quality_rank !== undefined && (
<Label color='violet'>
<Icon name='star outline'/> {file.quality_rank}
</Label>
)}
<Label color={file.model_type === 'video' ? 'blue' : 'orange'}>
{file.model_type}
</Label>
</div>
</div>
{/* Delete button column */}
<Grid.Column width={2} textAlign='center' verticalAlign='middle'>
<SButton
color='red'
icon
loading={isDeleting}
disabled={isDeleting}
onClick={() => handleDelete(false)}
title='Delete this file'
>
<Icon name='trash'/>
</SButton>
</Grid.Column>
</Grid.Row>
</Grid>
</Card.Content>
{/* Delete button column */}
<div style={{flex: '0 0 auto'}}>
<IconButton
role='danger'
icon='trash'
label='Delete this file'
loading={isDeleting}
disabled={isDeleting}
onClick={() => handleDelete(false)}
/>
</div>
</div>
<TaggedDeleteConfirmModal
open={taggedFileGroups !== null}
taggedFileGroups={taggedFileGroups}
@ -152,7 +150,7 @@ function ConflictFileCard({file, onDelete, isRecommended}) {
await handleDelete(true);
}}
/>
</Card>
</Panel>
);
}
@ -212,7 +210,6 @@ export function ConflictResolutionModal({
};
const totalConflicts = localConflicts.length;
const totalFiles = localConflicts.reduce((sum, c) => sum + c.conflicting_files.length, 0);
return (
<Modal
@ -222,11 +219,10 @@ export function ConflictResolutionModal({
size='fullscreen'
>
<Modal.Header>
<Icon name='warning sign' color='yellow'/> Resolve Conflicts Before Reorganizing
<Icon name='warning sign'/> Resolve Conflicts Before Reorganizing
</Modal.Header>
<Modal.Content scrolling>
<Message warning>
<Message.Header>Destination Path Conflicts Detected</Message.Header>
<Message kind='warning' title='Destination Path Conflicts Detected'>
<p>
{totalConflicts} destination {totalConflicts === 1 ? 'path has' : 'paths have'}{' '}
multiple files that would be moved there. This typically happens when the same{' '}
@ -238,56 +234,58 @@ export function ConflictResolutionModal({
</p>
</Message>
{localConflicts.map((conflict, idx) => {
// Find the highest quality rank in this conflict (for video recommendations)
const hasRanks = conflict.conflicting_files.some(
f => f.quality_rank !== null && f.quality_rank !== undefined
);
const highestRank = hasRanks
? Math.max(...conflict.conflicting_files.map(f => f.quality_rank || 0))
: null;
// Check if there are multiple files with the same highest rank
const highestRankCount = hasRanks
? conflict.conflicting_files.filter(f => f.quality_rank === highestRank).length
: 0;
<Stack>
{localConflicts.map((conflict, idx) => {
// Find the highest quality rank in this conflict (for video recommendations)
const hasRanks = conflict.conflicting_files.some(
f => f.quality_rank !== null && f.quality_rank !== undefined
);
const highestRank = hasRanks
? Math.max(...conflict.conflicting_files.map(f => f.quality_rank || 0))
: null;
// Check if there are multiple files with the same highest rank
const highestRankCount = hasRanks
? conflict.conflicting_files.filter(f => f.quality_rank === highestRank).length
: 0;
return (
<Segment key={idx}>
<Label attached='top' color='grey'>
<Icon name='folder'/> Destination: {conflict.destination_path}
<Label.Detail>{conflict.conflicting_files.length} files</Label.Detail>
</Label>
return (
<Panel key={idx}>
<div style={{display: 'flex', alignItems: 'center', gap: '0.5em', marginBottom: '1em'}}>
<Icon name='folder'/>
<strong>Destination: {conflict.destination_path}</strong>
<Label>{conflict.conflicting_files.length} files</Label>
</div>
<div style={{marginTop: '1em'}}>
{conflict.conflicting_files.map((file, fileIdx) => {
// Only show "Recommended" if there's a clear winner (one file with highest rank)
const isRecommended = hasRanks &&
highestRankCount === 1 &&
file.quality_rank === highestRank;
<div>
{conflict.conflicting_files.map((file, fileIdx) => {
// Only show "Recommended" if there's a clear winner (one file with highest rank)
const isRecommended = hasRanks &&
highestRankCount === 1 &&
file.quality_rank === highestRank;
return (
<ConflictFileCard
key={file.file_group_id}
file={file}
onDelete={handleFileDelete}
isRecommended={isRecommended}
/>
);
})}
</div>
</Segment>
);
})}
return (
<ConflictFileCard
key={file.file_group_id}
file={file}
onDelete={handleFileDelete}
isRecommended={isRecommended}
/>
);
})}
</div>
</Panel>
);
})}
</Stack>
{localConflicts.length === 0 && (
<Message success>
<Message.Header>All Conflicts Resolved</Message.Header>
<Message kind='success' title='All Conflicts Resolved'>
<p>You can now proceed with the reorganization.</p>
</Message>
)}
</Modal.Content>
<Modal.Actions>
<Button onClick={handleClose}>
<Button role='cancel' onClick={handleClose}>
{localConflicts.length === 0 ? 'Done' : 'Close'}
</Button>
</Modal.Actions>