From ffd4a8c60476fe75d3c37d8323b51b4367fb7492 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 2 Oct 2026 18:42:06 -0500 Subject: show errors, toast if popup blocked --- src/web/src/components/System/Logs/Explorer.jsx | 150 +++++++++++++----------- 1 file changed, 82 insertions(+), 68 deletions(-) (limited to 'src') diff --git a/src/web/src/components/System/Logs/Explorer.jsx b/src/web/src/components/System/Logs/Explorer.jsx index ac6d982f..b1391da2 100644 --- a/src/web/src/components/System/Logs/Explorer.jsx +++ b/src/web/src/components/System/Logs/Explorer.jsx @@ -1,7 +1,12 @@ import '../Files/Files.css'; import { getFileBlob, list } from '../../../lib/logs'; import { downloadFile, formatBytes, formatDate } from '../../../lib/util'; -import { LoaderSegment } from '../../Shared'; +import { + ErrorSegment, + LoaderSegment, + PlaceholderSegment, + Switch, +} from '../../Shared'; import React, { useEffect, useState } from 'react'; import { toast } from 'react-toastify'; import { Header, Icon, Table } from 'semantic-ui-react'; @@ -9,6 +14,13 @@ import { Header, Icon, Table } from 'semantic-ui-react'; const view = async (filename) => { const tab = window.open('', '_blank'); + if (!tab) { + toast.error( + 'Unable to open a new window; allow pop-ups for this site to view logs', + ); + return; + } + try { const blob = await getFileBlob({ filename }); @@ -60,17 +72,23 @@ const FileRow = ({ length, modifiedAt, name }) => ( const Explorer = () => { const [files, setFiles] = useState([]); - const [loading, setLoading] = useState(false); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(undefined); const [sortColumn, setSortColumn] = useState('date'); const [sortDirection, setSortDirection] = useState('descending'); const fetch = async () => { setLoading(true); + setError(undefined); try { setFiles(await list()); - } catch (error) { - toast.error(error?.message ?? error); + } catch (fetchError) { + if (fetchError?.response?.status === 404) { + setFiles([]); + } else { + setError(fetchError?.message ?? fetchError); + } } finally { setLoading(false); } @@ -112,10 +130,6 @@ const Explorer = () => { }); }; - if (loading) { - return ; - } - const sortedFiles = sortItems(files); return ( @@ -127,74 +141,74 @@ const Explorer = () => { /logs - + ) + } + error={error && } + loading={loading && } > - - - handleSort('name')} - style={{ cursor: 'pointer' }} - > - Name - {sortColumn === 'name' && ( - - )} - - handleSort('date')} - style={{ cursor: 'pointer' }} - > - Date Modified - {sortColumn === 'date' && ( - - )} - - - Size - - - - - - {files.length === 0 ? ( +
+ - handleSort('name')} + style={{ cursor: 'pointer' }} + > + Name + {sortColumn === 'name' && ( + + )} + + handleSort('date')} + style={{ cursor: 'pointer' }} > - No log files - + Date Modified + {sortColumn === 'date' && ( + + )} + + + Size + + - ) : ( - sortedFiles.map((f) => ( + + + {sortedFiles.map((f) => ( - )) - )} - -
+ ))} + + + ); }; -- cgit v1.2.3