Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: SEB component integration POC #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/generic/SEBCourseAccessErrorPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, { useEffect } from 'react';

Check failure on line 1 in src/generic/SEBCourseAccessErrorPage.jsx

View workflow job for this annotation

GitHub Actions / tests

'useEffect' is defined but never used
import { LearningHeader as Header } from '@edx/frontend-component-header';
import Footer from '@edx/frontend-component-footer';
import { useParams } from 'react-router-dom';

Check failure on line 4 in src/generic/SEBCourseAccessErrorPage.jsx

View workflow job for this annotation

GitHub Actions / tests

'useParams' is defined but never used
import { useDispatch } from 'react-redux';

Check failure on line 5 in src/generic/SEBCourseAccessErrorPage.jsx

View workflow job for this annotation

GitHub Actions / tests

'useDispatch' is defined but never used
import { injectIntl } from '@edx/frontend-platform/i18n';

Check failure on line 6 in src/generic/SEBCourseAccessErrorPage.jsx

View workflow job for this annotation

GitHub Actions / tests

'/home/runner/work/frontend-app-learning/frontend-app-learning/node_modules/@edx/frontend-platform/i18n/index.js' imported multiple times
import { Alert } from '@openedx/paragon';
import { WarningFilled } from '@openedx/paragon/icons';
import { FormattedMessage } from '@edx/frontend-platform/i18n';

Check failure on line 9 in src/generic/SEBCourseAccessErrorPage.jsx

View workflow job for this annotation

GitHub Actions / tests

'/home/runner/work/frontend-app-learning/frontend-app-learning/node_modules/@edx/frontend-platform/i18n/index.js' imported multiple times

const SEBCourseAccessErrorPage = ({ intl }) => {

Check failure on line 11 in src/generic/SEBCourseAccessErrorPage.jsx

View workflow job for this annotation

GitHub Actions / tests

'intl' is missing in props validation

Check failure on line 11 in src/generic/SEBCourseAccessErrorPage.jsx

View workflow job for this annotation

GitHub Actions / tests

'intl' is defined but never used

Check failure on line 11 in src/generic/SEBCourseAccessErrorPage.jsx

View workflow job for this annotation

GitHub Actions / tests

Block must not be padded by blank lines

Check failure on line 11 in src/generic/SEBCourseAccessErrorPage.jsx

View workflow job for this annotation

GitHub Actions / tests

Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`

return (
<>
<Header />
<main id="main-content" className="container my-5 text-center" data-testid="access-denied-main">
<Alert variant="warning" icon={WarningFilled}>

Check failure on line 17 in src/generic/SEBCourseAccessErrorPage.jsx

View workflow job for this annotation

GitHub Actions / tests

Expected indentation of 8 space characters but found 6
<FormattedMessage
id="learning.accessDenied.alert"
description="Alert message shown to learner when access to the course is denied"
defaultMessage="Please use Safe Exam Browser to access this course."
/>
</Alert>
</main>
<Footer />
</>
);
}

export default injectIntl(SEBCourseAccessErrorPage);
2 changes: 2 additions & 0 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import LiveTab from './course-home/live-tab/LiveTab';
import CourseAccessErrorPage from './generic/CourseAccessErrorPage';
import DecodePageRoute from './decode-page-route';
import { DECODE_ROUTES, ROUTES } from './constants';
import SEBCourseAccessErrorPage from './generic/SEBCourseAccessErrorPage';

subscribe(APP_READY, () => {
ReactDOM.render(
Expand All @@ -50,6 +51,7 @@ subscribe(APP_READY, () => {
<Routes>
<Route path={ROUTES.UNSUBSCRIBE} element={<PageWrap><GoalUnsubscribe /></PageWrap>} />
<Route path={ROUTES.REDIRECT} element={<PageWrap><CoursewareRedirectLandingPage /></PageWrap>} />
<Route path={'/seb-openedx/courseware/access-denied/:courseId'} element={<SEBCourseAccessErrorPage />} />
<Route
path={DECODE_ROUTES.ACCESS_DENIED}
element={<DecodePageRoute><CourseAccessErrorPage /></DecodePageRoute>}
Expand Down
3 changes: 3 additions & 0 deletions src/shared/access.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { getLocale } from '@edx/frontend-platform/i18n';
export function getAccessDeniedRedirectUrl(courseId, activeTabSlug, courseAccess, start) {
let url = null;
switch (courseAccess.errorCode) {
case 'seb_access_denied':
url = `/seb-openedx/courseware/access-denied/${courseId}`;
break;
case 'audit_expired':
url = `/redirect/dashboard?access_response_error=${courseAccess.additionalContextUserMessage}`;
break;
Expand Down
Loading