@openedx/frontend-app-learner-dashboard 1.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.rst +86 -0
- package/package.json +84 -0
- package/src/Main.jsx +20 -0
- package/src/__mocks__/file.js +1 -0
- package/src/__mocks__/svg.js +1 -0
- package/src/__snapshots__/App.test.jsx.snap +83 -0
- package/src/__snapshots__/index.test.jsx.snap +43 -0
- package/src/app.scss +41 -0
- package/src/app.ts +23 -0
- package/src/assets/empty-course.svg +49 -0
- package/src/assets/more-courses-sidewidget.svg +52 -0
- package/src/assets/verified-ribbon.png +0 -0
- package/src/components/Banner.jsx +26 -0
- package/src/components/Banner.test.jsx +27 -0
- package/src/components/__snapshots__/Banner.test.jsx.snap +31 -0
- package/src/constants.ts +1 -0
- package/src/containers/CourseCard/CourseCard.scss +75 -0
- package/src/containers/CourseCard/__snapshots__/index.test.jsx.snap +111 -0
- package/src/containers/CourseCard/components/CourseCardActions/ActionButton/__snapshots__/index.test.jsx.snap +14 -0
- package/src/containers/CourseCard/components/CourseCardActions/ActionButton/hooks.js +8 -0
- package/src/containers/CourseCard/components/CourseCardActions/ActionButton/hooks.test.js +21 -0
- package/src/containers/CourseCard/components/CourseCardActions/ActionButton/index.jsx +16 -0
- package/src/containers/CourseCard/components/CourseCardActions/ActionButton/index.test.jsx +25 -0
- package/src/containers/CourseCard/components/CourseCardActions/BeginCourseButton.jsx +38 -0
- package/src/containers/CourseCard/components/CourseCardActions/BeginCourseButton.test.jsx +86 -0
- package/src/containers/CourseCard/components/CourseCardActions/ResumeButton.jsx +38 -0
- package/src/containers/CourseCard/components/CourseCardActions/ResumeButton.test.jsx +84 -0
- package/src/containers/CourseCard/components/CourseCardActions/SelectSessionButton.jsx +28 -0
- package/src/containers/CourseCard/components/CourseCardActions/SelectSessionButton.test.jsx +34 -0
- package/src/containers/CourseCard/components/CourseCardActions/ViewCourseButton.jsx +37 -0
- package/src/containers/CourseCard/components/CourseCardActions/ViewCourseButton.test.jsx +45 -0
- package/src/containers/CourseCard/components/CourseCardActions/__snapshots__/BeginCourseButton.test.jsx.snap +39 -0
- package/src/containers/CourseCard/components/CourseCardActions/__snapshots__/ResumeButton.test.jsx.snap +39 -0
- package/src/containers/CourseCard/components/CourseCardActions/__snapshots__/SelectSessionButton.test.jsx.snap +19 -0
- package/src/containers/CourseCard/components/CourseCardActions/__snapshots__/ViewCourseButton.test.jsx.snap +39 -0
- package/src/containers/CourseCard/components/CourseCardActions/index.jsx +42 -0
- package/src/containers/CourseCard/components/CourseCardActions/index.test.jsx +97 -0
- package/src/containers/CourseCard/components/CourseCardActions/messages.js +26 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CertificateBanner.jsx +95 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CertificateBanner.test.jsx +227 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CourseBanner.jsx +57 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CourseBanner.test.jsx +131 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/__snapshots__/index.test.jsx.snap +58 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/hooks.js +42 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/hooks.test.js +90 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/index.jsx +36 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/index.test.jsx +95 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/messages.js +16 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/ApprovedContent.jsx +35 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/ApprovedContent.test.jsx +64 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/EligibleContent.jsx +34 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/EligibleContent.test.jsx +82 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/MustRequestContent.jsx +36 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/MustRequestContent.test.jsx +74 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/PendingContent.jsx +30 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/PendingContent.test.jsx +63 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/RejectedContent.jsx +27 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/RejectedContent.test.jsx +54 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditContent.jsx +51 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditContent.test.jsx +60 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditRequestForm/__snapshots__/index.test.jsx.snap +32 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditRequestForm/hooks.js +13 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditRequestForm/hooks.test.js +45 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditRequestForm/index.jsx +43 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditRequestForm/index.test.jsx +65 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/CreditRequestForm/ref.test.jsx +34 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/ProviderLink.jsx +24 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/ProviderLink.test.jsx +42 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/__snapshots__/CreditContent.test.jsx.snap +60 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/components/__snapshots__/ProviderLink.test.jsx.snap +11 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/hooks.js +27 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/hooks.test.js +56 -0
- package/src/containers/CourseCard/components/CourseCardBanners/CreditBanner/views/messages.js +61 -0
- package/src/containers/CourseCard/components/CourseCardBanners/EntitlementBanner.jsx +66 -0
- package/src/containers/CourseCard/components/CourseCardBanners/EntitlementBanner.test.jsx +63 -0
- package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/ProgramsList.jsx +23 -0
- package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/ProgramsList.test.jsx +23 -0
- package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/__snapshots__/ProgramsList.test.jsx.snap +28 -0
- package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/__snapshots__/index.test.jsx.snap +29 -0
- package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/index.jsx +38 -0
- package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/index.test.jsx +42 -0
- package/src/containers/CourseCard/components/CourseCardBanners/RelatedProgramsBanner/messages.js +31 -0
- package/src/containers/CourseCard/components/CourseCardBanners/__snapshots__/CertificateBanner.test.jsx.snap +205 -0
- package/src/containers/CourseCard/components/CourseCardBanners/__snapshots__/CourseBanner.test.jsx.snap +38 -0
- package/src/containers/CourseCard/components/CourseCardBanners/__snapshots__/EntitlementBanner.test.jsx.snap +53 -0
- package/src/containers/CourseCard/components/CourseCardBanners/__snapshots__/index.test.jsx.snap +41 -0
- package/src/containers/CourseCard/components/CourseCardBanners/index.jsx +28 -0
- package/src/containers/CourseCard/components/CourseCardBanners/index.test.jsx +32 -0
- package/src/containers/CourseCard/components/CourseCardBanners/messages.js +106 -0
- package/src/containers/CourseCard/components/CourseCardDetails/__snapshots__/index.test.jsx.snap +56 -0
- package/src/containers/CourseCard/components/CourseCardDetails/hooks.js +67 -0
- package/src/containers/CourseCard/components/CourseCardDetails/hooks.test.js +186 -0
- package/src/containers/CourseCard/components/CourseCardDetails/index.jsx +45 -0
- package/src/containers/CourseCard/components/CourseCardDetails/index.scss +7 -0
- package/src/containers/CourseCard/components/CourseCardDetails/index.test.jsx +71 -0
- package/src/containers/CourseCard/components/CourseCardDetails/messages.js +41 -0
- package/src/containers/CourseCard/components/CourseCardImage.jsx +68 -0
- package/src/containers/CourseCard/components/CourseCardImage.test.jsx +66 -0
- package/src/containers/CourseCard/components/CourseCardMenu/SocialShareMenu.jsx +83 -0
- package/src/containers/CourseCard/components/CourseCardMenu/SocialShareMenu.test.jsx +236 -0
- package/src/containers/CourseCard/components/CourseCardMenu/__snapshots__/index.test.jsx.snap +81 -0
- package/src/containers/CourseCard/components/CourseCardMenu/hooks.js +58 -0
- package/src/containers/CourseCard/components/CourseCardMenu/hooks.test.js +153 -0
- package/src/containers/CourseCard/components/CourseCardMenu/index.jsx +85 -0
- package/src/containers/CourseCard/components/CourseCardMenu/index.test.jsx +214 -0
- package/src/containers/CourseCard/components/CourseCardMenu/messages.js +36 -0
- package/src/containers/CourseCard/components/CourseCardTitle.jsx +43 -0
- package/src/containers/CourseCard/components/CourseCardTitle.test.jsx +67 -0
- package/src/containers/CourseCard/components/RelatedProgramsBadge/__snapshots__/index.test.jsx.snap +25 -0
- package/src/containers/CourseCard/components/RelatedProgramsBadge/hooks.jsx +35 -0
- package/src/containers/CourseCard/components/RelatedProgramsBadge/hooks.test.js +76 -0
- package/src/containers/CourseCard/components/RelatedProgramsBadge/index.jsx +39 -0
- package/src/containers/CourseCard/components/RelatedProgramsBadge/index.test.jsx +30 -0
- package/src/containers/CourseCard/components/RelatedProgramsBadge/messages.js +13 -0
- package/src/containers/CourseCard/components/__snapshots__/CourseCardImage.test.jsx.snap +72 -0
- package/src/containers/CourseCard/components/__snapshots__/CourseCardTitle.test.jsx.snap +33 -0
- package/src/containers/CourseCard/components/hooks.js +33 -0
- package/src/containers/CourseCard/components/hooks.test.js +165 -0
- package/src/containers/CourseCard/hooks.js +23 -0
- package/src/containers/CourseCard/hooks.test.js +48 -0
- package/src/containers/CourseCard/index.jsx +50 -0
- package/src/containers/CourseCard/index.test.jsx +29 -0
- package/src/containers/CourseCard/messages.js +26 -0
- package/src/containers/CourseFilterControls/ActiveCourseFilters.jsx +40 -0
- package/src/containers/CourseFilterControls/ActiveCourseFilters.test.jsx +17 -0
- package/src/containers/CourseFilterControls/CourseFilterControls.jsx +115 -0
- package/src/containers/CourseFilterControls/CourseFilterControls.test.jsx +60 -0
- package/src/containers/CourseFilterControls/__snapshots__/ActiveCourseFilters.test.jsx.snap +39 -0
- package/src/containers/CourseFilterControls/__snapshots__/CourseFilterControls.test.jsx.snap +169 -0
- package/src/containers/CourseFilterControls/components/Checkbox.jsx +21 -0
- package/src/containers/CourseFilterControls/components/Checkbox.test.jsx +15 -0
- package/src/containers/CourseFilterControls/components/FilterForm.jsx +45 -0
- package/src/containers/CourseFilterControls/components/FilterForm.test.jsx +29 -0
- package/src/containers/CourseFilterControls/components/SortForm.jsx +39 -0
- package/src/containers/CourseFilterControls/components/SortForm.test.jsx +19 -0
- package/src/containers/CourseFilterControls/components/__snapshots__/Checkbox.test.jsx.snap +46 -0
- package/src/containers/CourseFilterControls/components/__snapshots__/FilterForm.test.jsx.snap +41 -0
- package/src/containers/CourseFilterControls/components/__snapshots__/SortForm.test.jsx.snap +29 -0
- package/src/containers/CourseFilterControls/hooks.js +60 -0
- package/src/containers/CourseFilterControls/hooks.test.js +113 -0
- package/src/containers/CourseFilterControls/index.jsx +6 -0
- package/src/containers/CourseFilterControls/index.scss +29 -0
- package/src/containers/CourseFilterControls/messages.js +61 -0
- package/src/containers/CoursesPanel/CourseList/__snapshots__/index.test.jsx.snap +70 -0
- package/src/containers/CoursesPanel/CourseList/hooks.js +8 -0
- package/src/containers/CoursesPanel/CourseList/index.jsx +54 -0
- package/src/containers/CoursesPanel/CourseList/index.test.jsx +64 -0
- package/src/containers/CoursesPanel/NoCoursesView/__snapshots__/index.test.jsx.snap +29 -0
- package/src/containers/CoursesPanel/NoCoursesView/index.jsx +40 -0
- package/src/containers/CoursesPanel/NoCoursesView/index.scss +15 -0
- package/src/containers/CoursesPanel/NoCoursesView/index.test.jsx +18 -0
- package/src/containers/CoursesPanel/NoCoursesView/messages.js +26 -0
- package/src/containers/CoursesPanel/__snapshots__/index.test.jsx.snap +55 -0
- package/src/containers/CoursesPanel/hooks.js +54 -0
- package/src/containers/CoursesPanel/hooks.test.js +115 -0
- package/src/containers/CoursesPanel/index.jsx +40 -0
- package/src/containers/CoursesPanel/index.scss +42 -0
- package/src/containers/CoursesPanel/index.test.jsx +58 -0
- package/src/containers/CoursesPanel/messages.js +11 -0
- package/src/containers/Dashboard/DashboardLayout.jsx +54 -0
- package/src/containers/Dashboard/DashboardLayout.test.jsx +115 -0
- package/src/containers/Dashboard/LoadingView.jsx +20 -0
- package/src/containers/Dashboard/LoadingView.test.jsx +23 -0
- package/src/containers/Dashboard/__snapshots__/DashboardLayout.test.jsx.snap +197 -0
- package/src/containers/Dashboard/__snapshots__/LoadingView.test.jsx.snap +13 -0
- package/src/containers/Dashboard/__snapshots__/index.test.jsx.snap +69 -0
- package/src/containers/Dashboard/hooks.js +34 -0
- package/src/containers/Dashboard/hooks.test.js +88 -0
- package/src/containers/Dashboard/index.jsx +43 -0
- package/src/containers/Dashboard/index.scss +29 -0
- package/src/containers/Dashboard/index.test.jsx +122 -0
- package/src/containers/EmailSettingsModal/__snapshots__/index.test.jsx.snap +133 -0
- package/src/containers/EmailSettingsModal/hooks.js +32 -0
- package/src/containers/EmailSettingsModal/hooks.test.js +71 -0
- package/src/containers/EmailSettingsModal/index.jsx +58 -0
- package/src/containers/EmailSettingsModal/index.test.jsx +57 -0
- package/src/containers/EmailSettingsModal/messages.js +37 -0
- package/src/containers/RelatedProgramsModal/__snapshots__/index.test.jsx.snap +169 -0
- package/src/containers/RelatedProgramsModal/components/ProgramCard.jsx +66 -0
- package/src/containers/RelatedProgramsModal/components/ProgramCard.test.jsx +23 -0
- package/src/containers/RelatedProgramsModal/components/__snapshots__/ProgramCard.test.jsx.snap +60 -0
- package/src/containers/RelatedProgramsModal/components/index.scss +23 -0
- package/src/containers/RelatedProgramsModal/components/messages.js +24 -0
- package/src/containers/RelatedProgramsModal/hooks.js +10 -0
- package/src/containers/RelatedProgramsModal/index.jsx +62 -0
- package/src/containers/RelatedProgramsModal/index.scss +5 -0
- package/src/containers/RelatedProgramsModal/index.test.jsx +60 -0
- package/src/containers/RelatedProgramsModal/messages.js +16 -0
- package/src/containers/SelectSessionModal/__snapshots__/index.test.jsx.snap +176 -0
- package/src/containers/SelectSessionModal/constants.js +2 -0
- package/src/containers/SelectSessionModal/hooks.js +77 -0
- package/src/containers/SelectSessionModal/hooks.test.js +194 -0
- package/src/containers/SelectSessionModal/index.jsx +75 -0
- package/src/containers/SelectSessionModal/index.test.jsx +53 -0
- package/src/containers/SelectSessionModal/messages.js +41 -0
- package/src/containers/UnenrollConfirmModal/__snapshots__/index.test.jsx.snap +101 -0
- package/src/containers/UnenrollConfirmModal/components/ConfirmPane.jsx +36 -0
- package/src/containers/UnenrollConfirmModal/components/ConfirmPane.test.jsx +14 -0
- package/src/containers/UnenrollConfirmModal/components/FinishedPane.jsx +35 -0
- package/src/containers/UnenrollConfirmModal/components/FinishedPane.test.jsx +21 -0
- package/src/containers/UnenrollConfirmModal/components/ReasonPane.jsx +65 -0
- package/src/containers/UnenrollConfirmModal/components/ReasonPane.test.jsx +26 -0
- package/src/containers/UnenrollConfirmModal/components/__snapshots__/ConfirmPane.test.jsx.snap +22 -0
- package/src/containers/UnenrollConfirmModal/components/__snapshots__/FinishedPane.test.jsx.snap +38 -0
- package/src/containers/UnenrollConfirmModal/components/__snapshots__/ReasonPane.test.jsx.snap +183 -0
- package/src/containers/UnenrollConfirmModal/components/messages.js +56 -0
- package/src/containers/UnenrollConfirmModal/constants.js +86 -0
- package/src/containers/UnenrollConfirmModal/hooks/index.js +55 -0
- package/src/containers/UnenrollConfirmModal/hooks/index.test.js +101 -0
- package/src/containers/UnenrollConfirmModal/hooks/reasons.js +79 -0
- package/src/containers/UnenrollConfirmModal/hooks/reasons.test.js +192 -0
- package/src/containers/UnenrollConfirmModal/index.jsx +59 -0
- package/src/containers/UnenrollConfirmModal/index.test.jsx +61 -0
- package/src/data/constants/app.js +20 -0
- package/src/data/constants/app.test.js +24 -0
- package/src/data/constants/course.js +17 -0
- package/src/data/constants/credit.js +9 -0
- package/src/data/constants/files.js +20 -0
- package/src/data/constants/htmlKeys.js +21 -0
- package/src/data/constants/requests.js +34 -0
- package/src/data/contexts/GlobalDataContext.jsx +15 -0
- package/src/data/contexts/GlobalDataProvider.jsx +23 -0
- package/src/data/contexts/MasqueradeUserContext.jsx +16 -0
- package/src/data/contexts/MasqueradeUserProvider.jsx +31 -0
- package/src/data/redux/app/index.js +2 -0
- package/src/data/redux/app/reducer.js +81 -0
- package/src/data/redux/app/reducer.test.js +124 -0
- package/src/data/redux/app/selectors/appSelectors.js +23 -0
- package/src/data/redux/app/selectors/appSelectors.test.js +28 -0
- package/src/data/redux/app/selectors/courseCard.js +155 -0
- package/src/data/redux/app/selectors/courseCard.test.js +398 -0
- package/src/data/redux/app/selectors/currentList.js +60 -0
- package/src/data/redux/app/selectors/currentList.test.js +185 -0
- package/src/data/redux/app/selectors/index.js +13 -0
- package/src/data/redux/app/selectors/simpleSelectors.js +38 -0
- package/src/data/redux/app/selectors/simpleSelectors.test.js +75 -0
- package/src/data/redux/hooks/app.js +106 -0
- package/src/data/redux/hooks/index.js +2 -0
- package/src/data/redux/hooks/requests.js +47 -0
- package/src/data/redux/index.js +37 -0
- package/src/data/redux/requests/index.js +2 -0
- package/src/data/redux/requests/reducer.js +53 -0
- package/src/data/redux/requests/reducer.test.js +62 -0
- package/src/data/redux/requests/selectors.js +29 -0
- package/src/data/redux/requests/selectors.test.js +110 -0
- package/src/data/services/lms/api.js +77 -0
- package/src/data/services/lms/api.test.js +156 -0
- package/src/data/services/lms/constants.js +18 -0
- package/src/data/services/lms/fakeData/courses.js +828 -0
- package/src/data/services/lms/fakeData/testUtils.js +40 -0
- package/src/data/services/lms/index.js +8 -0
- package/src/data/services/lms/urls.js +43 -0
- package/src/data/services/lms/urls.test.js +51 -0
- package/src/data/services/lms/utils.js +60 -0
- package/src/data/services/lms/utils.test.js +40 -0
- package/src/data/services/segment/utils.js +17 -0
- package/src/data/services/segment/utils.test.js +36 -0
- package/src/data/store.js +25 -0
- package/src/data/store.test.js +47 -0
- package/src/data/utils.js +19 -0
- package/src/data/utils.test.js +29 -0
- package/src/hooks/api.js +123 -0
- package/src/hooks/api.test.js +273 -0
- package/src/hooks/index.js +7 -0
- package/src/hooks/utils.js +17 -0
- package/src/hooks/utils.test.js +16 -0
- package/src/i18n/index.js +25 -0
- package/src/index.ts +3 -0
- package/src/messages.js +16 -0
- package/src/providers.ts +11 -0
- package/src/routes.jsx +14 -0
- package/src/segment.js +85 -0
- package/src/setupTest.jsx +251 -0
- package/src/slots/CourseBannerSlot/README.md +44 -0
- package/src/slots/CourseBannerSlot/images/course_banner_slot_default.png +0 -0
- package/src/slots/CourseBannerSlot/images/custom_course_banner.png +0 -0
- package/src/slots/CourseBannerSlot/index.jsx +18 -0
- package/src/slots/CourseCardActionSlot/README.md +53 -0
- package/src/slots/CourseCardActionSlot/images/post_course_card_action.png +0 -0
- package/src/slots/CourseCardActionSlot/index.jsx +15 -0
- package/src/slots/CourseListSlot/README.md +54 -0
- package/src/slots/CourseListSlot/images/course_list_slot.png +0 -0
- package/src/slots/CourseListSlot/images/readme_custom_course_list.png +0 -0
- package/src/slots/CourseListSlot/index.jsx +17 -0
- package/src/slots/DashboardModalSlot/README.md +30 -0
- package/src/slots/DashboardModalSlot/images/dashboard_modal_slot.png +0 -0
- package/src/slots/DashboardModalSlot/index.jsx +7 -0
- package/src/slots/NoCoursesViewSlot/README.md +34 -0
- package/src/slots/NoCoursesViewSlot/images/no_course_view_slot.png +0 -0
- package/src/slots/NoCoursesViewSlot/images/readme_custom_no_courses.png +0 -0
- package/src/slots/NoCoursesViewSlot/index.jsx +11 -0
- package/src/slots/README.md +8 -0
- package/src/slots/WidgetSidebarSlot/README.md +51 -0
- package/src/slots/WidgetSidebarSlot/__snapshots__/index.test.jsx.snap +14 -0
- package/src/slots/WidgetSidebarSlot/images/readme_custom_sidebar.png +0 -0
- package/src/slots/WidgetSidebarSlot/images/widget_sidebar_slot.png +0 -0
- package/src/slots/WidgetSidebarSlot/index.jsx +10 -0
- package/src/slots/WidgetSidebarSlot/index.test.jsx +18 -0
- package/src/slots.tsx +9 -0
- package/src/test/app.test.jsx +255 -0
- package/src/test/inspector.js +50 -0
- package/src/test/messages.js +29 -0
- package/src/test/utils.js +3 -0
- package/src/testUtils.js +211 -0
- package/src/tracking/constants.js +50 -0
- package/src/tracking/index.js +17 -0
- package/src/tracking/trackers/course.js +44 -0
- package/src/tracking/trackers/course.test.js +80 -0
- package/src/tracking/trackers/credit.js +20 -0
- package/src/tracking/trackers/credit.test.js +38 -0
- package/src/tracking/trackers/engagement.js +23 -0
- package/src/tracking/trackers/engagement.test.js +31 -0
- package/src/tracking/trackers/entitlements.js +34 -0
- package/src/tracking/trackers/entitlements.test.js +34 -0
- package/src/tracking/trackers/filter.js +21 -0
- package/src/tracking/trackers/filter.test.js +45 -0
- package/src/tracking/trackers/findCourses.js +16 -0
- package/src/tracking/trackers/findCourses.test.js +45 -0
- package/src/tracking/trackers/socialShare.js +11 -0
- package/src/tracking/trackers/socialShare.test.js +17 -0
- package/src/utils/StrictDict.js +19 -0
- package/src/utils/StrictDict.test.js +66 -0
- package/src/utils/dateFormatter.js +9 -0
- package/src/utils/hooks.js +12 -0
- package/src/utils/index.js +5 -0
- package/src/utils/keyStore.js +10 -0
- package/src/widgets/LearnerDashboardHeader/ConfirmEmailBanner/ConfirmEmailBanner.scss +3 -0
- package/src/widgets/LearnerDashboardHeader/ConfirmEmailBanner/assets/confirm-email.svg +76 -0
- package/src/widgets/LearnerDashboardHeader/ConfirmEmailBanner/hooks.js +45 -0
- package/src/widgets/LearnerDashboardHeader/ConfirmEmailBanner/index.jsx +66 -0
- package/src/widgets/LearnerDashboardHeader/ConfirmEmailBanner/messages.js +36 -0
- package/src/widgets/LearnerDashboardHeader/CoursesLink.jsx +14 -0
- package/src/widgets/LearnerDashboardHeader/DiscoverLinkMenuItem.jsx +30 -0
- package/src/widgets/LearnerDashboardHeader/MasqueradeBar/hooks.js +69 -0
- package/src/widgets/LearnerDashboardHeader/MasqueradeBar/index.jsx +92 -0
- package/src/widgets/LearnerDashboardHeader/MasqueradeBar/index.scss +38 -0
- package/src/widgets/LearnerDashboardHeader/MasqueradeBar/messages.js +36 -0
- package/src/widgets/LearnerDashboardHeader/OrderHistoryLinkMenuItem.jsx +29 -0
- package/src/widgets/LearnerDashboardHeader/ProgramsLinkMenuItem.jsx +26 -0
- package/src/widgets/LearnerDashboardHeader/SupportLinkMenuItem.jsx +29 -0
- package/src/widgets/LearnerDashboardHeader/app.tsx +93 -0
- package/src/widgets/LearnerDashboardHeader/hooks.js +20 -0
- package/src/widgets/LearnerDashboardHeader/index.ts +1 -0
- package/src/widgets/LearnerDashboardHeader/messages.js +91 -0
- package/src/widgets/LookingForChallengeWidget/__snapshots__/index.test.jsx.snap +45 -0
- package/src/widgets/LookingForChallengeWidget/index.jsx +47 -0
- package/src/widgets/LookingForChallengeWidget/index.scss +6 -0
- package/src/widgets/LookingForChallengeWidget/index.test.jsx +24 -0
- package/src/widgets/LookingForChallengeWidget/messages.js +16 -0
- package/src/widgets/LookingForChallengeWidget/track.js +15 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
apiHooks,
|
|
5
|
+
reduxHooks,
|
|
6
|
+
utilHooks,
|
|
7
|
+
} from '../../../hooks';
|
|
8
|
+
import { StrictDict } from '../../../utils';
|
|
9
|
+
import track from '../../../tracking';
|
|
10
|
+
|
|
11
|
+
import * as module from './reasons';
|
|
12
|
+
|
|
13
|
+
export const state = StrictDict({
|
|
14
|
+
customOption: (val) => React.useState(val), // eslint-disable-line
|
|
15
|
+
isSkipped: (val) => React.useState(val), // eslint-disable-line
|
|
16
|
+
selectedReason: (val) => React.useState(val), // eslint-disable-line
|
|
17
|
+
isSubmitted: (val) => React.useState(val), //eslint-disable-line
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export const useUnenrollReasons = ({
|
|
21
|
+
cardId,
|
|
22
|
+
}) => {
|
|
23
|
+
// The selected option element from the menu
|
|
24
|
+
const [selectedReason, setSelectedReason] = module.state.selectedReason(null);
|
|
25
|
+
// Custom option element entry value
|
|
26
|
+
const [customOption, setCustomOption] = module.state.customOption('');
|
|
27
|
+
|
|
28
|
+
// Did the user choose to skip selecting a reason?
|
|
29
|
+
const [isSkipped, setIsSkipped] = module.state.isSkipped(false);
|
|
30
|
+
// Did the user submit an unenrollment reason
|
|
31
|
+
const [isSubmitted, setIsSubmitted] = module.state.isSubmitted(false);
|
|
32
|
+
|
|
33
|
+
const { isEntitlement } = reduxHooks.useCardEntitlementData(cardId);
|
|
34
|
+
|
|
35
|
+
const submittedReason = selectedReason === 'custom' ? customOption : selectedReason;
|
|
36
|
+
const hasReason = ![null, ''].includes(submittedReason);
|
|
37
|
+
|
|
38
|
+
const handleTrackReasons = reduxHooks.useTrackCourseEvent(
|
|
39
|
+
track.engagement.unenrollReason,
|
|
40
|
+
cardId,
|
|
41
|
+
submittedReason,
|
|
42
|
+
isEntitlement,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const unenrollFromCourse = apiHooks.useUnenrollFromCourse(cardId);
|
|
46
|
+
|
|
47
|
+
const handleClear = () => {
|
|
48
|
+
setSelectedReason(null);
|
|
49
|
+
setCustomOption('');
|
|
50
|
+
setIsSkipped(false);
|
|
51
|
+
setIsSubmitted(false);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const handleSkip = () => {
|
|
55
|
+
setIsSkipped(true);
|
|
56
|
+
unenrollFromCourse();
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const handleSubmit = (e) => {
|
|
60
|
+
handleTrackReasons(e);
|
|
61
|
+
setIsSubmitted(true);
|
|
62
|
+
unenrollFromCourse();
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const handleCustomOptionChange = utilHooks.useValueCallback(setCustomOption);
|
|
66
|
+
const handleSelectOption = utilHooks.useValueCallback(setSelectedReason);
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
customOption: { value: customOption, onChange: handleCustomOptionChange },
|
|
70
|
+
handleClear,
|
|
71
|
+
handleSkip,
|
|
72
|
+
handleSubmit,
|
|
73
|
+
hasReason,
|
|
74
|
+
isSkipped,
|
|
75
|
+
isSubmitted,
|
|
76
|
+
selectOption: handleSelectOption,
|
|
77
|
+
submittedReason,
|
|
78
|
+
};
|
|
79
|
+
};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { MockUseState } from 'testUtils';
|
|
2
|
+
import track from 'tracking';
|
|
3
|
+
import {
|
|
4
|
+
apiHooks,
|
|
5
|
+
reduxHooks,
|
|
6
|
+
utilHooks,
|
|
7
|
+
} from 'hooks';
|
|
8
|
+
|
|
9
|
+
import * as hooks from './reasons';
|
|
10
|
+
|
|
11
|
+
jest.mock('hooks', () => ({
|
|
12
|
+
apiHooks: {
|
|
13
|
+
useUnenrollFromCourse: jest.fn((...args) => ({ unenrollFromCourse: args })),
|
|
14
|
+
},
|
|
15
|
+
reduxHooks: {
|
|
16
|
+
useCardEntitlementData: jest.fn(),
|
|
17
|
+
useTrackCourseEvent: jest.fn(),
|
|
18
|
+
},
|
|
19
|
+
utilHooks: {
|
|
20
|
+
useValueCallback: jest.fn((cb, prereqs) => ({ useValueCallback: { cb, prereqs } })),
|
|
21
|
+
},
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
const state = new MockUseState(hooks);
|
|
25
|
+
const testValue = 'test-value';
|
|
26
|
+
const testValue2 = 'test-value2';
|
|
27
|
+
const unenrollFromCourse = jest.fn((...args) => ({ unenrollFromCourse: args }));
|
|
28
|
+
const trackCourseEvent = jest.fn((e) => ({ courseEvent: e }));
|
|
29
|
+
apiHooks.useUnenrollFromCourse.mockReturnValue(unenrollFromCourse);
|
|
30
|
+
reduxHooks.useTrackCourseEvent.mockReturnValue(trackCourseEvent);
|
|
31
|
+
let out;
|
|
32
|
+
|
|
33
|
+
const cardId = 'test-card-id';
|
|
34
|
+
const loadHook = (isEntitlement = false) => {
|
|
35
|
+
reduxHooks.useCardEntitlementData.mockReturnValue({ isEntitlement });
|
|
36
|
+
out = hooks.useUnenrollReasons({ cardId });
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
describe('UnenrollConfirmModal reasons hooks', () => {
|
|
40
|
+
describe('state fields', () => {
|
|
41
|
+
state.testGetter(state.keys.customOption);
|
|
42
|
+
state.testGetter(state.keys.isSkipped);
|
|
43
|
+
state.testGetter(state.keys.isSubmitted);
|
|
44
|
+
state.testGetter(state.keys.selectedReason);
|
|
45
|
+
});
|
|
46
|
+
describe('useUnenrollReasons', () => {
|
|
47
|
+
beforeEach(() => {
|
|
48
|
+
jest.clearAllMocks();
|
|
49
|
+
state.mock();
|
|
50
|
+
loadHook();
|
|
51
|
+
});
|
|
52
|
+
afterEach(() => {
|
|
53
|
+
state.restore();
|
|
54
|
+
});
|
|
55
|
+
describe('behavior', () => {
|
|
56
|
+
describe('state fields', () => {
|
|
57
|
+
it('initializes selectedReason with null', () => {
|
|
58
|
+
state.expectInitializedWith(state.keys.selectedReason, null);
|
|
59
|
+
});
|
|
60
|
+
it('initializes customOption with empty string', () => {
|
|
61
|
+
state.expectInitializedWith(state.keys.customOption, '');
|
|
62
|
+
});
|
|
63
|
+
it('initializes isSkipped with false', () => {
|
|
64
|
+
state.expectInitializedWith(state.keys.isSkipped, false);
|
|
65
|
+
});
|
|
66
|
+
it('initializes isSubmitted with false', () => {
|
|
67
|
+
state.expectInitializedWith(state.keys.isSubmitted, false);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
describe('useTrackCourseEvent inititalization', () => {
|
|
71
|
+
it('passes custom option if selectedReason is custom', () => {
|
|
72
|
+
state.mockVal(state.keys.selectedReason, 'custom');
|
|
73
|
+
state.mockVal(state.keys.customOption, testValue);
|
|
74
|
+
loadHook();
|
|
75
|
+
expect(reduxHooks.useTrackCourseEvent).toHaveBeenCalledWith(
|
|
76
|
+
track.engagement.unenrollReason,
|
|
77
|
+
cardId,
|
|
78
|
+
testValue,
|
|
79
|
+
false, // isEntitlement
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
it('passes selected reason if not custom', () => {
|
|
83
|
+
state.mockVal(state.keys.selectedReason, testValue2);
|
|
84
|
+
state.mockVal(state.keys.customOption, testValue);
|
|
85
|
+
loadHook(true);
|
|
86
|
+
expect(reduxHooks.useTrackCourseEvent).toHaveBeenCalledWith(
|
|
87
|
+
track.engagement.unenrollReason,
|
|
88
|
+
cardId,
|
|
89
|
+
testValue2,
|
|
90
|
+
true, // isEntitlement
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
it('initializes card entitlement data with cardId', () => {
|
|
95
|
+
expect(reduxHooks.useCardEntitlementData).toHaveBeenCalledWith(cardId);
|
|
96
|
+
});
|
|
97
|
+
it('initializes unenerollFromCourse event with cardId', () => {
|
|
98
|
+
expect(apiHooks.useUnenrollFromCourse).toHaveBeenCalledWith(cardId);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
describe('output', () => {
|
|
102
|
+
describe('customOption', () => {
|
|
103
|
+
test('customOption.value returns custom option', () => {
|
|
104
|
+
state.mockVal(state.keys.customOption, testValue);
|
|
105
|
+
loadHook();
|
|
106
|
+
expect(out.customOption.value).toEqual(testValue);
|
|
107
|
+
});
|
|
108
|
+
test('customOption.onChange returns valueCallback for setCustomOption', () => {
|
|
109
|
+
expect(out.customOption.onChange).toEqual(
|
|
110
|
+
utilHooks.useValueCallback(state.setState.customOption),
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
describe('hasReason', () => {
|
|
115
|
+
it('returns true if an option is selected other than custom', () => {
|
|
116
|
+
state.mockVal(state.keys.selectedReason, testValue);
|
|
117
|
+
loadHook();
|
|
118
|
+
expect(out.hasReason).toEqual(true);
|
|
119
|
+
});
|
|
120
|
+
it('returns true if custom option is selected and provided', () => {
|
|
121
|
+
state.mockVal(state.keys.selectedReason, 'custom');
|
|
122
|
+
state.mockVal(state.keys.customOption, testValue2);
|
|
123
|
+
loadHook();
|
|
124
|
+
expect(out.hasReason).toEqual(true);
|
|
125
|
+
});
|
|
126
|
+
it('returns false if no option is selected', () => {
|
|
127
|
+
state.mockVal(state.keys.selectedReason, null);
|
|
128
|
+
loadHook();
|
|
129
|
+
expect(out.hasReason).toEqual(false);
|
|
130
|
+
});
|
|
131
|
+
it('returns false if custom option is selcted but not provided', () => {
|
|
132
|
+
state.mockVal(state.keys.selectedReason, 'custom');
|
|
133
|
+
state.mockVal(state.keys.customOption, '');
|
|
134
|
+
loadHook();
|
|
135
|
+
expect(out.hasReason).toEqual(false);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
describe('handleClear method', () => {
|
|
139
|
+
it('resets selected and submitted reasons, custom option and isSkipped', () => {
|
|
140
|
+
out.handleClear();
|
|
141
|
+
expect(state.setState.selectedReason).toHaveBeenCalledWith(null);
|
|
142
|
+
expect(state.setState.customOption).toHaveBeenCalledWith('');
|
|
143
|
+
expect(state.setState.isSkipped).toHaveBeenCalledWith(false);
|
|
144
|
+
expect(state.setState.isSubmitted).toHaveBeenCalledWith(false);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
test('handleSkip sets isSkipped and isSubmitted, and unenrolls w/out a reason', () => {
|
|
148
|
+
out.handleSkip();
|
|
149
|
+
expect(state.setState.isSkipped).toHaveBeenCalledWith(true);
|
|
150
|
+
expect(unenrollFromCourse).toHaveBeenCalledWith();
|
|
151
|
+
});
|
|
152
|
+
describe('handleSubmit', () => {
|
|
153
|
+
it('tracks reason event and calls unenroll action', () => {
|
|
154
|
+
state.mockVal(state.keys.selectedReason, testValue);
|
|
155
|
+
loadHook();
|
|
156
|
+
expect(trackCourseEvent).not.toHaveBeenCalled();
|
|
157
|
+
const event = { test: 'event' };
|
|
158
|
+
out.handleSubmit(event);
|
|
159
|
+
expect(trackCourseEvent).toHaveBeenCalledWith(event);
|
|
160
|
+
expect(unenrollFromCourse).toHaveBeenCalledWith();
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
test('isSkipped returns state value', () => {
|
|
164
|
+
state.mockVal(state.keys.isSkipped, testValue);
|
|
165
|
+
loadHook();
|
|
166
|
+
expect(out.isSkipped).toEqual(testValue);
|
|
167
|
+
});
|
|
168
|
+
test('isSubmitted returns state value', () => {
|
|
169
|
+
state.mockVal(state.keys.isSubmitted, testValue);
|
|
170
|
+
loadHook();
|
|
171
|
+
expect(out.isSubmitted).toEqual(testValue);
|
|
172
|
+
});
|
|
173
|
+
test('selectedOption returns valueCallback for setSelectedReason', () => {
|
|
174
|
+
expect(out.selectOption).toEqual(
|
|
175
|
+
utilHooks.useValueCallback(state.setState.selectedReason),
|
|
176
|
+
);
|
|
177
|
+
});
|
|
178
|
+
describe('submittedReason', () => {
|
|
179
|
+
it('returns the selected reason unless is custom, then shows custom option', () => {
|
|
180
|
+
state.mockVal(state.keys.selectedReason, testValue);
|
|
181
|
+
state.mockVal(state.keys.customOption, testValue2);
|
|
182
|
+
loadHook();
|
|
183
|
+
expect(out.submittedReason).toEqual(testValue);
|
|
184
|
+
state.mockVal(state.keys.selectedReason, 'custom');
|
|
185
|
+
state.mockVal(state.keys.customOption, testValue2);
|
|
186
|
+
loadHook();
|
|
187
|
+
expect(out.submittedReason).toEqual(testValue2);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import { ModalDialog } from '@openedx/paragon';
|
|
6
|
+
|
|
7
|
+
import { nullMethod } from '../../utils';
|
|
8
|
+
|
|
9
|
+
import ConfirmPane from './components/ConfirmPane';
|
|
10
|
+
import ReasonPane from './components/ReasonPane';
|
|
11
|
+
import FinishedPane from './components/FinishedPane';
|
|
12
|
+
|
|
13
|
+
import { useUnenrollData, modalStates } from './hooks';
|
|
14
|
+
|
|
15
|
+
export const UnenrollConfirmModal = ({
|
|
16
|
+
closeModal,
|
|
17
|
+
show,
|
|
18
|
+
cardId,
|
|
19
|
+
}) => {
|
|
20
|
+
const {
|
|
21
|
+
confirm,
|
|
22
|
+
reason,
|
|
23
|
+
closeAndRefresh,
|
|
24
|
+
close,
|
|
25
|
+
modalState,
|
|
26
|
+
} = useUnenrollData({ closeModal, cardId });
|
|
27
|
+
const showFullscreen = modalState === modalStates.reason;
|
|
28
|
+
return (
|
|
29
|
+
<ModalDialog
|
|
30
|
+
isOpen={show}
|
|
31
|
+
onClose={nullMethod}
|
|
32
|
+
hasCloseButton={false}
|
|
33
|
+
isFullscreenOnMobile={showFullscreen}
|
|
34
|
+
title=""
|
|
35
|
+
>
|
|
36
|
+
<div
|
|
37
|
+
className={classNames('bg-white p-3 rounded', { shadow: !showFullscreen })}
|
|
38
|
+
style={{ textAlign: 'start' }}
|
|
39
|
+
>
|
|
40
|
+
{(modalState === modalStates.confirm) && (
|
|
41
|
+
<ConfirmPane handleClose={close} handleConfirm={confirm} />
|
|
42
|
+
)}
|
|
43
|
+
{(modalState === modalStates.finished) && (
|
|
44
|
+
<FinishedPane handleClose={closeAndRefresh} gaveReason={!reason.isSkipped} />
|
|
45
|
+
)}
|
|
46
|
+
{(modalState === modalStates.reason) && (
|
|
47
|
+
<ReasonPane reason={reason} />
|
|
48
|
+
)}
|
|
49
|
+
</div>
|
|
50
|
+
</ModalDialog>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
UnenrollConfirmModal.propTypes = {
|
|
54
|
+
closeModal: PropTypes.func.isRequired,
|
|
55
|
+
show: PropTypes.bool.isRequired,
|
|
56
|
+
cardId: PropTypes.string.isRequired,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default UnenrollConfirmModal;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow } from '@edx/react-unit-test-utils';
|
|
3
|
+
|
|
4
|
+
import { UnenrollConfirmModal } from '.';
|
|
5
|
+
|
|
6
|
+
import * as hooks from './hooks';
|
|
7
|
+
|
|
8
|
+
jest.mock('./components/ConfirmPane', () => 'ConfirmPane');
|
|
9
|
+
jest.mock('./components/ReasonPane', () => 'ReasonPane');
|
|
10
|
+
jest.mock('./components/FinishedPane', () => 'FinishedPane');
|
|
11
|
+
|
|
12
|
+
jest.mock('./hooks', () => ({
|
|
13
|
+
__esModule: true,
|
|
14
|
+
modalStates: jest.requireActual('./hooks').modalStates,
|
|
15
|
+
useUnenrollData: jest.fn(),
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
describe('UnenrollConfirmModal component', () => {
|
|
19
|
+
const hookProps = {
|
|
20
|
+
confirm: jest.fn().mockName('hooks.confirm'),
|
|
21
|
+
reason: {
|
|
22
|
+
isSkipped: false,
|
|
23
|
+
reasonProps: 'other',
|
|
24
|
+
},
|
|
25
|
+
close: jest.fn().mockName('hooks.close'),
|
|
26
|
+
closeAndRefresh: jest.fn().mockName('hooks.closeAndRefresh'),
|
|
27
|
+
modalState: hooks.modalStates.confirm,
|
|
28
|
+
};
|
|
29
|
+
const closeModal = jest.fn().mockName('closeModal');
|
|
30
|
+
const cardId = 'cardId';
|
|
31
|
+
const props = {
|
|
32
|
+
closeModal,
|
|
33
|
+
show: true,
|
|
34
|
+
cardId,
|
|
35
|
+
};
|
|
36
|
+
test('hooks called with closeModal and cardId', () => {
|
|
37
|
+
hooks.useUnenrollData.mockReturnValueOnce(hookProps);
|
|
38
|
+
shallow(<UnenrollConfirmModal {...props} />);
|
|
39
|
+
expect(hooks.useUnenrollData).toHaveBeenCalledWith({ closeModal, cardId });
|
|
40
|
+
});
|
|
41
|
+
test('snapshot: modalStates.confirm', () => {
|
|
42
|
+
hooks.useUnenrollData.mockReturnValueOnce(hookProps);
|
|
43
|
+
expect(shallow(<UnenrollConfirmModal {...props} />).snapshot).toMatchSnapshot();
|
|
44
|
+
});
|
|
45
|
+
test('snapshot: modalStates.finished, reason given', () => {
|
|
46
|
+
hooks.useUnenrollData.mockReturnValueOnce({ ...hookProps, modalState: hooks.modalStates.finished });
|
|
47
|
+
expect(shallow(<UnenrollConfirmModal {...props} />).snapshot).toMatchSnapshot();
|
|
48
|
+
});
|
|
49
|
+
test('snapshot: modalStates.finished, reason skipped', () => {
|
|
50
|
+
hooks.useUnenrollData.mockReturnValueOnce({
|
|
51
|
+
...hookProps,
|
|
52
|
+
modalState: hooks.modalStates.finished,
|
|
53
|
+
isSkipped: true,
|
|
54
|
+
});
|
|
55
|
+
expect(shallow(<UnenrollConfirmModal {...props} />).snapshot).toMatchSnapshot();
|
|
56
|
+
});
|
|
57
|
+
test('snapshot: modalStates.reason, should be fullscreen with no shadow', () => {
|
|
58
|
+
hooks.useUnenrollData.mockReturnValueOnce({ ...hookProps, modalState: hooks.modalStates.reason });
|
|
59
|
+
expect(shallow(<UnenrollConfirmModal {...props} />).snapshot).toMatchSnapshot();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getSiteConfig } from '@openedx/frontend-base';
|
|
2
|
+
import { StrictDict } from '../../utils';
|
|
3
|
+
|
|
4
|
+
export const routePath = `${getSiteConfig().publicPath}:courseId`;
|
|
5
|
+
export const locationId = window.location.pathname.slice(1);
|
|
6
|
+
|
|
7
|
+
export const SortKeys = StrictDict({
|
|
8
|
+
enrolled: 'enrolled',
|
|
9
|
+
title: 'title',
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const FilterKeys = StrictDict({
|
|
13
|
+
inProgress: 'inProgress',
|
|
14
|
+
notStarted: 'notStarted',
|
|
15
|
+
done: 'done',
|
|
16
|
+
notEnrolled: 'notEnrolled',
|
|
17
|
+
upgraded: 'upgraded',
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export const ListPageSize = 25;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as base from '@openedx/frontend-base';
|
|
2
|
+
import * as constants from './app';
|
|
3
|
+
|
|
4
|
+
jest.unmock('./app');
|
|
5
|
+
|
|
6
|
+
jest.mock('@openedx/frontend-base', () => {
|
|
7
|
+
const PUBLIC_PATH = 'test-public-path';
|
|
8
|
+
return {
|
|
9
|
+
getSiteConfig: () => ({ PUBLIC_PATH }),
|
|
10
|
+
PUBLIC_PATH,
|
|
11
|
+
};
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe('app constants', () => {
|
|
15
|
+
test('route path draws from public path and adds courseId', () => {
|
|
16
|
+
expect(constants.routePath).toEqual(`${base.PUBLIC_PATH}:courseId`);
|
|
17
|
+
});
|
|
18
|
+
test('locationId returns trimmed pathname', () => {
|
|
19
|
+
const old = window.location;
|
|
20
|
+
window.location = { pathName: '/somePath.jpg' };
|
|
21
|
+
expect(constants.locationId).toEqual(window.location.pathname.slice(1));
|
|
22
|
+
window.location = old;
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Constants related to courses
|
|
2
|
+
export const COURSE_MODES = {
|
|
3
|
+
VERIFIED: 'verified',
|
|
4
|
+
PROFESSIONAL: 'professional',
|
|
5
|
+
NO_ID_PROFESSIONAL: 'no-id-professional',
|
|
6
|
+
AUDIT: 'audit',
|
|
7
|
+
HONOR: 'honor',
|
|
8
|
+
EXECUTIVE_EDUCATION: 'executive-education',
|
|
9
|
+
PAID_EXECUTIVE_EDUCATION: 'paid-executive-education',
|
|
10
|
+
UNPAID_EXECUTIVE_EDUCATION: 'unpaid-executive-education',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const EXECUTIVE_EDUCATION_COURSE_MODES = [
|
|
14
|
+
COURSE_MODES.EXECUTIVE_EDUCATION,
|
|
15
|
+
COURSE_MODES.PAID_EXECUTIVE_EDUCATION,
|
|
16
|
+
COURSE_MODES.UNPAID_EXECUTIVE_EDUCATION,
|
|
17
|
+
];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { StrictDict } from 'utils';
|
|
2
|
+
|
|
3
|
+
export const FileTypes = StrictDict({
|
|
4
|
+
pdf: 'pdf',
|
|
5
|
+
jpg: 'jpg',
|
|
6
|
+
jpeg: 'jpeg',
|
|
7
|
+
png: 'png',
|
|
8
|
+
bmp: 'bmp',
|
|
9
|
+
txt: 'txt',
|
|
10
|
+
gif: 'gif',
|
|
11
|
+
jfif: 'jfif',
|
|
12
|
+
pjpeg: 'pjpeg',
|
|
13
|
+
pjp: 'pjp',
|
|
14
|
+
svg: 'svg',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const downloadSingleLimit = 1610612736; // 1.5GB
|
|
18
|
+
export const downloadAllLimit = 10737418240; // 10GB
|
|
19
|
+
|
|
20
|
+
export default FileTypes;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { StrictDict } from 'utils';
|
|
2
|
+
|
|
3
|
+
export const buttonStates = StrictDict({
|
|
4
|
+
default: 'default',
|
|
5
|
+
pending: 'pending',
|
|
6
|
+
error: 'error',
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const htmlProps = StrictDict({
|
|
10
|
+
disabled: 'disabled',
|
|
11
|
+
href: 'href',
|
|
12
|
+
onClick: 'onClick',
|
|
13
|
+
onChange: 'onChange',
|
|
14
|
+
onBlur: 'onBlur',
|
|
15
|
+
size: 'size',
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
buttonStates,
|
|
20
|
+
htmlProps,
|
|
21
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { StrictDict } from '../../utils';
|
|
2
|
+
|
|
3
|
+
export const RequestStates = StrictDict({
|
|
4
|
+
inactive: 'inactive',
|
|
5
|
+
pending: 'pending',
|
|
6
|
+
completed: 'completed',
|
|
7
|
+
failed: 'failed',
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const RequestKeys = StrictDict({
|
|
11
|
+
initialize: 'initialize',
|
|
12
|
+
refreshList: 'refreshList',
|
|
13
|
+
newEntitlementEnrollment: 'newEntitlementEnrollment',
|
|
14
|
+
leaveEntitlementEnrollment: 'leaveEntitlementEnrollment',
|
|
15
|
+
switchEntitlementSession: 'switchEntitlementSession',
|
|
16
|
+
unenrollFromCourse: 'unenrollFromCourse',
|
|
17
|
+
updateEmailSettings: 'updateEmailSettings',
|
|
18
|
+
enrollEntitlementSession: 'enrollEntitlementSession',
|
|
19
|
+
leaveEntitlementSession: 'leaveEntitlementSession',
|
|
20
|
+
recommendedCourses: 'recommendedCourses',
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const ErrorCodes = StrictDict({
|
|
24
|
+
missingParam: 'ERR_MISSING_PARAM',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const ErrorStatuses = StrictDict({
|
|
28
|
+
badRequest: 400,
|
|
29
|
+
unauthorized: 401,
|
|
30
|
+
forbidden: 403,
|
|
31
|
+
notFound: 404,
|
|
32
|
+
conflict: 409,
|
|
33
|
+
serverError: 500,
|
|
34
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
const GlobalDataContext = createContext({
|
|
4
|
+
emailConfirmation: {
|
|
5
|
+
isNeeded: false,
|
|
6
|
+
sendEmailUrl: '',
|
|
7
|
+
},
|
|
8
|
+
platformSettings: {
|
|
9
|
+
courseSearchUrl: '',
|
|
10
|
+
},
|
|
11
|
+
setEmailConfirmation: null,
|
|
12
|
+
setPlatformSettings: null,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export default GlobalDataContext;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useState, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import GlobalDataContext from './GlobalDataContext';
|
|
4
|
+
|
|
5
|
+
export default function GlobalDataProvider({ children }) {
|
|
6
|
+
const [emailConfirmation, setEmailConfirmation] = useState({ isNeeded: false, sendEmailUrl: '' });
|
|
7
|
+
const [platformSettings, setPlatformSettings] = useState({ courseSearchUrl: '' });
|
|
8
|
+
|
|
9
|
+
const value = useMemo(() => ({
|
|
10
|
+
emailConfirmation,
|
|
11
|
+
platformSettings,
|
|
12
|
+
setEmailConfirmation,
|
|
13
|
+
setPlatformSettings,
|
|
14
|
+
}), [emailConfirmation, platformSettings]);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<GlobalDataContext.Provider value={value}>
|
|
18
|
+
{children}
|
|
19
|
+
</GlobalDataContext.Provider>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
const MasqueradeUserContext = createContext({
|
|
4
|
+
masqueradeUser: undefined,
|
|
5
|
+
masqueradeIsSuccess: undefined,
|
|
6
|
+
masqueradeIsPending: undefined,
|
|
7
|
+
masqueradeIsError: undefined,
|
|
8
|
+
masqueradeError: undefined,
|
|
9
|
+
setMasqueradeUser: undefined,
|
|
10
|
+
setMasqueradeIsSuccess: undefined,
|
|
11
|
+
setMasqueradeIsPending: undefined,
|
|
12
|
+
setMasqueradeIsError: undefined,
|
|
13
|
+
setMasqueradeError: undefined,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export default MasqueradeUserContext;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useState, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import MasqueradeUserContext from './MasqueradeUserContext';
|
|
4
|
+
|
|
5
|
+
export default function MasqueradeUserProvider({ children }) {
|
|
6
|
+
const [masqueradeUser, setMasqueradeUser] = useState(null);
|
|
7
|
+
const [masqueradeIsSuccess, setMasqueradeIsSuccess] = useState(false);
|
|
8
|
+
const [masqueradeIsPending, setMasqueradeIsPending] = useState(false);
|
|
9
|
+
const [masqueradeIsError, setMasqueradeIsError] = useState(false);
|
|
10
|
+
const [masqueradeError, setMasqueradeError] = useState(null);
|
|
11
|
+
|
|
12
|
+
const value = useMemo(() => ({
|
|
13
|
+
masqueradeUser,
|
|
14
|
+
masqueradeIsPending,
|
|
15
|
+
masqueradeIsSuccess,
|
|
16
|
+
masqueradeIsError,
|
|
17
|
+
masqueradeError,
|
|
18
|
+
setMasqueradeUser,
|
|
19
|
+
setMasqueradeIsPending,
|
|
20
|
+
setMasqueradeIsSuccess,
|
|
21
|
+
setMasqueradeIsError,
|
|
22
|
+
setMasqueradeError,
|
|
23
|
+
}), [masqueradeUser, masqueradeIsSuccess, masqueradeIsPending, masqueradeIsError, masqueradeError]);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<MasqueradeUserContext.Provider value={value}>
|
|
27
|
+
{children}
|
|
28
|
+
</MasqueradeUserContext.Provider>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|