diff --git a/public/locales/en/files.json b/public/locales/en/files.json index 4a2dee8bd..a50098709 100644 --- a/public/locales/en/files.json +++ b/public/locales/en/files.json @@ -185,5 +185,14 @@ }, "noPinsInProgress": "All done, no remote pins in progress.", "remotePinningInProgress": "Remote pinning in progress:", - "selectAllEntries": "Select all entries" + "selectAllEntries": "Select all entries", + "previewNotFound": { + "title": "IPFS can't find this item", + "helpTitle": "These are common troubleshooting steps might help:", + "helpListItemPathTypo": "Are there typos in the path you entered?", + "helpListItemFileMoved": "Was the file moved, renamed, or deleted?", + "helpListItemBookmarkMigrated": "Did you copy a URL or bookmark from another computer? If so, you'll need to", + "helpListItemBookmarkMigratedLink": "point this instance at that computer's node", + "backButton": "Go to Home" + } } diff --git a/src/bundles/files/actions.js b/src/bundles/files/actions.js index 381bd3fca..bc59e465c 100644 --- a/src/bundles/files/actions.js +++ b/src/bundles/files/actions.js @@ -221,8 +221,19 @@ const actions = () => ({ ? await last(ipfs.name.resolve(realPath)) : realPath - const stats = await stat(ipfs, resolvedPath) const time = Date.now() + /** @type {Stat} */ + let stats + try { + stats = await stat(ipfs, resolvedPath) + } catch (error) { + console.error(`Error fetching stats for path "${resolvedPath}":`, error) + return { + fetched: time, + type: 'not-found', + path: resolvedPath + } + } switch (stats.type) { case 'unknown': { diff --git a/src/files/FilesPage.js b/src/files/FilesPage.js index bde0f6f0c..ede996fd1 100644 --- a/src/files/FilesPage.js +++ b/src/files/FilesPage.js @@ -14,6 +14,7 @@ import FilePreview from './file-preview/FilePreview.js' import FilesList from './files-list/FilesList.js' import FilesGrid from './files-grid/files-grid.js' import { ViewList, ViewModule } from '../icons/stroke-icons.js' +import FileNotFound from './file-not-found/index.tsx' import { getJoyrideLocales } from '../helpers/i8n.js' // Icons @@ -192,6 +193,9 @@ const FilesPage = ({ ) } + if (files.type === 'not-found') { + return + } const commonProps = { key: window.encodeURIComponent(files.path), diff --git a/src/files/file-not-found/index.tsx b/src/files/file-not-found/index.tsx new file mode 100644 index 000000000..aeb2df093 --- /dev/null +++ b/src/files/file-not-found/index.tsx @@ -0,0 +1,36 @@ +import React from 'react' +import Button from '../../components/button/button.js' +import GlyphAttention from '../../icons/GlyphAttention.js' +import { useTranslation } from 'react-i18next' + +export interface FileNotFoundProps { + path: string +} + +const FileNotFound = ({ path }: FileNotFoundProps) => { + const { t } = useTranslation('files') + + return ( +
+
+ +
{t('previewNotFound.title')}
+
+
{path}
+
{t('previewNotFound.helpTitle')}
+ + + + +
+ ) +} + +export default FileNotFound