@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,88 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { useIntl } from '@openedx/frontend-base';
|
|
4
|
+
import { useWindowSize, breakpoints } from '@openedx/paragon';
|
|
5
|
+
|
|
6
|
+
import { apiHooks } from 'hooks';
|
|
7
|
+
import { MockUseState } from 'testUtils';
|
|
8
|
+
|
|
9
|
+
import appMessages from 'messages';
|
|
10
|
+
import * as hooks from './hooks';
|
|
11
|
+
|
|
12
|
+
jest.mock('@openedx/paragon', () => ({
|
|
13
|
+
useWindowSize: jest.fn(),
|
|
14
|
+
breakpoints: {},
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
jest.mock('hooks', () => ({
|
|
18
|
+
apiHooks: {
|
|
19
|
+
useInitializeApp: jest.fn(),
|
|
20
|
+
},
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
const state = new MockUseState(hooks);
|
|
24
|
+
|
|
25
|
+
const initializeApp = jest.fn();
|
|
26
|
+
apiHooks.useInitializeApp.mockReturnValue(initializeApp);
|
|
27
|
+
useWindowSize.mockReturnValue({ width: 20 });
|
|
28
|
+
breakpoints.large = { maxWidth: 30 };
|
|
29
|
+
describe('CourseCard hooks', () => {
|
|
30
|
+
const { formatMessage } = useIntl();
|
|
31
|
+
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
jest.clearAllMocks();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('state fields', () => {
|
|
37
|
+
state.testGetter(state.keys.sidebarShowing);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('useDashboardLayoutData', () => {
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
state.mock();
|
|
43
|
+
});
|
|
44
|
+
describe('behavior', () => {
|
|
45
|
+
it('initializes sidebarShowing to default true value', () => {
|
|
46
|
+
hooks.useDashboardLayoutData();
|
|
47
|
+
state.expectInitializedWith(state.keys.sidebarShowing, true);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
describe('output', () => {
|
|
51
|
+
describe('isDashboardCollapsed', () => {
|
|
52
|
+
it('returns true iff windowSize width is below the xl breakpoint', () => {
|
|
53
|
+
expect(hooks.useDashboardLayoutData().isDashboardCollapsed).toEqual(true);
|
|
54
|
+
useWindowSize.mockReturnValueOnce({ width: 40 });
|
|
55
|
+
expect(hooks.useDashboardLayoutData().isDashboardCollapsed).toEqual(false);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
it('forwards sidebarShowing and setSidebarShowing from state hook', () => {
|
|
59
|
+
const hook = hooks.useDashboardLayoutData();
|
|
60
|
+
const { sidebarShowing, setSidebarShowing } = hook;
|
|
61
|
+
expect(sidebarShowing).toEqual(state.stateVals.sidebarShowing);
|
|
62
|
+
expect(setSidebarShowing).toEqual(state.setState.sidebarShowing);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
describe('useInitializeDashboard', () => {
|
|
67
|
+
it('dispatches initialize thunk action on component load', () => {
|
|
68
|
+
hooks.useInitializeDashboard();
|
|
69
|
+
const [cb, prereqs] = React.useEffect.mock.calls[0];
|
|
70
|
+
expect(prereqs).toEqual([]);
|
|
71
|
+
expect(initializeApp).not.toHaveBeenCalled();
|
|
72
|
+
cb();
|
|
73
|
+
expect(initializeApp).toHaveBeenCalledWith();
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
describe('useDashboardMessages', () => {
|
|
77
|
+
it('returns spinner screen reader text', () => {
|
|
78
|
+
expect(hooks.useDashboardMessages()['learner-dash.loadingSR']).toEqual(
|
|
79
|
+
formatMessage(appMessages['learner-dash.loadingSR']),
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
it('returns page title', () => {
|
|
83
|
+
expect(hooks.useDashboardMessages()['learner-dash.title']).toEqual(
|
|
84
|
+
formatMessage(appMessages['learner-dash.title']),
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { apiHooks, reduxHooks } from '../../hooks';
|
|
2
|
+
import SelectSessionModal from '../../containers/SelectSessionModal';
|
|
3
|
+
import CoursesPanel from '../../containers/CoursesPanel';
|
|
4
|
+
import DashboardModalSlot from '../../slots/DashboardModalSlot';
|
|
5
|
+
|
|
6
|
+
import LoadingView from './LoadingView';
|
|
7
|
+
import DashboardLayout from './DashboardLayout';
|
|
8
|
+
import hooks from './hooks';
|
|
9
|
+
import './index.scss';
|
|
10
|
+
|
|
11
|
+
export const Dashboard = () => {
|
|
12
|
+
const { isPending } = apiHooks.useInitializeApp();
|
|
13
|
+
const { pageTitle } = hooks.useDashboardMessages();
|
|
14
|
+
const hasCourses = reduxHooks.useHasCourses();
|
|
15
|
+
const showSelectSessionModal = reduxHooks.useShowSelectSessionModal();
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div id="learnerdashboardroot">
|
|
19
|
+
<main>
|
|
20
|
+
<div id="dashboard-container" className="d-flex flex-column p-2 pt-0">
|
|
21
|
+
<h1 className="sr-only">{pageTitle}</h1>
|
|
22
|
+
{!isPending && (
|
|
23
|
+
<>
|
|
24
|
+
<DashboardModalSlot />
|
|
25
|
+
{(hasCourses && showSelectSessionModal) && <SelectSessionModal />}
|
|
26
|
+
</>
|
|
27
|
+
)}
|
|
28
|
+
<div id="dashboard-content" data-testid="dashboard-content">
|
|
29
|
+
{isPending
|
|
30
|
+
? (<LoadingView />)
|
|
31
|
+
: (
|
|
32
|
+
<DashboardLayout>
|
|
33
|
+
<CoursesPanel />
|
|
34
|
+
</DashboardLayout>
|
|
35
|
+
)}
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</main>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default Dashboard;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
@import "@openedx/paragon/scss/core/core";
|
|
2
|
+
|
|
3
|
+
.course-list-column {
|
|
4
|
+
padding: 0 map-get($spacers, 4);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.sidebar-column {
|
|
8
|
+
padding: 0 map-get($spacers, 3) 0 map-get($spacers, 1);
|
|
9
|
+
|
|
10
|
+
&.not-collapsed {
|
|
11
|
+
padding-top: map-get($spacers, 2);
|
|
12
|
+
|
|
13
|
+
& >:first-child {
|
|
14
|
+
margin-top: map-get($spacers, 5\.5);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@include media-breakpoint-down(lg) {
|
|
20
|
+
.sidebar-column {
|
|
21
|
+
// grid are inheriting dir="ltr" from the body, so we need to override it
|
|
22
|
+
[dir=ltr] & {
|
|
23
|
+
padding: 0 map-get($spacers, 3);
|
|
24
|
+
}
|
|
25
|
+
[dir=rtl] & {
|
|
26
|
+
padding: 0 map-get($spacers, 3);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { shallow } from '@edx/react-unit-test-utils';
|
|
2
|
+
|
|
3
|
+
import { reduxHooks } from 'hooks';
|
|
4
|
+
|
|
5
|
+
import SelectSessionModal from 'containers/SelectSessionModal';
|
|
6
|
+
import CoursesPanel from 'containers/CoursesPanel';
|
|
7
|
+
|
|
8
|
+
import DashboardLayout from './DashboardLayout';
|
|
9
|
+
import LoadingView from './LoadingView';
|
|
10
|
+
import hooks from './hooks';
|
|
11
|
+
import Dashboard from '.';
|
|
12
|
+
|
|
13
|
+
jest.mock('hooks', () => ({
|
|
14
|
+
reduxHooks: {
|
|
15
|
+
useHasCourses: jest.fn(),
|
|
16
|
+
useShowSelectSessionModal: jest.fn(),
|
|
17
|
+
useRequestIsPending: jest.fn(),
|
|
18
|
+
},
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
jest.mock('slots/DashboardModalSlot', () => 'DashboardModalSlot');
|
|
22
|
+
jest.mock('containers/CoursesPanel', () => 'CoursesPanel');
|
|
23
|
+
jest.mock('./LoadingView', () => 'LoadingView');
|
|
24
|
+
jest.mock('./DashboardLayout', () => 'DashboardLayout');
|
|
25
|
+
|
|
26
|
+
jest.mock('./hooks', () => ({
|
|
27
|
+
useInitializeDashboard: jest.fn(),
|
|
28
|
+
useDashboardMessages: jest.fn(),
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
const pageTitle = 'test-page-title';
|
|
32
|
+
|
|
33
|
+
describe('Dashboard', () => {
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
hooks.useDashboardMessages.mockReturnValue({ pageTitle });
|
|
36
|
+
});
|
|
37
|
+
const createWrapper = ({
|
|
38
|
+
hasCourses,
|
|
39
|
+
initIsPending,
|
|
40
|
+
showSelectSessionModal,
|
|
41
|
+
}) => {
|
|
42
|
+
reduxHooks.useHasCourses.mockReturnValueOnce(hasCourses);
|
|
43
|
+
reduxHooks.useRequestIsPending.mockReturnValueOnce(initIsPending);
|
|
44
|
+
reduxHooks.useShowSelectSessionModal.mockReturnValueOnce(showSelectSessionModal);
|
|
45
|
+
return shallow(<Dashboard />);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
let wrapper;
|
|
49
|
+
describe('snapshots', () => {
|
|
50
|
+
const testTitle = () => {
|
|
51
|
+
test('page title is displayed in sr-only h1 tag', () => {
|
|
52
|
+
const heading = wrapper.instance.findByType('h1')[0];
|
|
53
|
+
expect(heading.props.className).toEqual('sr-only');
|
|
54
|
+
expect(heading.children[0].el).toEqual(pageTitle);
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
const testSnapshot = () => {
|
|
58
|
+
test('snapshot', () => {
|
|
59
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
const testContent = (el) => {
|
|
63
|
+
expect(wrapper.instance.findByTestId('dashboard-content')[0].children[0]).toMatchObject(shallow(el));
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const renderString = (show) => (show ? 'renders' : 'does not render');
|
|
67
|
+
const testView = ({
|
|
68
|
+
props,
|
|
69
|
+
content: [contentName, contentEl],
|
|
70
|
+
showSelectSessionModal,
|
|
71
|
+
}) => {
|
|
72
|
+
beforeEach(() => { wrapper = createWrapper(props); });
|
|
73
|
+
testTitle();
|
|
74
|
+
testSnapshot();
|
|
75
|
+
it(`renders ${contentName}`, () => {
|
|
76
|
+
testContent(contentEl);
|
|
77
|
+
});
|
|
78
|
+
it(`${renderString(showSelectSessionModal)} select session modal`, () => {
|
|
79
|
+
expect(wrapper.instance.findByType(SelectSessionModal).length).toEqual(showSelectSessionModal ? 1 : 0);
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
describe('courses still loading', () => {
|
|
83
|
+
testView({
|
|
84
|
+
props: {
|
|
85
|
+
hasCourses: false,
|
|
86
|
+
initIsPending: true,
|
|
87
|
+
showSelectSessionModal: false,
|
|
88
|
+
},
|
|
89
|
+
content: ['LoadingView', <LoadingView />],
|
|
90
|
+
showSelectSessionModal: false,
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe('courses loaded, show select session modal', () => {
|
|
95
|
+
testView({
|
|
96
|
+
props: {
|
|
97
|
+
hasCourses: true,
|
|
98
|
+
initIsPending: false,
|
|
99
|
+
showSelectSessionModal: true,
|
|
100
|
+
},
|
|
101
|
+
content: ['LoadedView', (
|
|
102
|
+
<DashboardLayout><CoursesPanel /></DashboardLayout>
|
|
103
|
+
)],
|
|
104
|
+
showSelectSessionModal: true,
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
describe('there are no courses', () => {
|
|
109
|
+
testView({
|
|
110
|
+
props: {
|
|
111
|
+
hasCourses: false,
|
|
112
|
+
initIsPending: false,
|
|
113
|
+
showSelectSessionModal: false,
|
|
114
|
+
},
|
|
115
|
+
content: ['Dashboard layout with no courses sidebar and content', (
|
|
116
|
+
<DashboardLayout><CoursesPanel /></DashboardLayout>
|
|
117
|
+
)],
|
|
118
|
+
showSelectSessionModal: false,
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`EmailSettingsModal render snapshot: emails disabled, show: false 1`] = `
|
|
4
|
+
<ModalDialog
|
|
5
|
+
hasCloseButton={false}
|
|
6
|
+
isOpen={false}
|
|
7
|
+
onClose={[MockFunction utils.nullMethod]}
|
|
8
|
+
title=""
|
|
9
|
+
>
|
|
10
|
+
<div
|
|
11
|
+
className="bg-white p-3 rounded shadow"
|
|
12
|
+
style={
|
|
13
|
+
{
|
|
14
|
+
"textAlign": "start",
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
>
|
|
18
|
+
<h4>
|
|
19
|
+
Receive course emails?
|
|
20
|
+
</h4>
|
|
21
|
+
<Form.Switch
|
|
22
|
+
checked={false}
|
|
23
|
+
onChange={[MockFunction hooks.onToggle]}
|
|
24
|
+
>
|
|
25
|
+
Course emails are off
|
|
26
|
+
</Form.Switch>
|
|
27
|
+
<p>
|
|
28
|
+
Course emails include important information about your course from instructors.
|
|
29
|
+
</p>
|
|
30
|
+
<ActionRow>
|
|
31
|
+
<Button
|
|
32
|
+
onClick={[MockFunction closeModal]}
|
|
33
|
+
variant="tertiary"
|
|
34
|
+
>
|
|
35
|
+
Never mind
|
|
36
|
+
</Button>
|
|
37
|
+
<Button
|
|
38
|
+
onClick={[MockFunction hooks.save]}
|
|
39
|
+
>
|
|
40
|
+
Save settings
|
|
41
|
+
</Button>
|
|
42
|
+
</ActionRow>
|
|
43
|
+
</div>
|
|
44
|
+
</ModalDialog>
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
exports[`EmailSettingsModal render snapshot: emails disabled, show: true 1`] = `
|
|
48
|
+
<ModalDialog
|
|
49
|
+
hasCloseButton={false}
|
|
50
|
+
isOpen={true}
|
|
51
|
+
onClose={[MockFunction utils.nullMethod]}
|
|
52
|
+
title=""
|
|
53
|
+
>
|
|
54
|
+
<div
|
|
55
|
+
className="bg-white p-3 rounded shadow"
|
|
56
|
+
style={
|
|
57
|
+
{
|
|
58
|
+
"textAlign": "start",
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
>
|
|
62
|
+
<h4>
|
|
63
|
+
Receive course emails?
|
|
64
|
+
</h4>
|
|
65
|
+
<Form.Switch
|
|
66
|
+
checked={false}
|
|
67
|
+
onChange={[MockFunction hooks.onToggle]}
|
|
68
|
+
>
|
|
69
|
+
Course emails are off
|
|
70
|
+
</Form.Switch>
|
|
71
|
+
<p>
|
|
72
|
+
Course emails include important information about your course from instructors.
|
|
73
|
+
</p>
|
|
74
|
+
<ActionRow>
|
|
75
|
+
<Button
|
|
76
|
+
onClick={[MockFunction closeModal]}
|
|
77
|
+
variant="tertiary"
|
|
78
|
+
>
|
|
79
|
+
Never mind
|
|
80
|
+
</Button>
|
|
81
|
+
<Button
|
|
82
|
+
onClick={[MockFunction hooks.save]}
|
|
83
|
+
>
|
|
84
|
+
Save settings
|
|
85
|
+
</Button>
|
|
86
|
+
</ActionRow>
|
|
87
|
+
</div>
|
|
88
|
+
</ModalDialog>
|
|
89
|
+
`;
|
|
90
|
+
|
|
91
|
+
exports[`EmailSettingsModal render snapshot: emails enabled, show: true 1`] = `
|
|
92
|
+
<ModalDialog
|
|
93
|
+
hasCloseButton={false}
|
|
94
|
+
isOpen={true}
|
|
95
|
+
onClose={[MockFunction utils.nullMethod]}
|
|
96
|
+
title=""
|
|
97
|
+
>
|
|
98
|
+
<div
|
|
99
|
+
className="bg-white p-3 rounded shadow"
|
|
100
|
+
style={
|
|
101
|
+
{
|
|
102
|
+
"textAlign": "start",
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
>
|
|
106
|
+
<h4>
|
|
107
|
+
Receive course emails?
|
|
108
|
+
</h4>
|
|
109
|
+
<Form.Switch
|
|
110
|
+
checked={true}
|
|
111
|
+
onChange={[MockFunction hooks.onToggle]}
|
|
112
|
+
>
|
|
113
|
+
Course emails are on
|
|
114
|
+
</Form.Switch>
|
|
115
|
+
<p>
|
|
116
|
+
Course emails include important information about your course from instructors.
|
|
117
|
+
</p>
|
|
118
|
+
<ActionRow>
|
|
119
|
+
<Button
|
|
120
|
+
onClick={[MockFunction closeModal]}
|
|
121
|
+
variant="tertiary"
|
|
122
|
+
>
|
|
123
|
+
Never mind
|
|
124
|
+
</Button>
|
|
125
|
+
<Button
|
|
126
|
+
onClick={[MockFunction hooks.save]}
|
|
127
|
+
>
|
|
128
|
+
Save settings
|
|
129
|
+
</Button>
|
|
130
|
+
</ActionRow>
|
|
131
|
+
</div>
|
|
132
|
+
</ModalDialog>
|
|
133
|
+
`;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { StrictDict } from '../../utils';
|
|
4
|
+
import { reduxHooks, apiHooks } from '../../hooks';
|
|
5
|
+
|
|
6
|
+
import * as module from './hooks';
|
|
7
|
+
|
|
8
|
+
export const state = StrictDict({
|
|
9
|
+
toggle: (val) => React.useState(val), // eslint-disable-line
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const useEmailData = ({
|
|
13
|
+
closeModal,
|
|
14
|
+
cardId,
|
|
15
|
+
}) => {
|
|
16
|
+
const { hasOptedOutOfEmail } = reduxHooks.useCardEnrollmentData(cardId);
|
|
17
|
+
const [isOptedOut, setIsOptedOut] = module.state.toggle(hasOptedOutOfEmail);
|
|
18
|
+
const updateEmailSettings = apiHooks.useUpdateEmailSettings(cardId);
|
|
19
|
+
const onToggle = () => setIsOptedOut(!isOptedOut);
|
|
20
|
+
const save = () => {
|
|
21
|
+
updateEmailSettings(!isOptedOut);
|
|
22
|
+
closeModal();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
onToggle,
|
|
27
|
+
save,
|
|
28
|
+
isOptedOut,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default useEmailData;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { MockUseState } from 'testUtils';
|
|
2
|
+
import { reduxHooks, apiHooks } from 'hooks';
|
|
3
|
+
|
|
4
|
+
import * as hooks from './hooks';
|
|
5
|
+
|
|
6
|
+
jest.mock('hooks', () => ({
|
|
7
|
+
reduxHooks: {
|
|
8
|
+
useCardEnrollmentData: jest.fn(),
|
|
9
|
+
},
|
|
10
|
+
apiHooks: {
|
|
11
|
+
useUpdateEmailSettings: jest.fn(),
|
|
12
|
+
},
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
const cardId = 'my-test-course-number';
|
|
16
|
+
const closeModal = jest.fn();
|
|
17
|
+
const updateEmailSettings = jest.fn();
|
|
18
|
+
apiHooks.useUpdateEmailSettings.mockReturnValue(updateEmailSettings);
|
|
19
|
+
|
|
20
|
+
const state = new MockUseState(hooks);
|
|
21
|
+
|
|
22
|
+
describe('EmailSettingsModal hooks', () => {
|
|
23
|
+
let out;
|
|
24
|
+
describe('state values', () => {
|
|
25
|
+
state.testGetter(state.keys.toggle);
|
|
26
|
+
});
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
jest.clearAllMocks();
|
|
29
|
+
});
|
|
30
|
+
describe('useEmailData', () => {
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
state.mock();
|
|
33
|
+
reduxHooks.useCardEnrollmentData.mockReturnValueOnce({ hasOptedOutOfEmail: true });
|
|
34
|
+
out = hooks.useEmailData({ closeModal, cardId });
|
|
35
|
+
});
|
|
36
|
+
afterEach(state.restore);
|
|
37
|
+
|
|
38
|
+
it('loads enrollment data based on course number', () => {
|
|
39
|
+
expect(reduxHooks.useCardEnrollmentData).toHaveBeenCalledWith(cardId);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('initializes toggle value to cardData.hasOptedOutOfEmail', () => {
|
|
43
|
+
state.expectInitializedWith(state.keys.toggle, true);
|
|
44
|
+
expect(out.isOptedOut).toEqual(true);
|
|
45
|
+
|
|
46
|
+
reduxHooks.useCardEnrollmentData.mockReturnValueOnce({ hasOptedOutOfEmail: false });
|
|
47
|
+
out = hooks.useEmailData({ closeModal, cardId });
|
|
48
|
+
state.expectInitializedWith(state.keys.toggle, false);
|
|
49
|
+
expect(out.isOptedOut).toEqual(false);
|
|
50
|
+
});
|
|
51
|
+
it('initializes email settings hok with cardId', () => {
|
|
52
|
+
expect(apiHooks.useUpdateEmailSettings).toHaveBeenCalledWith(cardId);
|
|
53
|
+
});
|
|
54
|
+
describe('onToggle - returned callback', () => {
|
|
55
|
+
it('sets toggle state value to opposite current value', () => {
|
|
56
|
+
out.onToggle();
|
|
57
|
+
expect(state.setState.toggle).toHaveBeenCalledWith(!out.isOptedOut);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
describe('save', () => {
|
|
61
|
+
it('calls updateEmailSettings', () => {
|
|
62
|
+
out.save();
|
|
63
|
+
expect(updateEmailSettings).toHaveBeenCalledWith(!out.isOptedOut);
|
|
64
|
+
});
|
|
65
|
+
it('calls closeModal', () => {
|
|
66
|
+
out.save();
|
|
67
|
+
expect(closeModal).toHaveBeenCalled();
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { useIntl } from '@openedx/frontend-base';
|
|
5
|
+
import {
|
|
6
|
+
ActionRow,
|
|
7
|
+
Button,
|
|
8
|
+
Form,
|
|
9
|
+
ModalDialog,
|
|
10
|
+
} from '@openedx/paragon';
|
|
11
|
+
|
|
12
|
+
import { nullMethod } from '../../utils';
|
|
13
|
+
|
|
14
|
+
import useEmailData from './hooks';
|
|
15
|
+
import messages from './messages';
|
|
16
|
+
|
|
17
|
+
export const EmailSettingsModal = ({
|
|
18
|
+
closeModal,
|
|
19
|
+
show,
|
|
20
|
+
cardId,
|
|
21
|
+
}) => {
|
|
22
|
+
const {
|
|
23
|
+
isOptedOut,
|
|
24
|
+
onToggle,
|
|
25
|
+
save,
|
|
26
|
+
} = useEmailData({ closeModal, cardId });
|
|
27
|
+
const { formatMessage } = useIntl();
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<ModalDialog
|
|
31
|
+
isOpen={show}
|
|
32
|
+
onClose={nullMethod}
|
|
33
|
+
hasCloseButton={false}
|
|
34
|
+
title=""
|
|
35
|
+
>
|
|
36
|
+
<div className="bg-white p-3 rounded shadow" style={{ textAlign: 'start' }}>
|
|
37
|
+
<h4>{formatMessage(messages.header)}</h4>
|
|
38
|
+
<Form.Switch checked={!isOptedOut} onChange={onToggle}>
|
|
39
|
+
{formatMessage(isOptedOut ? messages.emailsOff : messages.emailsOn)}
|
|
40
|
+
</Form.Switch>
|
|
41
|
+
<p>{formatMessage(messages.description)}</p>
|
|
42
|
+
<ActionRow>
|
|
43
|
+
<Button variant="tertiary" onClick={closeModal}>
|
|
44
|
+
{formatMessage(messages.nevermind)}
|
|
45
|
+
</Button>
|
|
46
|
+
<Button onClick={save}>{formatMessage(messages.save)}</Button>
|
|
47
|
+
</ActionRow>
|
|
48
|
+
</div>
|
|
49
|
+
</ModalDialog>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
EmailSettingsModal.propTypes = {
|
|
53
|
+
cardId: PropTypes.string.isRequired,
|
|
54
|
+
closeModal: PropTypes.func.isRequired,
|
|
55
|
+
show: PropTypes.bool.isRequired,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default EmailSettingsModal;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow } from '@edx/react-unit-test-utils';
|
|
3
|
+
|
|
4
|
+
import hooks from './hooks';
|
|
5
|
+
import EmailSettingsModal from '.';
|
|
6
|
+
|
|
7
|
+
jest.mock('./hooks', () => ({
|
|
8
|
+
__esModule: true,
|
|
9
|
+
default: jest.fn(),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
const hookProps = {
|
|
13
|
+
isOptedOut: true,
|
|
14
|
+
onToggle: jest.fn().mockName('hooks.onToggle'),
|
|
15
|
+
save: jest.fn().mockName('hooks.save'),
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const props = {
|
|
19
|
+
closeModal: jest.fn().mockName('closeModal'),
|
|
20
|
+
show: true,
|
|
21
|
+
cardId: 'test-course-number',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
describe('EmailSettingsModal', () => {
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
jest.clearAllMocks();
|
|
27
|
+
});
|
|
28
|
+
describe('behavior', () => {
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
hooks.mockReturnValueOnce(hookProps);
|
|
31
|
+
shallow(<EmailSettingsModal {...props} />);
|
|
32
|
+
});
|
|
33
|
+
it('calls hook w/ closeModal and cardId from props', () => {
|
|
34
|
+
expect(hooks).toHaveBeenCalledWith({
|
|
35
|
+
closeModal: props.closeModal,
|
|
36
|
+
cardId: props.cardId,
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
describe('render', () => {
|
|
41
|
+
test('snapshot: emails disabled, show: false', () => {
|
|
42
|
+
hooks.mockReturnValueOnce(hookProps);
|
|
43
|
+
expect(shallow(<EmailSettingsModal {...props} show={false} />).snapshot).toMatchSnapshot();
|
|
44
|
+
});
|
|
45
|
+
test('snapshot: emails disabled, show: true', () => {
|
|
46
|
+
hooks.mockReturnValueOnce(hookProps);
|
|
47
|
+
expect(shallow(<EmailSettingsModal {...props} />).snapshot).toMatchSnapshot();
|
|
48
|
+
});
|
|
49
|
+
test('snapshot: emails enabled, show: true', () => {
|
|
50
|
+
hooks.mockReturnValueOnce({
|
|
51
|
+
...hookProps,
|
|
52
|
+
isOptedOut: false,
|
|
53
|
+
});
|
|
54
|
+
expect(shallow(<EmailSettingsModal {...props} />).snapshot).toMatchSnapshot();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { defineMessages } from '@openedx/frontend-base';
|
|
2
|
+
|
|
3
|
+
const messages = defineMessages({
|
|
4
|
+
header: {
|
|
5
|
+
id: 'learner-dash.emailSettings.header',
|
|
6
|
+
description: 'Header for email settings modal',
|
|
7
|
+
defaultMessage: 'Receive course emails?',
|
|
8
|
+
},
|
|
9
|
+
emailsOff: {
|
|
10
|
+
id: 'learner-dash.emailSettings.emailsOff',
|
|
11
|
+
description: 'Toggle text for email settings modal when email is disabled',
|
|
12
|
+
defaultMessage: 'Course emails are off',
|
|
13
|
+
},
|
|
14
|
+
emailsOn: {
|
|
15
|
+
id: 'learner-dash.emailSettings.emailsOn',
|
|
16
|
+
description: 'Toggle text for email settings modal when email is enabled',
|
|
17
|
+
defaultMessage: 'Course emails are on',
|
|
18
|
+
},
|
|
19
|
+
description: {
|
|
20
|
+
id: 'learner-dash.emailSettings.description',
|
|
21
|
+
description: 'Description for email settings modal',
|
|
22
|
+
defaultMessage: 'Course emails include important information about your course from instructors.',
|
|
23
|
+
},
|
|
24
|
+
nevermind: {
|
|
25
|
+
id: 'learner-dash.emailSettings.nevermind',
|
|
26
|
+
description: 'Cancel action for email settings modal',
|
|
27
|
+
defaultMessage: 'Never mind',
|
|
28
|
+
},
|
|
29
|
+
save: {
|
|
30
|
+
id: 'learner-dash.emailSettings.save',
|
|
31
|
+
description: 'Save action for email settings modal',
|
|
32
|
+
defaultMessage: 'Save settings',
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export default messages;
|