Compare commits

..

47 Commits

Author SHA1 Message Date
Brian Smith
fe386e31ee feat: import FooterSlot from component package instead of slot package (#604) 2025-04-24 12:25:32 -04:00
Brian Smith
cb1de82f0a feat: standardize slot ids (#608) 2025-04-24 07:47:52 -04:00
renovate[bot]
2337843d54 fix(deps): update dependency @edx/frontend-component-header to v6.4.0 (#607)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-23 20:17:47 +00:00
renovate[bot]
70da0d38ed fix(deps): update dependency @edx/frontend-component-header to v6.3.0 (#606)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-21 10:26:20 +00:00
renovate[bot]
154a2583f6 fix(deps): update dependency @edx/frontend-component-footer to v14.6.0 (#605)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-21 07:27:36 +00:00
renovate[bot]
633050739e fix(deps): update dependency @edx/frontend-component-footer to v14.4.0 (#602)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-14 12:28:07 +00:00
renovate[bot]
61d24d29f1 chore(deps): update dependency @openedx/frontend-build to v14.5.0 (#601)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-14 07:11:40 +00:00
Ivo Branco
a210f23c9f fix: unenroll reasons translation
The unenroll reasons select wasn't being translated.
2025-04-09 10:17:21 -04:00
renovate[bot]
b16908842e fix(deps): update dependency @edx/frontend-platform to v8.3.4 (#596)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Deborah Kaplan <deborahgu@users.noreply.github.com>
2025-04-08 09:47:48 -04:00
renovate[bot]
b80cab7a66 chore(deps): update dependency @openedx/frontend-build to v14.4.2 (#595)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-08 09:42:55 -04:00
Brian Smith
6b8cd1f780 feat: upgrade to react 18 (#593) 2025-04-04 10:24:46 -04:00
Régis Behmo
78c5d73900 chore: remove husky 🪓🐶 (#594) 2025-04-03 09:17:58 -04:00
renovate[bot]
eb3fc9412d fix(deps): update dependency @openedx/paragon to v22.17.0 (#592)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-31 10:52:17 +00:00
renovate[bot]
3caf6fd67a chore(deps): update dependency @openedx/frontend-build to v14.4.1 (#591)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-31 06:45:28 +00:00
Brian Smith
d48cb3d9fc chore(deps): update @openedx dependencies to versions that support React 18 (#590) 2025-03-27 16:16:48 -04:00
Maxwell Frank
d3b4a7fc84 feat: remove upgrade refs course banner (#585) 2025-03-26 09:48:14 -04:00
Maxwell Frank
9e63777c5c fix: CourseBanner slot readme (#589) 2025-03-25 11:36:10 -04:00
renovate[bot]
cf2f3acc51 fix(deps): update dependency @openedx/frontend-slot-footer to v1.1.0 (#588)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-24 06:45:05 +00:00
Maxwell Frank
54f8bc86e3 fix: rename course banner slot (#586) 2025-03-21 11:08:32 -04:00
renovate[bot]
10961010ba fix(deps): update dependency @openedx/frontend-plugin-framework to v1.6.0 (#584)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-17 05:59:50 +00:00
Kira Miller
3c1b749395 fix: changing slot id 2025-03-11 08:39:12 -06:00
Kira Miller
845ee09bf2 fix: PR requests 2025-03-11 08:39:12 -06:00
Kira Miller
1efec09f44 fix: PR requests 2025-03-11 08:39:12 -06:00
Kira Miller
aa1cae5200 fix: pr requests 2025-03-11 08:39:12 -06:00
Kira Miller
77ab48c59f fix: renaming slot 2025-03-11 08:39:12 -06:00
Kira Miller
5d2b33abd3 feat: adding new plugin slot for an enterprise modal 2025-03-11 08:39:12 -06:00
renovate[bot]
dd4f61eec3 fix(deps): update dependency @edx/frontend-enterprise-hotjar to v7.2.0 (#581)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-10 12:27:57 +00:00
renovate[bot]
8f7580ec30 chore(deps): update dependency @openedx/frontend-build to v14.3.2 (#580)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-10 05:34:46 +00:00
Ankush Chudiwal
fbf24e42d3 fix: broken skip link in Learner Dashboard (#522)
Co-authored-by: Deborah Kaplan <deborahgu@users.noreply.github.com>
2025-03-03 14:52:33 -05:00
Jason Wesson
e764e9c502 Revert "feat: adding new plugin slot for an enterprise modal"
This reverts commit f110a0ade8.
2025-03-03 12:40:17 -06:00
Jason Wesson
13721f2770 Revert "fix: renaming slot"
This reverts commit 6a43918b56.
2025-03-03 12:40:17 -06:00
Jason Wesson
960647ce9f Revert "fix: pr requests"
This reverts commit 86fd29309a.
2025-03-03 12:40:17 -06:00
Jason Wesson
44c797854f Revert "fix: PR requests"
This reverts commit 57d09af61d.
2025-03-03 12:40:17 -06:00
Jason Wesson
3ea088e411 Revert "fix: PR requests"
This reverts commit 76783133da.
2025-03-03 12:40:17 -06:00
Jason Wesson
4a18c890c3 Revert "fix: changing slot id"
This reverts commit b26d4632c9.
2025-03-03 12:40:17 -06:00
renovate[bot]
e1c1c51704 chore(deps): update dependency @openedx/frontend-build to v14.3.1 (#578)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-03 10:39:48 +00:00
renovate[bot]
f83f3a1850 fix(deps): update dependency @openedx/paragon to v22.15.3 (#577)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-03 05:37:49 +00:00
Kira Miller
b26d4632c9 fix: changing slot id 2025-02-27 11:28:33 -06:00
Kira Miller
76783133da fix: PR requests 2025-02-27 11:28:33 -06:00
Kira Miller
57d09af61d fix: PR requests 2025-02-27 11:28:33 -06:00
Kira Miller
86fd29309a fix: pr requests 2025-02-27 11:28:33 -06:00
Kira Miller
6a43918b56 fix: renaming slot 2025-02-27 11:28:33 -06:00
Kira Miller
f110a0ade8 feat: adding new plugin slot for an enterprise modal 2025-02-27 11:28:33 -06:00
Feanil Patel
93bd883a01 Update catalog-info file for release data (#570) 2025-02-26 09:07:11 -05:00
salman2013
61375c9e95 chore: update catalog-info-file for release data and remove openedx.yaml file 2025-02-24 15:36:50 -05:00
renovate[bot]
c2f4be5063 fix(deps): update dependency @openedx/paragon to v22.15.2 (#574)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-24 11:48:06 +00:00
renovate[bot]
14bde7fc3f fix(deps): update dependency @edx/frontend-component-header to v5.8.3 (#573)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-24 07:03:02 +00:00
50 changed files with 5559 additions and 3501 deletions

View File

@@ -1 +0,0 @@
npm run lint

View File

@@ -17,6 +17,7 @@ metadata:
openedx.org/arch-interest-groups: "" openedx.org/arch-interest-groups: ""
# This can be multiple comma-separated projects. # This can be multiple comma-separated projects.
openedx.org/add-to-projects: "openedx:23" openedx.org/add-to-projects: "openedx:23"
openedx.org/release: "master"
spec: spec:
type: 'service' type: 'service'
lifecycle: 'production' lifecycle: 'production'

View File

@@ -1,9 +0,0 @@
# This file describes this Open edX repo, as described in OEP-2:
# http://open-edx-proposals.readthedocs.io/en/latest/oeps/oep-0002.html#specification
tags:
- frontend-app
- masters
oeps:
oep-2: true # Repository metadata
openedx-release: {ref: master}

8186
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -20,8 +20,7 @@
"test": "TZ=GMT fedx-scripts jest --coverage --passWithNoTests", "test": "TZ=GMT fedx-scripts jest --coverage --passWithNoTests",
"quality": "npm run lint-fix && npm run test", "quality": "npm run lint-fix && npm run test",
"watch-tests": "jest --watch", "watch-tests": "jest --watch",
"snapshot": "fedx-scripts jest --updateSnapshot", "snapshot": "fedx-scripts jest --updateSnapshot"
"prepare": "husky"
}, },
"author": "edX", "author": "edX",
"license": "AGPL-3.0", "license": "AGPL-3.0",
@@ -31,18 +30,18 @@
}, },
"dependencies": { "dependencies": {
"@edx/brand": "npm:@openedx/brand-openedx@^1.2.2", "@edx/brand": "npm:@openedx/brand-openedx@^1.2.2",
"@edx/frontend-component-header": "^5.6.0", "@edx/frontend-component-footer": "^14.6.0",
"@edx/frontend-enterprise-hotjar": "7.1.0", "@edx/frontend-component-header": "^6.2.0",
"@edx/frontend-platform": "8.1.5", "@edx/frontend-enterprise-hotjar": "7.2.0",
"@edx/frontend-platform": "^8.3.1",
"@edx/openedx-atlas": "^0.6.0", "@edx/openedx-atlas": "^0.6.0",
"@edx/react-unit-test-utils": "3.0.0", "@edx/react-unit-test-utils": "^4.0.0",
"@fortawesome/fontawesome-svg-core": "^1.2.36", "@fortawesome/fontawesome-svg-core": "^1.2.36",
"@fortawesome/free-brands-svg-icons": "^5.15.4", "@fortawesome/free-brands-svg-icons": "^5.15.4",
"@fortawesome/free-solid-svg-icons": "^5.15.4", "@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/react-fontawesome": "^0.2.0", "@fortawesome/react-fontawesome": "^0.2.0",
"@openedx/frontend-plugin-framework": "^1.2.0", "@openedx/frontend-plugin-framework": "^1.7.0",
"@openedx/frontend-slot-footer": "^1.0.2", "@openedx/paragon": "^22.16.0",
"@openedx/paragon": "^22.2.2",
"@redux-devtools/extension": "3.3.0", "@redux-devtools/extension": "3.3.0",
"@reduxjs/toolkit": "^2.0.0", "@reduxjs/toolkit": "^2.0.0",
"classnames": "^2.3.1", "classnames": "^2.3.1",
@@ -54,8 +53,8 @@
"moment": "^2.29.4", "moment": "^2.29.4",
"prop-types": "15.8.1", "prop-types": "15.8.1",
"query-string": "7.1.3", "query-string": "7.1.3",
"react": "^17.0.2", "react": "^18.3.1",
"react-dom": "^17.0.2", "react-dom": "^18.3.1",
"react-helmet": "^6.1.0", "react-helmet": "^6.1.0",
"react-intl": "6.8.9", "react-intl": "6.8.9",
"react-redux": "^7.2.4", "react-redux": "^7.2.4",
@@ -72,18 +71,17 @@
"devDependencies": { "devDependencies": {
"@edx/browserslist-config": "^1.3.0", "@edx/browserslist-config": "^1.3.0",
"@edx/reactifex": "^2.1.1", "@edx/reactifex": "^2.1.1",
"@openedx/frontend-build": "14.2.2", "@openedx/frontend-build": "^14.3.3",
"@testing-library/jest-dom": "^5.14.1", "@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^12.1.0", "@testing-library/react": "^16.2.0",
"copy-webpack-plugin": "^12.0.0", "copy-webpack-plugin": "^12.0.0",
"husky": "^9.0.0",
"identity-obj-proxy": "^3.0.0", "identity-obj-proxy": "^3.0.0",
"jest": "^29.7.0", "jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0", "jest-environment-jsdom": "^29.7.0",
"jest-expect-message": "^1.1.3", "jest-expect-message": "^1.1.3",
"jest-when": "^3.6.0", "jest-when": "^3.6.0",
"react-dev-utils": "^12.0.0", "react-dev-utils": "^12.0.0",
"react-test-renderer": "^17.0.2", "react-test-renderer": "^18.3.1",
"redux-mock-store": "^1.5.4" "redux-mock-store": "^1.5.4"
} }
} }

View File

@@ -6,7 +6,7 @@ import { logError } from '@edx/frontend-platform/logging';
import { initializeHotjar } from '@edx/frontend-enterprise-hotjar'; import { initializeHotjar } from '@edx/frontend-enterprise-hotjar';
import { ErrorPage, AppContext } from '@edx/frontend-platform/react'; import { ErrorPage, AppContext } from '@edx/frontend-platform/react';
import FooterSlot from '@openedx/frontend-slot-footer'; import { FooterSlot } from '@edx/frontend-component-footer';
import { Alert } from '@openedx/paragon'; import { Alert } from '@openedx/paragon';
import { RequestKeys } from 'data/constants/requests'; import { RequestKeys } from 'data/constants/requests';
@@ -80,7 +80,7 @@ export const App = () => {
<div> <div>
<AppWrapper> <AppWrapper>
<LearnerDashboardHeader /> <LearnerDashboardHeader />
<main> <main id="main">
{hasNetworkFailure {hasNetworkFailure
? ( ? (
<Alert variant="danger"> <Alert variant="danger">

View File

@@ -13,7 +13,7 @@ import AppWrapper from 'containers/WidgetContainers/AppWrapper';
import { App } from './App'; import { App } from './App';
import messages from './messages'; import messages from './messages';
jest.mock('@edx/frontend-component-footer', () => ({ FooterSlot: 'Footer' })); jest.mock('@edx/frontend-component-footer', () => ({ FooterSlot: 'FooterSlot' }));
jest.mock('containers/Dashboard', () => 'Dashboard'); jest.mock('containers/Dashboard', () => 'Dashboard');
jest.mock('containers/LearnerDashboardHeader', () => 'LearnerDashboardHeader'); jest.mock('containers/LearnerDashboardHeader', () => 'LearnerDashboardHeader');

View File

@@ -17,7 +17,9 @@ exports[`App router component component initialize failure snapshot 1`] = `
<div> <div>
<AppWrapper> <AppWrapper>
<LearnerDashboardHeader /> <LearnerDashboardHeader />
<main> <main
id="main"
>
<Alert <Alert
variant="danger" variant="danger"
> >
@@ -49,7 +51,9 @@ exports[`App router component component no network failure snapshot 1`] = `
<div> <div>
<AppWrapper> <AppWrapper>
<LearnerDashboardHeader /> <LearnerDashboardHeader />
<main> <main
id="main"
>
<Dashboard /> <Dashboard />
</main> </main>
</AppWrapper> </AppWrapper>
@@ -75,7 +79,9 @@ exports[`App router component component no network failure with optimizely proje
<div> <div>
<AppWrapper> <AppWrapper>
<LearnerDashboardHeader /> <LearnerDashboardHeader />
<main> <main
id="main"
>
<Dashboard /> <Dashboard />
</main> </main>
</AppWrapper> </AppWrapper>
@@ -101,7 +107,9 @@ exports[`App router component component no network failure with optimizely url s
<div> <div>
<AppWrapper> <AppWrapper>
<LearnerDashboardHeader /> <LearnerDashboardHeader />
<main> <main
id="main"
>
<Dashboard /> <Dashboard />
</main> </main>
</AppWrapper> </AppWrapper>
@@ -127,7 +135,9 @@ exports[`App router component component refresh failure snapshot 1`] = `
<div> <div>
<AppWrapper> <AppWrapper>
<LearnerDashboardHeader /> <LearnerDashboardHeader />
<main> <main
id="main"
>
<Alert <Alert
variant="danger" variant="danger"
> >

View File

@@ -1,19 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`app registry subscribe: APP_INIT_ERROR. snapshot: displays an ErrorPage to root element 1`] = ` exports[`app registry subscribe: APP_INIT_ERROR. snapshot: displays an ErrorPage to root element 1`] = `
<UNDEFINED>
<ErrorPage <ErrorPage
message="test-error-message" message="test-error-message"
/> />
</UNDEFINED>
`; `;
exports[`app registry subscribe: APP_READY. links App to root element 1`] = ` exports[`app registry subscribe: APP_READY. links App to root element 1`] = `
<UNDEFINED>
<AppProvider <AppProvider
store={ store={
{ {
"redux": "store", "redux": "store",
} }
} }
wrapWithRouter={true}
> >
<NoticesWrapper> <NoticesWrapper>
<Routes> <Routes>
@@ -37,4 +39,5 @@ exports[`app registry subscribe: APP_READY. links App to root element 1`] = `
</Routes> </Routes>
</NoticesWrapper> </NoticesWrapper>
</AppProvider> </AppProvider>
</UNDEFINED>
`; `;

View File

@@ -12,7 +12,6 @@ export const CourseBanner = ({ cardId }) => {
const { const {
isVerified, isVerified,
isAuditAccessExpired, isAuditAccessExpired,
canUpgrade,
coursewareAccess = {}, coursewareAccess = {},
} = reduxHooks.useCardEnrollmentData(cardId); } = reduxHooks.useCardEnrollmentData(cardId);
const courseRun = reduxHooks.useCardCourseRunData(cardId); const courseRun = reduxHooks.useCardCourseRunData(cardId);
@@ -26,13 +25,7 @@ export const CourseBanner = ({ cardId }) => {
return ( return (
<> <>
{isAuditAccessExpired {isAuditAccessExpired
&& (canUpgrade ? ( && (
<Banner>
{formatMessage(messages.auditAccessExpired)}
{' '}
{formatMessage(messages.upgradeToAccess)}
</Banner>
) : (
<Banner> <Banner>
{formatMessage(messages.auditAccessExpired)} {formatMessage(messages.auditAccessExpired)}
{' '} {' '}
@@ -40,16 +33,6 @@ export const CourseBanner = ({ cardId }) => {
{formatMessage(messages.findAnotherCourse)} {formatMessage(messages.findAnotherCourse)}
</Hyperlink> </Hyperlink>
</Banner> </Banner>
))}
{courseRun.isActive && !canUpgrade && (
<Banner>
{formatMessage(messages.upgradeDeadlinePassed)}
{' '}
<Hyperlink isInline destination={courseRun.marketingUrl || ''}>
{formatMessage(messages.exploreCourseDetails)}
</Hyperlink>
</Banner>
)} )}
{(!isStaff && isTooEarly && courseRun.startDate) && ( {(!isStaff && isTooEarly && courseRun.startDate) && (
@@ -59,6 +42,7 @@ export const CourseBanner = ({ cardId }) => {
})} })}
</Banner> </Banner>
)} )}
{(!isStaff && hasUnmetPrerequisites) && ( {(!isStaff && hasUnmetPrerequisites) && (
<Banner>{formatMessage(messages.prerequisitesNotMet)}</Banner> <Banner>{formatMessage(messages.prerequisitesNotMet)}</Banner>
)} )}

View File

@@ -25,7 +25,6 @@ let el;
const enrollmentData = { const enrollmentData = {
isVerified: false, isVerified: false,
canUpgrade: false,
isAuditAccessExpired: false, isAuditAccessExpired: false,
coursewareAccess: { coursewareAccess: {
hasUnmetPrerequisites: false, hasUnmetPrerequisites: false,
@@ -65,51 +64,18 @@ describe('CourseBanner', () => {
render({ enrollment: { isVerified: true } }); render({ enrollment: { isVerified: true } });
expect(el.isEmptyRender()).toEqual(true); expect(el.isEmptyRender()).toEqual(true);
}); });
describe('audit access expired, can upgrade', () => { describe('audit access expired', () => {
beforeEach(() => {
render({ enrollment: { isAuditAccessExpired: true, canUpgrade: true } });
});
test('snapshot: (auditAccessExpired, upgradeToAccess)', () => {
expect(el.snapshot).toMatchSnapshot();
});
test('messages: (auditAccessExpired, upgradeToAccess)', () => {
expect(el.instance.children[0].children[0].el).toContain(messages.auditAccessExpired.defaultMessage);
expect(el.instance.children[0].children[2].el).toContain(messages.upgradeToAccess.defaultMessage);
});
});
describe('audit access expired, cannot upgrade', () => {
beforeEach(() => { beforeEach(() => {
render({ enrollment: { isAuditAccessExpired: true } }); render({ enrollment: { isAuditAccessExpired: true } });
}); });
test('snapshot: (auditAccessExpired, findAnotherCourse hyperlink)', () => { test('snapshot: (auditAccessExpired, findAnotherCourse hyperlink)', () => {
expect(el.snapshot).toMatchSnapshot(); expect(el.snapshot).toMatchSnapshot();
}); });
test('messages: (auditAccessExpired, upgradeToAccess)', () => { test('messages: auditAccessExpired', () => {
expect(el.instance.children[0].children[0].el).toContain(messages.auditAccessExpired.defaultMessage); expect(el.instance.children[0].children[0].el).toContain(messages.auditAccessExpired.defaultMessage);
expect(el.instance.findByType(Hyperlink)[0].children[0].el).toEqual(messages.findAnotherCourse.defaultMessage); expect(el.instance.findByType(Hyperlink)[0].children[0].el).toEqual(messages.findAnotherCourse.defaultMessage);
}); });
}); });
describe('course run active and cannot upgrade', () => {
beforeEach(() => {
render({ courseRun: { isActive: true } });
});
test('snapshot: (upgradseDeadlinePassed, exploreCourseDetails hyperlink)', () => {
expect(el.snapshot).toMatchSnapshot();
});
test('messages: (upgradseDeadlinePassed, exploreCourseDetails hyperlink)', () => {
expect(el.instance.children[0].children[0].el).toContain(messages.upgradeDeadlinePassed.defaultMessage);
const link = el.instance.findByType(Hyperlink);
expect(link[0].children[0].el).toEqual(messages.exploreCourseDetails.defaultMessage);
expect(link[0].props.destination).toEqual(courseRunData.marketingUrl);
});
});
test('no display if audit access not expired and (course is not active or can upgrade)', () => {
render();
// isEmptyRender() isn't true because the minimal is <Fragment />
expect(el.instance.children).toEqual([]);
render({ enrollment: { canUpgrade: true }, courseRun: { isActive: true } });
expect(el.instance.children).toEqual([]);
});
describe('unmet prerequisites', () => { describe('unmet prerequisites', () => {
beforeEach(() => { beforeEach(() => {
render({ enrollment: { coursewareAccess: { hasUnmetPrerequisites: true } } }); render({ enrollment: { coursewareAccess: { hasUnmetPrerequisites: true } } });

View File

@@ -1,16 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`CourseBanner audit access expired, can upgrade snapshot: (auditAccessExpired, upgradeToAccess) 1`] = ` exports[`CourseBanner audit access expired snapshot: (auditAccessExpired, findAnotherCourse hyperlink) 1`] = `
<Fragment>
<Banner>
Your audit access to this course has expired.
Upgrade now to access your course again.
</Banner>
</Fragment>
`;
exports[`CourseBanner audit access expired, cannot upgrade snapshot: (auditAccessExpired, findAnotherCourse hyperlink) 1`] = `
<Fragment> <Fragment>
<Banner> <Banner>
Your audit access to this course has expired. Your audit access to this course has expired.
@@ -25,21 +15,6 @@ exports[`CourseBanner audit access expired, cannot upgrade snapshot: (auditAcces
</Fragment> </Fragment>
`; `;
exports[`CourseBanner course run active and cannot upgrade snapshot: (upgradseDeadlinePassed, exploreCourseDetails hyperlink) 1`] = `
<Fragment>
<Banner>
Your upgrade deadline for this course has passed. To upgrade, enroll in a session that is farther in the future.
<Hyperlink
destination="marketing-url"
isInline={true}
>
Explore course details.
</Hyperlink>
</Banner>
</Fragment>
`;
exports[`CourseBanner snapshot: stacking banners 1`] = `<Fragment />`; exports[`CourseBanner snapshot: stacking banners 1`] = `<Fragment />`;
exports[`CourseBanner staff snapshot: isStaff 1`] = `<Fragment />`; exports[`CourseBanner staff snapshot: isStaff 1`] = `<Fragment />`;

View File

@@ -6,26 +6,11 @@ const messages = defineMessages({
description: 'Audit access expiration banner message', description: 'Audit access expiration banner message',
defaultMessage: 'Your audit access to this course has expired.', defaultMessage: 'Your audit access to this course has expired.',
}, },
upgradeToAccess: {
id: 'learner-dash.courseCard.banners.upgradeToAccess',
description: 'Upgrade prompt for audit-expired learners that can still upgrade',
defaultMessage: 'Upgrade now to access your course again.',
},
findAnotherCourse: { findAnotherCourse: {
id: 'learner-dash.courseCard.banners.findAnotherCourse', id: 'learner-dash.courseCard.banners.findAnotherCourse',
description: 'Action prompt taking learners to course exploration', description: 'Action prompt taking learners to course exploration',
defaultMessage: 'Find another course', defaultMessage: 'Find another course',
}, },
upgradeDeadlinePassed: {
id: 'learner-dash.courseCard.banners.upgradeDeadlinePassed',
description: 'Audit upgrade deadline passed banner message',
defaultMessage: 'Your upgrade deadline for this course has passed. To upgrade, enroll in a session that is farther in the future.',
},
exploreCourseDetails: {
id: 'learner-dash.courseCard.banners.exploreCourseDetails',
description: 'Action prompt taking learners to course details page',
defaultMessage: 'Explore course details.',
},
certRestricted: { certRestricted: {
id: 'learner-dash.courseCard.banners.certificateRestricted', id: 'learner-dash.courseCard.banners.certificateRestricted',
description: 'Restricted certificate warning message', description: 'Restricted certificate warning message',

View File

@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Dashboard snapshots courses loaded, show select session modal, no available dashboards snapshot 1`] = ` exports[`Dashboard snapshots courses loaded, show select session modal snapshot 1`] = `
<div <div
className="d-flex flex-column p-2 pt-0" className="d-flex flex-column p-2 pt-0"
id="dashboard-container" id="dashboard-container"
@@ -11,6 +11,7 @@ exports[`Dashboard snapshots courses loaded, show select session modal, no avail
test-page-title test-page-title
</h1> </h1>
<Fragment> <Fragment>
<DashboardModalSlot />
<SelectSessionModal /> <SelectSessionModal />
</Fragment> </Fragment>
<div <div
@@ -43,7 +44,7 @@ exports[`Dashboard snapshots courses still loading snapshot 1`] = `
</div> </div>
`; `;
exports[`Dashboard snapshots there are no courses, there ARE available dashboards snapshot 1`] = ` exports[`Dashboard snapshots there are no courses snapshot 1`] = `
<div <div
className="d-flex flex-column p-2 pt-0" className="d-flex flex-column p-2 pt-0"
id="dashboard-container" id="dashboard-container"
@@ -54,7 +55,7 @@ exports[`Dashboard snapshots there are no courses, there ARE available dashboard
test-page-title test-page-title
</h1> </h1>
<Fragment> <Fragment>
<EnterpriseDashboardModal /> <DashboardModalSlot />
</Fragment> </Fragment>
<div <div
data-testid="dashboard-content" data-testid="dashboard-content"

View File

@@ -2,9 +2,9 @@ import React from 'react';
import { reduxHooks } from 'hooks'; import { reduxHooks } from 'hooks';
import { RequestKeys } from 'data/constants/requests'; import { RequestKeys } from 'data/constants/requests';
import EnterpriseDashboardModal from 'containers/EnterpriseDashboardModal';
import SelectSessionModal from 'containers/SelectSessionModal'; import SelectSessionModal from 'containers/SelectSessionModal';
import CoursesPanel from 'containers/CoursesPanel'; import CoursesPanel from 'containers/CoursesPanel';
import DashboardModalSlot from 'plugin-slots/DashboardModalSlot';
import LoadingView from './LoadingView'; import LoadingView from './LoadingView';
import DashboardLayout from './DashboardLayout'; import DashboardLayout from './DashboardLayout';
@@ -15,7 +15,6 @@ export const Dashboard = () => {
hooks.useInitializeDashboard(); hooks.useInitializeDashboard();
const { pageTitle } = hooks.useDashboardMessages(); const { pageTitle } = hooks.useDashboardMessages();
const hasCourses = reduxHooks.useHasCourses(); const hasCourses = reduxHooks.useHasCourses();
const hasAvailableDashboards = reduxHooks.useHasAvailableDashboards();
const initIsPending = reduxHooks.useRequestIsPending(RequestKeys.initialize); const initIsPending = reduxHooks.useRequestIsPending(RequestKeys.initialize);
const showSelectSessionModal = reduxHooks.useShowSelectSessionModal(); const showSelectSessionModal = reduxHooks.useShowSelectSessionModal();
@@ -24,7 +23,7 @@ export const Dashboard = () => {
<h1 className="sr-only">{pageTitle}</h1> <h1 className="sr-only">{pageTitle}</h1>
{!initIsPending && ( {!initIsPending && (
<> <>
{hasAvailableDashboards && <EnterpriseDashboardModal />} <DashboardModalSlot />
{(hasCourses && showSelectSessionModal) && <SelectSessionModal />} {(hasCourses && showSelectSessionModal) && <SelectSessionModal />}
</> </>
)} )}

View File

@@ -2,7 +2,6 @@ import { shallow } from '@edx/react-unit-test-utils';
import { reduxHooks } from 'hooks'; import { reduxHooks } from 'hooks';
import EnterpriseDashboardModal from 'containers/EnterpriseDashboardModal';
import SelectSessionModal from 'containers/SelectSessionModal'; import SelectSessionModal from 'containers/SelectSessionModal';
import CoursesPanel from 'containers/CoursesPanel'; import CoursesPanel from 'containers/CoursesPanel';
@@ -14,13 +13,12 @@ import Dashboard from '.';
jest.mock('hooks', () => ({ jest.mock('hooks', () => ({
reduxHooks: { reduxHooks: {
useHasCourses: jest.fn(), useHasCourses: jest.fn(),
useHasAvailableDashboards: jest.fn(),
useShowSelectSessionModal: jest.fn(), useShowSelectSessionModal: jest.fn(),
useRequestIsPending: jest.fn(), useRequestIsPending: jest.fn(),
}, },
})); }));
jest.mock('containers/EnterpriseDashboardModal', () => 'EnterpriseDashboardModal'); jest.mock('plugin-slots/DashboardModalSlot', () => 'DashboardModalSlot');
jest.mock('containers/CoursesPanel', () => 'CoursesPanel'); jest.mock('containers/CoursesPanel', () => 'CoursesPanel');
jest.mock('./LoadingView', () => 'LoadingView'); jest.mock('./LoadingView', () => 'LoadingView');
jest.mock('./DashboardLayout', () => 'DashboardLayout'); jest.mock('./DashboardLayout', () => 'DashboardLayout');
@@ -38,12 +36,10 @@ describe('Dashboard', () => {
}); });
const createWrapper = ({ const createWrapper = ({
hasCourses, hasCourses,
hasAvailableDashboards,
initIsPending, initIsPending,
showSelectSessionModal, showSelectSessionModal,
}) => { }) => {
reduxHooks.useHasCourses.mockReturnValueOnce(hasCourses); reduxHooks.useHasCourses.mockReturnValueOnce(hasCourses);
reduxHooks.useHasAvailableDashboards.mockReturnValueOnce(hasAvailableDashboards);
reduxHooks.useRequestIsPending.mockReturnValueOnce(initIsPending); reduxHooks.useRequestIsPending.mockReturnValueOnce(initIsPending);
reduxHooks.useShowSelectSessionModal.mockReturnValueOnce(showSelectSessionModal); reduxHooks.useShowSelectSessionModal.mockReturnValueOnce(showSelectSessionModal);
return shallow(<Dashboard />); return shallow(<Dashboard />);
@@ -71,7 +67,6 @@ describe('Dashboard', () => {
const testView = ({ const testView = ({
props, props,
content: [contentName, contentEl], content: [contentName, contentEl],
showEnterpriseModal,
showSelectSessionModal, showSelectSessionModal,
}) => { }) => {
beforeEach(() => { wrapper = createWrapper(props); }); beforeEach(() => { wrapper = createWrapper(props); });
@@ -80,10 +75,6 @@ describe('Dashboard', () => {
it(`renders ${contentName}`, () => { it(`renders ${contentName}`, () => {
testContent(contentEl); testContent(contentEl);
}); });
it(`${renderString(showEnterpriseModal)} dashbaord modal`, () => {
expect(wrapper.instance.findByType(EnterpriseDashboardModal).length)
.toEqual(showEnterpriseModal ? 1 : 0);
});
it(`${renderString(showSelectSessionModal)} select session modal`, () => { it(`${renderString(showSelectSessionModal)} select session modal`, () => {
expect(wrapper.instance.findByType(SelectSessionModal).length).toEqual(showSelectSessionModal ? 1 : 0); expect(wrapper.instance.findByType(SelectSessionModal).length).toEqual(showSelectSessionModal ? 1 : 0);
}); });
@@ -92,44 +83,38 @@ describe('Dashboard', () => {
testView({ testView({
props: { props: {
hasCourses: false, hasCourses: false,
hasAvailableDashboards: false,
initIsPending: true, initIsPending: true,
showSelectSessionModal: false, showSelectSessionModal: false,
}, },
content: ['LoadingView', <LoadingView />], content: ['LoadingView', <LoadingView />],
showEnterpriseModal: false,
showSelectSessionModal: false, showSelectSessionModal: false,
}); });
}); });
describe('courses loaded, show select session modal, no available dashboards', () => { describe('courses loaded, show select session modal', () => {
testView({ testView({
props: { props: {
hasCourses: true, hasCourses: true,
hasAvailableDashboards: false,
initIsPending: false, initIsPending: false,
showSelectSessionModal: true, showSelectSessionModal: true,
}, },
content: ['LoadedView', ( content: ['LoadedView', (
<DashboardLayout><CoursesPanel /></DashboardLayout> <DashboardLayout><CoursesPanel /></DashboardLayout>
)], )],
showEnterpriseModal: false,
showSelectSessionModal: true, showSelectSessionModal: true,
}); });
}); });
describe('there are no courses, there ARE available dashboards', () => { describe('there are no courses', () => {
testView({ testView({
props: { props: {
hasCourses: false, hasCourses: false,
hasAvailableDashboards: true,
initIsPending: false, initIsPending: false,
showSelectSessionModal: false, showSelectSessionModal: false,
}, },
content: ['Dashboard layout with no courses sidebar and content', ( content: ['Dashboard layout with no courses sidebar and content', (
<DashboardLayout><CoursesPanel /></DashboardLayout> <DashboardLayout><CoursesPanel /></DashboardLayout>
)], )],
showEnterpriseModal: true,
showSelectSessionModal: false, showSelectSessionModal: false,
}); });
}); });

View File

@@ -1,42 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`EnterpriseDashboard empty snapshot 1`] = `null`;
exports[`EnterpriseDashboard snapshot 1`] = `
<ModalDialog
hasCloseButton={false}
onClose={[MockFunction useEnterpriseDashboardHook.handleEscape]}
title=""
>
<div
className="bg-white p-3 rounded shadow"
style={
{
"textAlign": "start",
}
}
>
<h4>
You have access to the edX, Inc. dashboard
</h4>
<p>
To access the courses available to you through edX, Inc., visit the edX, Inc. dashboard now.
</p>
<ActionRow>
<Button
onClick={[MockFunction useEnterpriseDashboardHook.handleClose]}
variant="tertiary"
>
Dismiss
</Button>
<Button
href="/edx-dashboard"
onClick={[MockFunction useEnterpriseDashboardHook.handleCTAClick]}
type="a"
>
Go to dashboard
</Button>
</ActionRow>
</div>
</ModalDialog>
`;

View File

@@ -1,48 +0,0 @@
import React from 'react';
import { StrictDict } from 'utils';
import track from 'tracking';
import { reduxHooks } from 'hooks';
import * as module from './hooks';
export const state = StrictDict({
showModal: (val) => React.useState(val), // eslint-disable-line
});
const { modalOpened, modalClosed, modalCTAClicked } = track.enterpriseDashboard;
export const useEnterpriseDashboardHook = () => {
const [showModal, setShowModal] = module.state.showModal(true);
const dashboard = reduxHooks.useEnterpriseDashboardData();
const trackOpened = modalOpened(dashboard.enterpriseUUID);
const trackClose = modalClosed(dashboard.enterpriseUUID, 'Cancel button');
const trackEscape = modalClosed(dashboard.enterpriseUUID, 'Escape');
const handleCTAClick = modalCTAClicked(dashboard.enterpriseUUID, dashboard.url);
const handleClose = () => {
trackClose();
setShowModal(false);
};
const handleEscape = () => {
trackEscape();
setShowModal(false);
};
React.useEffect(() => {
if (dashboard && dashboard.label) {
trackOpened();
}
}, []); // eslint-disable-line
return {
showModal,
handleCTAClick,
handleClose,
handleEscape,
dashboard,
};
};
export default useEnterpriseDashboardHook;

View File

@@ -1,75 +0,0 @@
import { MockUseState } from 'testUtils';
import { reduxHooks } from 'hooks';
import track from 'tracking';
import * as hooks from './hooks';
jest.mock('hooks', () => ({
reduxHooks: {
useEnterpriseDashboardData: jest.fn(),
},
}));
jest.mock('tracking', () => {
const modalOpenedEvent = jest.fn();
const modalClosedEvent = jest.fn();
const modalCTAClickedEvent = jest.fn();
return {
__esModule: true,
default: {
enterpriseDashboard: {
modalOpenedEvent,
modalClosedEvent,
modalCTAClickedEvent,
modalOpened: jest.fn(() => modalOpenedEvent),
modalClosed: jest.fn(() => modalClosedEvent),
modalCTAClicked: jest.fn(() => modalCTAClickedEvent),
},
},
};
});
const state = new MockUseState(hooks);
const enterpriseDashboardData = { label: 'edX, Inc.', url: '/edx-dashboard' };
describe('EnterpriseDashboard hooks', () => {
reduxHooks.useEnterpriseDashboardData.mockReturnValue({ ...enterpriseDashboardData });
describe('state values', () => {
state.testGetter(state.keys.showModal);
});
describe('behavior', () => {
let out;
beforeEach(() => {
state.mock();
out = hooks.useEnterpriseDashboardHook();
});
afterEach(state.restore);
test('useEnterpriseDashboardHook to return dashboard data from redux hooks', () => {
expect(out.dashboard).toMatchObject(enterpriseDashboardData);
});
test('modal initializes to shown when rendered and closes on click', () => {
state.expectInitializedWith(state.keys.showModal, true);
out.handleClose();
expect(state.values.showModal).toEqual(false);
});
test('modal initializes to shown when rendered and closes on escape', () => {
state.expectInitializedWith(state.keys.showModal, true);
out.handleEscape();
expect(state.values.showModal).toEqual(false);
});
test('CTA click tracks modalCTAClicked', () => {
out.handleCTAClick();
expect(track.enterpriseDashboard.modalCTAClicked).toHaveBeenCalledWith(
enterpriseDashboardData.enterpriseUUID,
enterpriseDashboardData.url,
);
});
});
});

View File

@@ -1,60 +0,0 @@
import React from 'react';
// import PropTypes from 'prop-types';
import { useIntl } from '@edx/frontend-platform/i18n';
import {
ModalDialog, ActionRow, Button,
} from '@openedx/paragon';
import messages from './messages';
import useEnterpriseDashboardHook from './hooks';
export const EnterpriseDashboardModal = () => {
const { formatMessage } = useIntl();
const {
showModal,
handleClose,
handleCTAClick,
handleEscape,
dashboard,
} = useEnterpriseDashboardHook();
if (!dashboard || !dashboard.label) {
return null;
}
return (
<ModalDialog
isOpen={showModal}
onClose={handleEscape}
hasCloseButton={false}
title=""
>
<div
className="bg-white p-3 rounded shadow"
style={{ textAlign: 'start' }}
>
<h4>
{formatMessage(messages.enterpriseDialogHeader, {
label: dashboard.label,
})}
</h4>
<p>
{formatMessage(messages.enterpriseDialogBody, {
label: dashboard.label,
})}
</p>
<ActionRow>
<Button variant="tertiary" onClick={handleClose}>
{formatMessage(messages.enterpriseDialogDismissButton)}
</Button>
<Button type="a" href={dashboard.url} onClick={handleCTAClick}>
{formatMessage(messages.enterpriseDialogConfirmButton)}
</Button>
</ActionRow>
</div>
</ModalDialog>
);
};
EnterpriseDashboardModal.propTypes = {};
export default EnterpriseDashboardModal;

View File

@@ -1,29 +0,0 @@
import { shallow } from '@edx/react-unit-test-utils';
import EnterpriseDashboard from '.';
import useEnterpriseDashboardHook from './hooks';
jest.mock('./hooks', () => ({
__esModule: true,
default: jest.fn(),
}));
describe('EnterpriseDashboard', () => {
test('snapshot', () => {
const hookData = {
dashboard: { label: 'edX, Inc.', url: '/edx-dashboard' },
showDialog: false,
handleClose: jest.fn().mockName('useEnterpriseDashboardHook.handleClose'),
handleCTAClick: jest.fn().mockName('useEnterpriseDashboardHook.handleCTAClick'),
handleEscape: jest.fn().mockName('useEnterpriseDashboardHook.handleEscape'),
};
useEnterpriseDashboardHook.mockReturnValueOnce({ ...hookData });
const el = shallow(<EnterpriseDashboard />);
expect(el.snapshot).toMatchSnapshot();
});
test('empty snapshot', () => {
useEnterpriseDashboardHook.mockReturnValueOnce({});
const el = shallow(<EnterpriseDashboard />);
expect(el.snapshot).toMatchSnapshot();
});
});

View File

@@ -1,26 +0,0 @@
import { defineMessages } from '@edx/frontend-platform/i18n';
const messages = defineMessages({
enterpriseDialogHeader: {
id: 'leanerDashboard.enterpriseDialogHeader',
defaultMessage: 'You have access to the {label} dashboard',
description: 'title for enterpise dashboard dialog',
},
enterpriseDialogBody: {
id: 'leanerDashboard.enterpriseDialogBody',
defaultMessage: 'To access the courses available to you through {label}, visit the {label} dashboard now.',
description: 'Body text for enterpise dashboard dialog',
},
enterpriseDialogDismissButton: {
id: 'leanerDashboard.enterpriseDialogDismissButton',
defaultMessage: 'Dismiss',
description: 'Dismiss button to cancel visiting dashboard',
},
enterpriseDialogConfirmButton: {
id: 'leanerDashboard.enterpriseDialogConfirmButton',
defaultMessage: 'Go to dashboard',
description: 'Confirm button to go to the dashboard url',
},
});
export default messages;

View File

@@ -1,5 +1,6 @@
/* eslint-disable quotes */ /* eslint-disable quotes */
import { StrictDict } from 'utils'; import { StrictDict } from 'utils';
import { defineMessages } from '@edx/frontend-platform/i18n';
export const reasonKeys = StrictDict({ export const reasonKeys = StrictDict({
prereqs: 'prereqs', prereqs: 'prereqs',
@@ -26,7 +27,7 @@ export const order = [
reasonKeys.easy, reasonKeys.easy,
]; ];
const messages = StrictDict({ const messages = defineMessages({
[reasonKeys.prereqs]: { [reasonKeys.prereqs]: {
id: 'learner-dash.unenrollConfirm.reasons.prereqs', id: 'learner-dash.unenrollConfirm.reasons.prereqs',
description: 'Unenroll reason option - missing prerequisites', description: 'Unenroll reason option - missing prerequisites',

View File

@@ -10,10 +10,7 @@ export const numCourses = createSelector(
(courseData) => Object.keys(courseData).length, (courseData) => Object.keys(courseData).length,
); );
export const hasCourses = createSelector([module.numCourses], (num) => num > 0); export const hasCourses = createSelector([module.numCourses], (num) => num > 0);
export const hasAvailableDashboards = createSelector(
[simpleSelectors.enterpriseDashboard],
(data) => data !== null && data.isLearnerPortalEnabled === true,
);
export const showSelectSessionModal = createSelector( export const showSelectSessionModal = createSelector(
[simpleSelectors.selectSessionModal], [simpleSelectors.selectSessionModal],
(data) => data.cardId != null, (data) => data.cardId != null,
@@ -22,6 +19,5 @@ export const showSelectSessionModal = createSelector(
export default StrictDict({ export default StrictDict({
numCourses, numCourses,
hasCourses, hasCourses,
hasAvailableDashboards,
showSelectSessionModal, showSelectSessionModal,
}); });

View File

@@ -17,15 +17,6 @@ describe('basic app selectors', () => {
expect(cb(0)).toEqual(false); expect(cb(0)).toEqual(false);
}); });
}); });
describe('hasAvailableDashboards', () => {
it('returns true iff the enterpriseDashboard field is populated and learner portal is enabled', () => {
const { preSelectors, cb } = appSelectors.hasAvailableDashboards;
expect(preSelectors).toEqual([simpleSelectors.enterpriseDashboard]);
expect(cb({ isLearnerPortalEnabled: true })).toEqual(true);
expect(cb({ isLearnerPortalEnabled: false })).toEqual(false);
expect(cb(null)).toEqual(false);
});
});
describe('showSelectSessionModal', () => { describe('showSelectSessionModal', () => {
it('returns true if the selectSessionModal cardId is not null', () => { it('returns true if the selectSessionModal cardId is not null', () => {
const { preSelectors, cb } = appSelectors.showSelectSessionModal; const { preSelectors, cb } = appSelectors.showSelectSessionModal;

View File

@@ -36,12 +36,6 @@ describe('app simple selectors', () => {
expect(preSelectors).toEqual([appSelector]); expect(preSelectors).toEqual([appSelector]);
expect(cb(testState.app)).toEqual(testString); expect(cb(testState.app)).toEqual(testString);
}); });
test('enterpriseDashboard returns empty object if data returns null', () => {
testState = { app: { enterpriseDashboard: null } };
const { preSelectors, cb } = simpleSelectors.enterpriseDashboard;
expect(preSelectors).toEqual([appSelector]);
expect(cb(testState.app)).toEqual({});
});
describe('cardSimpleSelectors', () => { describe('cardSimpleSelectors', () => {
keys = keyStore(cardSimpleSelectors); keys = keyStore(cardSimpleSelectors);
test.each([ test.each([

View File

@@ -18,7 +18,6 @@ export const useSocialShareSettings = () => useSelector(selectors.socialShareSet
/** global-level meta-selectors **/ /** global-level meta-selectors **/
export const useHasCourses = () => useSelector(selectors.hasCourses); export const useHasCourses = () => useSelector(selectors.hasCourses);
export const useHasAvailableDashboards = () => useSelector(selectors.hasAvailableDashboards);
export const useCurrentCourseList = (opts) => useSelector( export const useCurrentCourseList = (opts) => useSelector(
state => selectors.currentList(state, opts), state => selectors.currentList(state, opts),
); );

View File

@@ -2,8 +2,8 @@
import 'core-js/stable'; import 'core-js/stable';
import 'regenerator-runtime/runtime'; import 'regenerator-runtime/runtime';
import React from 'react'; import React, { StrictMode } from 'react';
import ReactDOM from 'react-dom'; import { createRoot } from 'react-dom/client';
import { import {
Route, Navigate, Routes, Route, Navigate, Routes,
} from 'react-router-dom'; } from 'react-router-dom';
@@ -30,7 +30,10 @@ import App from './App';
import NoticesWrapper from './components/NoticesWrapper'; import NoticesWrapper from './components/NoticesWrapper';
subscribe(APP_READY, () => { subscribe(APP_READY, () => {
ReactDOM.render( const root = createRoot(document.getElementById('root'));
root.render(
<StrictMode>
<AppProvider store={store}> <AppProvider store={store}>
<NoticesWrapper> <NoticesWrapper>
<Routes> <Routes>
@@ -38,15 +41,18 @@ subscribe(APP_READY, () => {
<Route path="*" element={<Navigate to="/" replace />} /> <Route path="*" element={<Navigate to="/" replace />} />
</Routes> </Routes>
</NoticesWrapper> </NoticesWrapper>
</AppProvider>, </AppProvider>
document.getElementById('root'), </StrictMode>,
); );
}); });
subscribe(APP_INIT_ERROR, (error) => { subscribe(APP_INIT_ERROR, (error) => {
ReactDOM.render( const root = createRoot(document.getElementById('root'));
<ErrorPage message={error.message} />,
document.getElementById('root'), root.render(
<StrictMode>
<ErrorPage message={error.message} />
</StrictMode>,
); );
}); });

View File

@@ -1,5 +1,3 @@
import { render } from 'react-dom';
import { import {
APP_INIT_ERROR, APP_INIT_ERROR,
APP_READY, APP_READY,
@@ -11,10 +9,21 @@ import {
import { configuration } from './config'; import { configuration } from './config';
import * as app from '.'; import * as app from '.';
jest.mock('react-dom', () => ({ // These need to be var not let so they get hoisted
render: jest.fn(), // and can be used by jest.mock (which is also hoisted)
var mockRender; // eslint-disable-line no-var
var mockCreateRoot; // eslint-disable-line no-var
jest.mock('react-dom/client', () => {
mockRender = jest.fn();
mockCreateRoot = jest.fn(() => ({
render: mockRender,
})); }));
return ({
createRoot: mockCreateRoot,
});
});
jest.mock('@edx/frontend-platform', () => ({ jest.mock('@edx/frontend-platform', () => ({
mergeConfig: jest.fn(), mergeConfig: jest.fn(),
ensureConfig: jest.fn(), ensureConfig: jest.fn(),
@@ -32,7 +41,9 @@ describe('app registry', () => {
let getElement; let getElement;
beforeEach(() => { beforeEach(() => {
render.mockClear(); mockCreateRoot.mockClear();
mockRender.mockClear();
getElement = window.document.getElementById; getElement = window.document.getElementById;
window.document.getElementById = jest.fn(id => ({ id })); window.document.getElementById = jest.fn(id => ({ id }));
}); });
@@ -44,18 +55,16 @@ describe('app registry', () => {
const callArgs = subscribe.mock.calls[0]; const callArgs = subscribe.mock.calls[0];
expect(callArgs[0]).toEqual(APP_READY); expect(callArgs[0]).toEqual(APP_READY);
callArgs[1](); callArgs[1]();
const [rendered, target] = render.mock.calls[0]; const [rendered] = mockRender.mock.calls[0];
expect(rendered).toMatchSnapshot(); expect(rendered).toMatchSnapshot();
expect(target).toEqual(document.getElementById('root'));
}); });
test('subscribe: APP_INIT_ERROR. snapshot: displays an ErrorPage to root element', () => { test('subscribe: APP_INIT_ERROR. snapshot: displays an ErrorPage to root element', () => {
const callArgs = subscribe.mock.calls[1]; const callArgs = subscribe.mock.calls[1];
expect(callArgs[0]).toEqual(APP_INIT_ERROR); expect(callArgs[0]).toEqual(APP_INIT_ERROR);
const error = { message: 'test-error-message' }; const error = { message: 'test-error-message' };
callArgs[1](error); callArgs[1](error);
const [rendered, target] = render.mock.calls[0]; const [rendered] = mockRender.mock.calls[0];
expect(rendered).toMatchSnapshot(); expect(rendered).toMatchSnapshot();
expect(target).toEqual(document.getElementById('root'));
}); });
test('initialize is called with requireAuthenticatedUser', () => { test('initialize is called with requireAuthenticatedUser', () => {
expect(initialize).toHaveBeenCalledTimes(1); expect(initialize).toHaveBeenCalledTimes(1);

View File

@@ -1,6 +1,6 @@
# Course Card Action Slot # Course Card Action Slot
### Slot ID: `course_banner_slot` ### Slot ID: `org.openedx.frontend.learner_dashboard.course_card_banner.v1`
### Props: ### Props:
* `cardId` * `cardId`
@@ -19,16 +19,17 @@ The following `env.config.jsx` will render a custom implemenation of a CourseBan
```js ```js
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
import { Alert } from '@openedx/paragon';
const config = { const config = {
pluginSlots: { pluginSlots: {
course_banner_slot: { 'org.openedx.frontend.learner_dashboard.course_card_banner.v1': {
keepDefault: false, keepDefault: false,
plugins: [ plugins: [
{ {
op: PLUGIN_OPERATIONS.Insert, op: PLUGIN_OPERATIONS.Insert,
widget: { widget: {
id: 'custom_course_banner', id: 'org.openedx.frontend.learner_dashboard.course_card_banner.v1',
type: DIRECT_PLUGIN, type: DIRECT_PLUGIN,
priority: 60, priority: 60,
RenderWidget: ({ cardId }) => ( RenderWidget: ({ cardId }) => (

View File

@@ -5,7 +5,7 @@ import CourseBanner from 'containers/CourseCard/components/CourseCardBanners/Cou
const CourseBannerSlot = ({ cardId }) => ( const CourseBannerSlot = ({ cardId }) => (
<PluginSlot <PluginSlot
id="course_banner_slot" id="org.openedx.frontend.learner_dashboard.course_card_banner.v1"
pluginProps={{ pluginProps={{
cardId, cardId,
}} }}

View File

@@ -1,6 +1,10 @@
# Course Card Action Slot # Course Card Action Slot
### Slot ID: `course_card_action_slot` ### Slot ID: `org.openedx.frontend.learner_dashboard.course_card_action.v1`
### Slot ID Aliases
* `course_card_action_slot`
### Props: ### Props:
* `cardId` * `cardId`
@@ -20,7 +24,7 @@ import ActionButton from 'containers/CourseCard/components/CourseCardActions/Act
const config = { const config = {
pluginSlots: { pluginSlots: {
course_card_action_slot: { 'org.openedx.frontend.learner_dashboard.course_card_action.v1': {
keepDefault: false, keepDefault: false,
plugins: [ plugins: [
{ {

View File

@@ -4,7 +4,8 @@ import { PluginSlot } from '@openedx/frontend-plugin-framework';
const CourseCardActionSlot = ({ cardId }) => ( const CourseCardActionSlot = ({ cardId }) => (
<PluginSlot <PluginSlot
id="course_card_action_slot" id="org.openedx.frontend.learner_dashboard.course_card_action.v1"
idAliases={['course_card_action_slot']}
pluginProps={{ pluginProps={{
cardId, cardId,
}} }}

View File

@@ -1,6 +1,9 @@
# Course List Slot # Course List Slot
### Slot ID: `course_list_slot` ### Slot ID: `org.openedx.frontend.learner_dashboard.course_list.v1`
### Slot ID Aliases
* `course_list_slot`
## Plugin Props ## Plugin Props
@@ -25,7 +28,7 @@ import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-frame
const config = { const config = {
pluginSlots: { pluginSlots: {
course_list_slot: { 'org.openedx.frontend.learner_dashboard.course_list.v1': {
// Hide the default CourseList component // Hide the default CourseList component
keepDefault: false, keepDefault: false,
plugins: [ plugins: [

View File

@@ -4,7 +4,11 @@ import { PluginSlot } from '@openedx/frontend-plugin-framework';
import { CourseList, courseListDataShape } from 'containers/CoursesPanel/CourseList'; import { CourseList, courseListDataShape } from 'containers/CoursesPanel/CourseList';
export const CourseListSlot = ({ courseListData }) => ( export const CourseListSlot = ({ courseListData }) => (
<PluginSlot id="course_list_slot" pluginProps={{ courseListData }}> <PluginSlot
id="org.openedx.frontend.learner_dashboard.course_list.v1"
idAliases={['course_list_slot']}
pluginProps={{ courseListData }}
>
<CourseList courseListData={courseListData} /> <CourseList courseListData={courseListData} />
</PluginSlot> </PluginSlot>
); );

View File

@@ -0,0 +1,41 @@
# Dashboard Modal Slot
### Slot ID: `org.openedx.frontend.learner_dashboard.dashboard_modal.v1`
### https://github.com/openedx/frontend-plugin-framework/blob/master/docs/decisions/0003-slot-naming-and-life-cycle.rst#1-naming-format
## Description
This slot is used for the modal on a dashboard.
The following `env.config.jsx` will render the modal.
## Example
Learner dashboard will show modal
![Screenshot of the dashboard modal](./images/dashboard_modal_slot.png)
```js
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
import { ModalDialog } from '@openedx/paragon';
const config = {
pluginSlots: {
org.openedx.frontend.learner_dashboard.dashboard_modal.v1: {
plugins: [
{
op: PLUGIN_OPERATIONS.Insert,
widget: {
id: 'dashboard_modal',
type: DIRECT_PLUGIN,
priority: 60,
RenderWidget:
<ModalDialog title="Modal that appears on learner dashboard" />,
},
},
],
}
},
}
export default config;
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 KiB

View File

@@ -0,0 +1,8 @@
import React from 'react';
import { PluginSlot } from '@openedx/frontend-plugin-framework';
const DashboardModalSlot = () => (
<PluginSlot id="org.openedx.frontend.learner_dashboard.dashboard_modal.v1" />
);
export default DashboardModalSlot;

View File

@@ -1,12 +1,15 @@
# Footer Slot # Footer Slot
### Slot ID: `footer_slot` ### Slot ID: `org.openedx.frontend.layout.footer.v1`
### Slot ID Aliases
* `footer_slot`
## Description ## Description
This slot is used to replace/modify/hide the footer. This slot is used to replace/modify/hide the footer.
The implementation of the `FooterSlot` component lives in [the `frontend-slot-footer` repository](https://github.com/openedx/frontend-slot-footer/). The implementation of the `FooterSlot` component lives in [the `frontend-component-footer` repository](https://github.com/openedx/frontend-component-footer/).
## Example ## Example
@@ -23,7 +26,7 @@ import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-frame
const config = { const config = {
pluginSlots: { pluginSlots: {
footer_slot: { 'org.openedx.frontend.layout.footer.v1': {
plugins: [ plugins: [
{ {
// Hide the default footer // Hide the default footer

View File

@@ -1,6 +1,9 @@
# No Courses View Slot # No Courses View Slot
### Slot ID: `no_courses_view_slot` ### Slot ID: `org.openedx.frontend.learner_dashboard.no_courses_view.v1`
### Slot ID Aliases
* `no_courses_view_slot`
## Description ## Description
@@ -21,7 +24,7 @@ import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-frame
const config = { const config = {
pluginSlots: { pluginSlots: {
no_courses_view_slot: { 'org.openedx.frontend.learner_dashboard.no_courses_view.v1': {
// Hide the default NoCoursesView component // Hide the default NoCoursesView component
keepDefault: false, keepDefault: false,
plugins: [ plugins: [

View File

@@ -4,7 +4,10 @@ import { PluginSlot } from '@openedx/frontend-plugin-framework';
import NoCoursesView from 'containers/CoursesPanel/NoCoursesView'; import NoCoursesView from 'containers/CoursesPanel/NoCoursesView';
export const NoCoursesViewSlot = () => ( export const NoCoursesViewSlot = () => (
<PluginSlot id="no_courses_view_slot"> <PluginSlot
id="org.openedx.frontend.learner_dashboard.no_courses_view.v1"
idAliases={['no_courses_view_slot']}
>
<NoCoursesView /> <NoCoursesView />
</PluginSlot> </PluginSlot>
); );

View File

@@ -1,7 +1,8 @@
# `frontend-app-learner-dashboard` Plugin Slots # `frontend-app-learner-dashboard` Plugin Slots
* [`course_card_action_slot`](./CourseCardActionSlot/) * [`org.openedx.frontend.learner_dashboard.course_card_action.v1`](./CourseCardActionSlot/)
* [`footer_slot`](./FooterSlot/) * [`org.openedx.frontend.layout.footer.v1`](./FooterSlot/)
* [`widget_sidebar_slot`](./WidgetSidebarSlot/) * [`org.openedx.frontend.learner_dashboard.widget_sidebar.v1`](./WidgetSidebarSlot/)
* [`course_list_slot`](./CourseListSlot/) * [`org.openedx.frontend.learner_dashboard.course_list.v1`](./CourseListSlot/)
* [`no_courses_view_slot`](./NoCoursesViewSlot/) * [`org.openedx.frontend.learner_dashboard.no_courses_view.v1`](./NoCoursesViewSlot/)
* [`org.openedx.frontend.learner_dashboard.dashboard_modal.v1`](./DashboardModalSlot)

View File

@@ -1,6 +1,9 @@
# Widget Sidebar Slot # Widget Sidebar Slot
### Slot ID: `widget_sidebar_slot` ### Slot ID: `org.openedx.frontend.learner_dashboard.widget_sidebar.v1`
### Slot ID Aliases
* `widget_sidebar_slot`
## Description ## Description
@@ -21,7 +24,7 @@ import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-frame
const config = { const config = {
pluginSlots: { pluginSlots: {
widget_sidebar_slot: { 'org.openedx.frontend.learner_dashboard.widget_sidebar.v1': {
// Hide the default LookingForChallenge component // Hide the default LookingForChallenge component
keepDefault: false, keepDefault: false,
plugins: [ plugins: [

View File

@@ -2,7 +2,12 @@
exports[`WidgetSidebar snapshots 1`] = ` exports[`WidgetSidebar snapshots 1`] = `
<PluginSlot <PluginSlot
id="widget_sidebar_slot" id="org.openedx.frontend.learner_dashboard.widget_sidebar.v1"
idAliases={
[
"widget_sidebar_slot",
]
}
> >
<LookingForChallengeWidget /> <LookingForChallengeWidget />
</PluginSlot> </PluginSlot>

View File

@@ -5,7 +5,10 @@ import LookingForChallengeWidget from 'widgets/LookingForChallengeWidget';
// eslint-disable-next-line arrow-body-style // eslint-disable-next-line arrow-body-style
export const WidgetSidebarSlot = () => ( export const WidgetSidebarSlot = () => (
<PluginSlot id="widget_sidebar_slot"> <PluginSlot
id="org.openedx.frontend.learner_dashboard.widget_sidebar.v1"
idAliases={['widget_sidebar_slot']}
>
<LookingForChallengeWidget /> <LookingForChallengeWidget />
</PluginSlot> </PluginSlot>
); );

View File

@@ -1,6 +1,5 @@
/* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable import/no-extraneous-dependencies */
import '@testing-library/jest-dom'; import '@testing-library/jest-dom';
import '@testing-library/jest-dom/extend-expect';
jest.mock('react', () => ({ jest.mock('react', () => ({
...jest.requireActual('react'), ...jest.requireActual('react'),

View File

@@ -20,13 +20,8 @@ export const events = StrictDict({
leaveSession: 'leaveSession', leaveSession: 'leaveSession',
unenrollReason: 'unenrollReason', unenrollReason: 'unenrollReason',
entitlementUnenrollReason: 'entitlementUnenrollReason', entitlementUnenrollReason: 'entitlementUnenrollReason',
enterpriseDashboardModalOpened: 'enterpriseDashboardModalOpened',
enterpriseDashboardModalCTAClicked: 'enterpriseDashboardModalCTAClicked',
enterpriseDashboardModalClosed: 'enterpriseDashboardModalClosed',
}); });
const learnerPortal = 'edx.ui.enterprise.lms.dashboard.learner_portal_modal';
export const eventNames = StrictDict({ export const eventNames = StrictDict({
enterCourseClicked: 'edx.bi.dashboard.enter_course.clicked', enterCourseClicked: 'edx.bi.dashboard.enter_course.clicked',
courseImageClicked: 'edx.bi.dashboard.course_image.clicked', courseImageClicked: 'edx.bi.dashboard.course_image.clicked',
@@ -39,9 +34,6 @@ export const eventNames = StrictDict({
leaveSession: 'course-dashboard.leave-session', leaveSession: 'course-dashboard.leave-session',
unenrollReason: 'unenrollment_reason.selected', unenrollReason: 'unenrollment_reason.selected',
entitlementUnenrollReason: 'entitlement_unenrollment_reason.selected', entitlementUnenrollReason: 'entitlement_unenrollment_reason.selected',
enterpriseDashboardModalOpened: `${learnerPortal}.opened`,
enterpriseDashboardModalCTAClicked: `${learnerPortal}.dashboard_cta.clicked`,
enterpriseDashboardModalClosed: `${learnerPortal}.closed`,
findCoursesClicked: 'edx.bi.dashboard.find_courses_button.clicked', findCoursesClicked: 'edx.bi.dashboard.find_courses_button.clicked',
purchaseCredit: 'edx.bi.credit.clicked_purchase_credit', purchaseCredit: 'edx.bi.credit.clicked_purchase_credit',
filterClicked: 'course-dashboard.filter.clicked', filterClicked: 'course-dashboard.filter.clicked',

View File

@@ -1,7 +1,6 @@
import course from './trackers/course'; import course from './trackers/course';
import credit from './trackers/credit'; import credit from './trackers/credit';
import engagement from './trackers/engagement'; import engagement from './trackers/engagement';
import enterpriseDashboard from './trackers/enterpriseDashboard';
import entitlements from './trackers/entitlements'; import entitlements from './trackers/entitlements';
import socialShare from './trackers/socialShare'; import socialShare from './trackers/socialShare';
import findCourses from './trackers/findCourses'; import findCourses from './trackers/findCourses';
@@ -11,7 +10,6 @@ export default {
course, course,
credit, credit,
engagement, engagement,
enterpriseDashboard,
entitlements, entitlements,
socialShare, socialShare,
findCourses, findCourses,

View File

@@ -1,44 +0,0 @@
import { createEventTracker, createLinkTracker } from 'data/services/segment/utils';
import { eventNames } from '../constants';
/** Enterprise Dashboard events**/
/**
* Creates tracking callback for Enterprise Dashboard Modal open event
* @param {string} enterpriseUUID - enterprise identifier
* @return {func} - Callback that tracks the event when fired.
*/
export const modalOpened = (enterpriseUUID) => () => createEventTracker(
eventNames.enterpriseDashboardModalOpened,
{ enterpriseUUID },
);
/**
* Creates tracking callback for Enterprise Dashboard Modal Call-to-action click-event
* @param {string} enterpriseUUID - enterprise identifier
* @param {string} href - destination url
* @return {func} - Callback that tracks the event when fired and then loads the passed href.
*/
export const modalCTAClicked = (enterpriseUUID, href) => createLinkTracker(
createEventTracker(
eventNames.enterpriseDashboardModalCTAClicked,
{ enterpriseUUID },
),
href,
);
/**
* Creates tracking callback for Enterprise Dashboard Modal close event
* @param {string} enterpriseUUID - enterprise identifier
* @param {string} source - close event soruce ("Cancel button" vs "Escape")
* @return {func} - Callback that tracks the event when fired.
*/
export const modalClosed = (enterpriseUUID, source) => createEventTracker(
eventNames.enterpriseDashboardModalClosed,
{ enterpriseUUID, source },
);
export default {
modalOpened,
modalCTAClicked,
modalClosed,
};

View File

@@ -1,47 +0,0 @@
import { createEventTracker } from 'data/services/segment/utils';
import { eventNames } from '../constants';
import * as trackers from './enterpriseDashboard';
jest.mock('data/services/segment/utils', () => ({
createEventTracker: jest.fn(args => ({ createEventTracker: args })),
createLinkTracker: jest.fn((cb, href) => ({ createLinkTracker: { cb, href } })),
}));
const enterpriseUUID = 'test-enterprise-uuid';
const source = 'test-source';
describe('enterpriseDashboard trackers', () => {
describe('modalOpened', () => {
it('creates event tracker for dashboard modal opened event', () => {
expect(trackers.modalOpened(enterpriseUUID, source)()).toEqual(
createEventTracker(
eventNames.enterpriseDashboardModalOpened,
{ enterpriseUUID, source },
),
);
});
});
describe('modalCTAClicked', () => {
const testHref = 'test-href';
it('creates link tracker for dashboard modal cta click event', () => {
const { cb, href } = trackers.modalCTAClicked(enterpriseUUID, testHref).createLinkTracker;
expect(href).toEqual(testHref);
expect(cb).toEqual(
createEventTracker(
eventNames.enterpriseDashboardModalCTAClicked,
{ enterpriseUUID, source },
),
);
});
});
describe('modalClosed', () => {
it('creates event tracker for dashboard modal closed event with close source', () => {
expect(trackers.modalClosed(enterpriseUUID, source)).toEqual(
createEventTracker(
eventNames.enterpriseDashboardModalClosed,
{ enterpriseUUID, source },
),
);
});
});
});