From 93f38b1c4c9f24d4fc233a7d0cd28247cc503b84 Mon Sep 17 00:00:00 2001 From: Roland Date: Thu, 30 Jul 2026 13:13:06 -0600 Subject: [PATCH] ui: migrate Archive.js off Semantic UI React Replaces every semantic-ui-react and ./Theme import with the token-driven ./ui library: Segment->Panel, Tab/Tab.Pane->Tabs (Tabs.List/Tabs.Tab/ Tabs.Panel), Loader active inline='centered'->Loading, Message/Message.Header ->Message kind/title, Statistic/StatisticValue/StatisticLabel->Statistic value/label, Card/CardContent/CardHeader/CardMeta/CardDescription->Card media/title/meta/children, Input label={...}->ActionInput action={...}, Form.Dropdown->Select, Form/Form.Field/TextArea->plain markup + Textarea. Converts all three Semantic grid spellings (Grid.Row/Grid.Column, bare GridRow/GridColumn) to flexbox for the two-up rows in ArchivePage and DomainsPage, and to plain "row"/"column" divs (CollectionEditForm's existing CSS-class convention, shared with still-unmigrated Channels.js/Playlists.js) for the fields passed into CollectionEditForm in DomainEditPage. ArchiveFileNameForm no longer goes through hooks/useForm's InputForm helper, which still renders Semantic's Form.Input internally (hooks/useForm.js is off-limits for this migration) -- it now builds its field directly against form.getInputProps, mirroring the pattern Download.js already established. Drops ThemeContext's obsolete i/s/t/inverted spreads throughout, and the mimetype-color accent on Card (the new Card has no color prop; Videos.js's already-migrated VideoCard dropped the same accent for the same reason). Co-Authored-By: Claude Opus 5 (1M context) --- app/src/components/Archive.js | 696 ++++++++++++++++------------------ 1 file changed, 335 insertions(+), 361 deletions(-) diff --git a/app/src/components/Archive.js b/app/src/components/Archive.js index 78470c7c..a2aff695 100644 --- a/app/src/components/Archive.js +++ b/app/src/components/Archive.js @@ -1,24 +1,5 @@ -import React, {useContext, useState} from "react"; +import React, {useState} from "react"; import {useHotkeys} from "react-hotkeys-hook"; -import { - CardContent, - CardDescription, - CardHeader, - CardMeta, - Container, - Form, - GridColumn, - GridRow, - Image, - Input, - PlaceholderHeader, - PlaceholderLine, - StatisticLabel, - StatisticValue, - TableCell, - TextArea, -} from "semantic-ui-react"; -import Icon from "semantic-ui-react/dist/commonjs/elements/Icon"; import { APIButton, BackButton, @@ -33,7 +14,6 @@ import { humanNumber, InfoHeader, isoDatetimeToAgoPopup, - mimetypeColor, PageContainer, PreviewPath, resolveDataPath, @@ -58,14 +38,13 @@ import { untagFileGroup, updateArchiveDownloaderConfig, } from "../api"; -import {InputForm, useForm} from "../hooks/useForm"; +import {useForm} from "../hooks/useForm"; import {TaggedDeleteConfirmModal} from "./TaggedDeleteConfirmModal"; import {CollectionTagModal} from "./collections/CollectionTagModal"; import {CollectionReorganizeModal} from "./collections/CollectionReorganizeModal"; import {BatchReorganizeModal} from "./collections/BatchReorganizeModal"; import {useReorganizationStatus} from "../contexts/FileWorkerStatusContext"; import {Link, Route, Routes, useLocation, useNavigate, useParams} from "react-router"; -import Message from "semantic-ui-react/dist/commonjs/collections/Message"; import { useArchive, useArchiveStatistics, @@ -78,14 +57,32 @@ import { useSearchOrder } from "../hooks/customHooks"; import {DeepSearchHint, FileCards, FileRowTagIcon, FilesView, SearchControlBar} from "./Files"; -import Grid from "semantic-ui-react/dist/commonjs/collections/Grid"; import _ from "lodash"; -import {ThemeContext} from "../contexts/contexts"; -import {Button, Card, darkTheme, Header, Loader, Placeholder, Popup, Segment, Statistic, Tab} from "./Theme"; +import { + ActionInput, + Button, + Card, + Header, + Icon, + IconButton, + Loader, + Loading, + Message, + Panel, + Placeholder, + Select, + Statistic, + StatisticGroup, + Table, + Tabs, + Textarea, + TextInput, + Tooltip, + toast, +} from "./ui"; import {BulkTagModal} from "./BulkTagModal"; -import {taggedImageLabel, TagsSelector} from "../Tags"; +import {TagsSelector} from "../Tags"; import {AddToPlaylistButton} from "./AddToPlaylist"; -import {toast} from "./ui"; import {API_ARCHIVE_UPLOAD_URI, Downloaders} from "./Vars"; import {CollectionTable} from "./collections/CollectionTable"; import {CollectionEditForm} from "./collections/CollectionEditForm"; @@ -96,14 +93,13 @@ function ArchivePage() { const navigate = useNavigate(); const {fileGroupId} = useParams(); const {archiveFile, history, fetchArchive} = useArchive(fileGroupId); - const {theme} = useContext(ThemeContext); const [taggedFileGroups, setTaggedFileGroups] = useState(null); let title = archiveFile ? archiveFile.title ? archiveFile.title : archiveFile.name : null; useTitle(title); if (archiveFile === null) { - return ; + return Loading archive...; } if (archiveFile === undefined) { return <> @@ -124,14 +120,15 @@ function ArchivePage() { const screenshotUrl = screenshotPath ? `/media/${encodeMediaPath(screenshotPath)}` : null; const singlefileButton = - ; const readButton = - const screenshot = screenshotUrl ? - : + Archive screenshot : null; const localDeleteArchive = async (force = false) => { @@ -171,7 +168,6 @@ function ArchivePage() { } const updateButton = ; const deleteButton = localDeleteArchive(false)} obeyWROLMode={true} > Delete ; const generateScreenshotButton = !screenshotUrl ? : null; - let historyList = ; + let historyList = ; if (history && history.length === 0) { historyList =

No history available

; } else if (history) { @@ -237,28 +231,12 @@ function ArchivePage() { ? isoDatetimeToAgoPopup(archiveFile.published_modified_datetime, true) : 'unknown'; - const aboutPane = { - menuItem: 'About', render: () => -
Domain
- {domainHeader} - -
Size
- {humanFileSize(size)} - -
URL
-

{archiveFile.url ? {archiveFile.url} : 'N/A'}

- -
Modified Date
-

{modifiedDatetimeString}

-
- }; - // Helper to find file size from the files array by resolved path const findFileSize = (resolvedPath) => { if (!resolvedPath || !archiveFile.files) return null; const file = archiveFile.files.find(i => String(i.path) === String(resolvedPath)); return file && file.size - ? ({humanFileSize(file.size)}) + ? ({humanFileSize(file.size)}) : null; }; @@ -275,51 +253,11 @@ function ArchivePage() { const tableStyle = {width: '100%', borderCollapse: 'separate', borderSpacing: '0 0.7em'}; const labelStyle = {whiteSpace: 'nowrap', paddingRight: '1.5em', verticalAlign: 'top'}; - const filesPane = { - menuItem: 'Files', render: () => - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Singlefile File{localPreviewPath(data.singlefile_path, 'text/html')}
Readability File{localPreviewPath(data.readability_path, 'text/html')}
Readability Text File{localPreviewPath(data.readability_txt_path, 'text/plain')}
Readability JSON File{localPreviewPath(data.readability_json_path, 'application/json')}
Screenshot File - {screenshotPath - ? <>{screenshotPath}{findFileSize(screenshotPath)} - : 'Unknown'} -
Directory
-
- }; - - const tabPanes = [aboutPane, filesPane]; - const tabMenu = theme === darkTheme ? {inverted: true, attached: true} : {attached: true}; return <> - + {screenshot}
{textEllipsis(archiveFile.title || data.url)}
@@ -327,16 +265,14 @@ function ArchivePage() {
Author: {archiveFile.author ? archiveFile.author : 'unknown'}
- - - -
Published: {publishedDatetimeString}
-
- -
Downloaded: {downloadDatetimeString}
-
-
-
+
+
+
Published: {publishedDatetimeString}
+
+
+
Downloaded: {downloadDatetimeString}
+
+
{singlefileButton} {readButton} @@ -344,25 +280,78 @@ function ArchivePage() { {deleteButton} {generateScreenshotButton} -
+ - + - + - + + + About + Files + + +
Domain
+ {domainHeader} - +
Size
+ {humanFileSize(size)} + +
URL
+

{archiveFile.url ? {archiveFile.url} : 'N/A'}

+ +
Modified Date
+

{modifiedDatetimeString}

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Singlefile File{localPreviewPath(data.singlefile_path, 'text/html')}
Readability File{localPreviewPath(data.readability_path, 'text/html')}
Readability Text File{localPreviewPath(data.readability_txt_path, 'text/plain')}
Readability JSON File{localPreviewPath(data.readability_json_path, 'application/json')}
Screenshot File + {screenshotPath + ? <>{screenshotPath}{findFileSize(screenshotPath)} + : 'Unknown'} +
Directory
+
+
+ + {historyList} - + ; - const imageLabel = file.tags && file.tags.length ? taggedImageLabel : null; + // Marks a tagged file, pinned to the poster's corner (same convention as CardPoster). + const cardTagIcon =
; + const imageLabel = !_.isEmpty(file.tags) ? cardTagIcon : null; + + let media; if (imageSrc) { - screenshot = ; + media = +
+ {imageLabel} + +
+
; + } else { + media = +
+ {imageLabel} + +
+
; } const domain = data ? data.domain : null; const domainUrl = `/archives?domain=${domain}`; const title = file.title || data.url; - const header = {title}; + const titleElm = + {title} + ; const dt = file.published_datetime || file.published_modified_datetime || file.modified; - return + + const meta = <> + {domain &&
+ {domain} +
}
- - {screenshot} - + {sortField === 'published_modified_datetime' + ? isoDatetimeToAgoPopup(file.published_modified_datetime, false) + : sortField === 'download_datetime' + ? isoDatetimeToAgoPopup(file.download_datetime, false) + : sortField === 'size' + ? humanFileSize(file.size) + : sortField === 'viewed' + ? isoDatetimeToAgoPopup(file.viewed, false) + : isoDatetimeToAgoPopup(dt, false) + } +
+ ; + + return +
+ + + +
- - - - - - - {domain && - - {domain} - } - - {sortField === 'published_modified_datetime' - ? isoDatetimeToAgoPopup(file.published_modified_datetime, false) - : sortField === 'download_datetime' - ? isoDatetimeToAgoPopup(file.download_datetime, false) - : sortField === 'size' - ? humanFileSize(file.size) - : sortField === 'viewed' - ? isoDatetimeToAgoPopup(file.viewed, false) - : isoDatetimeToAgoPopup(dt, false) - } - - - -