Skip to content

Commit

Permalink
Merge branch 'openedx:master' into jci/issue#1509
Browse files Browse the repository at this point in the history
  • Loading branch information
jciasenza authored Nov 15, 2024
2 parents 134aa93 + c20c767 commit 0b04c50
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 13 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@edx/brand": "npm:@openedx/brand-openedx@^1.2.2",
"@edx/browserslist-config": "1.2.0",
"@edx/frontend-component-header": "^5.6.0",
"@edx/frontend-lib-learning-assistant": "^2.2.4",
"@edx/frontend-lib-learning-assistant": "^2.4.1",
"@edx/frontend-lib-special-exams": "^3.1.3",
"@edx/frontend-platform": "^8.0.0",
"@edx/openedx-atlas": "^0.6.0",
Expand Down
2 changes: 1 addition & 1 deletion src/courseware/course/sequence/Unit/ContentIFrame.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import * as hooks from './hooks';
* Changes to it should be vetted by them ([email protected]).
*/
export const IFRAME_FEATURE_POLICY = (
'microphone *; camera *; midi *; geolocation *; encrypted-media *, clipboard-write *'
'microphone *; camera *; midi *; geolocation *; encrypted-media *; clipboard-write *'
);

export const testIDs = StrictDict({
Expand Down
49 changes: 49 additions & 0 deletions src/generic/PageNotFound.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { getConfig } from '@edx/frontend-platform';
import { Hyperlink } from '@openedx/paragon';
import { useIntl } from '@edx/frontend-platform/i18n';
import { logError } from '@edx/frontend-platform/logging';
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
import FooterSlot from '@openedx/frontend-slot-footer';

import HeaderSlot from '../plugin-slots/HeaderSlot';
import messages from './messages';

const PageNotFound = () => {
const { formatMessage } = useIntl();
const location = window.location.href;

logError('Page failed to load, probably an invalid URL.', location);
sendTrackEvent('edx.ui.lms.page_not_found', { location });

return (
<>
<HeaderSlot />
<main
id="main-content"
className="main-content d-flex justify-content-center align-items-center flex-column"
style={{
height: '50vh',
}}
>
<h1 className="h3">
{formatMessage(messages.pageNotFoundHeader)}
</h1>
<p>
{formatMessage(
messages.pageNotFoundBody,
{
homepageLink: (
<Hyperlink destination={getConfig().LMS_BASE_URL}>
{formatMessage(messages.homepageLink)}
</Hyperlink>
),
},
)}
</p>
</main>
<FooterSlot />
</>
);
};

export default PageNotFound;
41 changes: 41 additions & 0 deletions src/generic/PageNotFound.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { getConfig, history } from '@edx/frontend-platform';
import { Routes, Route } from 'react-router-dom';
import { sendTrackEvent } from '@edx/frontend-platform/analytics';

import {
initializeTestStore,
render,
screen,
} from '../setupTest';
import PageNotFound from './PageNotFound';
import messages from './messages';

jest.mock('@edx/frontend-platform/analytics');

describe('PageNotFound', () => {
beforeEach(async () => {
await initializeTestStore();
const invalidUrl = '/new/course';
history.push(invalidUrl);
render(
<Routes>
<Route path="*" element={<PageNotFound />} />
</Routes>,
{ wrapWithRouter: true },
);
});

it('displays page not found header', () => {
expect(screen.getByText(messages.pageNotFoundHeader.defaultMessage)).toBeVisible();
});

it('displays link back to learner dashboard', () => {
const expected = getConfig().LMS_BASE_URL;
const homepageLink = screen.getByRole('link', { name: messages.homepageLink.defaultMessage });
expect(homepageLink).toHaveAttribute('href', expected);
});

it('calls tracking events', () => {
expect(sendTrackEvent).toHaveBeenCalled();
});
});
15 changes: 15 additions & 0 deletions src/generic/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ const messages = defineMessages({
defaultMessage: 'Sign in',
description: 'Text in a button, prompting the user to log in.',
},
pageNotFoundHeader: {
id: 'learning.pageNotFound.header',
defaultMessage: 'Page not found',
description: 'Text for header notifying them that the page is not found',
},
pageNotFoundBody: {
id: 'learning.pageNotFound.body',
defaultMessage: 'The page you you were looking for was not found. Go back to the {homepageLink}.',
description: 'Text for body, prompting the user to go back to the home page',
},
homepageLink: {
id: 'learning.pageNotFound.body.homepageLink.label',
defaultMessage: 'homepage',
description: 'Text for url, telling them the page they will be navigated to',
},
});

export default messages;
3 changes: 2 additions & 1 deletion src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
getConfig,
} from '@edx/frontend-platform';
import { AppProvider, ErrorPage, PageWrap } from '@edx/frontend-platform/react';
import React from 'react';
import ReactDOM from 'react-dom';
import { Routes, Route } from 'react-router-dom';

Expand Down Expand Up @@ -35,6 +34,7 @@ import CourseAccessErrorPage from './generic/CourseAccessErrorPage';
import DecodePageRoute from './decode-page-route';
import { DECODE_ROUTES, ROUTES } from './constants';
import PreferencesUnsubscribe from './preferences-unsubscribe';
import PageNotFound from './generic/PageNotFound';

subscribe(APP_READY, () => {
ReactDOM.render(
Expand All @@ -46,6 +46,7 @@ subscribe(APP_READY, () => {
<NoticesProvider>
<UserMessagesProvider>
<Routes>
<Route path="*" element={<PageWrap><PageNotFound /></PageWrap>} />
<Route path={ROUTES.UNSUBSCRIBE} element={<PageWrap><GoalUnsubscribe /></PageWrap>} />
<Route path={ROUTES.REDIRECT} element={<PageWrap><CoursewareRedirectLandingPage /></PageWrap>} />
<Route path={ROUTES.PREFERENCES_UNSUBSCRIBE} element={<PageWrap><PreferencesUnsubscribe /></PageWrap>} />
Expand Down
4 changes: 2 additions & 2 deletions src/tab-page/LoadedTabPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const LoadedTabPage = ({
streakDiscountCouponEnabled={streakDiscountCouponEnabled}
verifiedMode={verifiedMode}
/>
<main id="main-content" className="d-flex flex-column flex-grow-1">
<main className="d-flex flex-column flex-grow-1">
<AlertList
topic="outline"
className="mx-5 mt-3"
Expand All @@ -79,7 +79,7 @@ const LoadedTabPage = ({
}}
/>
<CourseTabsNavigation tabs={tabs} className="mb-3" activeTabSlug={activeTabSlug} />
<div className="container-xl">
<div id="main-content" className="container-xl">
{children}
</div>
</main>
Expand Down

0 comments on commit 0b04c50

Please sign in to comment.