diff --git a/frontend/src/components/dirent-detail/detail/body/index.css b/frontend/src/components/dirent-detail/detail/body/index.css index 9dcfb94242..d3b588cd89 100644 --- a/frontend/src/components/dirent-detail/detail/body/index.css +++ b/frontend/src/components/dirent-detail/detail/body/index.css @@ -6,3 +6,11 @@ overflow-x: hidden; padding: 8px; } + +.detail-body.dirent-info.error { + width: 100%; + height: 100%; + display: flex; + align-items: center; + justify-content: center; +} diff --git a/frontend/src/components/search/details/index.js b/frontend/src/components/search/details/index.js index 51ab82c3d4..c7c3c2ddc6 100644 --- a/frontend/src/components/search/details/index.js +++ b/frontend/src/components/search/details/index.js @@ -8,12 +8,15 @@ import { Repo } from '../../../models'; import { MetadataStatusProvider } from '../../../hooks'; import Details from './details'; import LibDetail from '../../dirent-detail/lib-details'; +import { Body, Header } from '../../dirent-detail/detail'; +import { gettext } from '../../../utils/constants'; import './index.css'; const SearchedItemDetails = ({ repoID, path, dirent }) => { const [repoInfo, setRepoInfo] = useState(null); const [direntDetail, setDirentDetail] = useState(null); + const [errMessage, setErrMessage] = useState(null); useEffect(() => { seafileAPI.getRepoInfo(repoID).then(res => { @@ -31,6 +34,7 @@ const SearchedItemDetails = ({ repoID, path, dirent }) => { const fetchData = async () => { if (!repoID || !path || !dirent || dirent.isLib) { setDirentDetail(null); + setErrMessage(null); return; } @@ -41,11 +45,18 @@ const SearchedItemDetails = ({ repoID, path, dirent }) => { { signal: controller.signal } ); setDirentDetail(res.data); + setErrMessage(null); } catch (error) { - if (error.name !== 'AbortError') { - const errMessage = Utils.getErrorMsg(error); - toaster.danger(errMessage); + if (error.name === 'AbortError') { + return; // Ignore abort errors } + if (error.response && error.response.status === 404) { + const err = `${dirent.type === 'file' ? 'File' : 'Folder'} does not exist`; + setErrMessage(err); + return; + } + const errMessage = Utils.getErrorMsg(error); + toaster.danger(errMessage); } }; @@ -59,6 +70,22 @@ const SearchedItemDetails = ({ repoID, path, dirent }) => { if (!repoInfo) return; + if (errMessage) { + return ( +