-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(materials): display custom error page when file or folder is miss…
…ing in course materials
- Loading branch information
1 parent
80f1e6b
commit 2df7c03
Showing
7 changed files
with
105 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { LoaderFunction, redirect } from 'react-router-dom'; | ||
import { getIdFromUnknown } from 'utilities'; | ||
|
||
import CourseAPI from 'api/course'; | ||
|
||
const folderLoader: LoaderFunction = async ({ params }) => { | ||
const folderId = getIdFromUnknown(params?.folderId); | ||
if (!folderId) return redirect('/'); | ||
|
||
const { data } = await CourseAPI.folders.fetch(folderId); | ||
|
||
return data; | ||
}; | ||
|
||
export default folderLoader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
client/app/bundles/course/material/folders/pages/ErrorRetrievingFolderPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React from 'react'; | ||
import { defineMessages } from 'react-intl'; | ||
import { useParams } from 'react-router-dom'; | ||
import { Cancel, FolderOutlined } from '@mui/icons-material'; | ||
|
||
import Link from 'lib/components/core/Link'; | ||
import useTranslation from 'lib/hooks/useTranslation'; | ||
|
||
import BaseRetrievePage from '../../BaseRetrieveMaterialPage'; | ||
|
||
const translations = defineMessages({ | ||
problemRetrievingFolder: { | ||
id: 'course.material.folders.ErrorRetrievingFolderPage.problemRetrievingFolder', | ||
defaultMessage: 'Problem retrieving folder', | ||
}, | ||
problemRetrievingFolderDescription: { | ||
id: 'course.material.folders.ErrorRetrievingFolderPage.problemRetrievingFolderDescription', | ||
defaultMessage: | ||
"Either it no longer exists, you don't have the permission to access it, or something unexpected happened when we were trying to retrieve it.", | ||
}, | ||
goToTheWorkbin: { | ||
id: 'course.material.folders.ErrorRetrievingFolderPage.goToTheWorkbin', | ||
defaultMessage: 'Go to the Workbin', | ||
}, | ||
}); | ||
|
||
const ErrorRetrievingFolderPage = (): JSX.Element => { | ||
const { t } = useTranslation(); | ||
|
||
const params = useParams(); | ||
const workbinURL = `/courses/${params.courseId}`; | ||
|
||
return ( | ||
<BaseRetrievePage | ||
description={t(translations.problemRetrievingFolderDescription)} | ||
illustration={ | ||
<div className="relative"> | ||
<FolderOutlined className="text-[6rem]" color="disabled" /> | ||
|
||
<Cancel | ||
className="absolute bottom-0 -right-2 text-[4rem] bg-white rounded-full" | ||
color="error" | ||
/> | ||
</div> | ||
} | ||
title={t(translations.problemRetrievingFolder)} | ||
> | ||
<Link className="mt-10" to={workbinURL}> | ||
{t(translations.goToTheWorkbin)} | ||
</Link> | ||
</BaseRetrievePage> | ||
); | ||
}; | ||
|
||
export default ErrorRetrievingFolderPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters