@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,27 @@
|
|
|
1
|
+
import { shallow } from '@edx/react-unit-test-utils';
|
|
2
|
+
|
|
3
|
+
import { Alert } from '@openedx/paragon';
|
|
4
|
+
|
|
5
|
+
import Banner from './Banner';
|
|
6
|
+
|
|
7
|
+
describe('Banner', () => {
|
|
8
|
+
const props = {
|
|
9
|
+
children: 'Hello, world!',
|
|
10
|
+
};
|
|
11
|
+
describe('snapshot', () => {
|
|
12
|
+
test('renders default banner', () => {
|
|
13
|
+
const wrapper = shallow(<Banner {...props} />);
|
|
14
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
15
|
+
});
|
|
16
|
+
test('renders with variants', () => {
|
|
17
|
+
const wrapper = shallow(<Banner {...props} variant="success" />);
|
|
18
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
19
|
+
|
|
20
|
+
expect(wrapper.instance.findByType(Alert)[0].props.variant).toEqual('success');
|
|
21
|
+
});
|
|
22
|
+
test('renders with custom class', () => {
|
|
23
|
+
const wrapper = shallow(<Banner {...props} className="custom-class" />);
|
|
24
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Banner snapshot renders default banner 1`] = `
|
|
4
|
+
<Alert
|
|
5
|
+
className="mb-0"
|
|
6
|
+
icon={[MockFunction icons.Info]}
|
|
7
|
+
variant="info"
|
|
8
|
+
>
|
|
9
|
+
Hello, world!
|
|
10
|
+
</Alert>
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
exports[`Banner snapshot renders with custom class 1`] = `
|
|
14
|
+
<Alert
|
|
15
|
+
className="custom-class"
|
|
16
|
+
icon={[MockFunction icons.Info]}
|
|
17
|
+
variant="info"
|
|
18
|
+
>
|
|
19
|
+
Hello, world!
|
|
20
|
+
</Alert>
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
exports[`Banner snapshot renders with variants 1`] = `
|
|
24
|
+
<Alert
|
|
25
|
+
className="mb-0"
|
|
26
|
+
icon={[MockFunction icons.Info]}
|
|
27
|
+
variant="success"
|
|
28
|
+
>
|
|
29
|
+
Hello, world!
|
|
30
|
+
</Alert>
|
|
31
|
+
`;
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const appId = 'org.openedx.frontend.app.learnerDashboard';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
@import "@openedx/paragon/scss/core/core";
|
|
2
|
+
|
|
3
|
+
.course-card {
|
|
4
|
+
.card {
|
|
5
|
+
.pgn__card-wrapper-image-cap.vertical {
|
|
6
|
+
display: flex;
|
|
7
|
+
min-height: $card-image-vertical-max-height;
|
|
8
|
+
}
|
|
9
|
+
.pgn__card-image-cap {
|
|
10
|
+
border-bottom-left-radius: 0 !important;
|
|
11
|
+
}
|
|
12
|
+
.overflow-visible {
|
|
13
|
+
overflow: visible;
|
|
14
|
+
}
|
|
15
|
+
.pgn__card-header-content {
|
|
16
|
+
margin-top: 1.5rem;
|
|
17
|
+
}
|
|
18
|
+
.pgn__card-footer {
|
|
19
|
+
flex-wrap: nowrap;
|
|
20
|
+
|
|
21
|
+
&.vertical {
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.pgn__action-row {
|
|
26
|
+
align-self: flex-end;
|
|
27
|
+
white-space: nowrap;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.course-card-verify-ribbon-container {
|
|
32
|
+
width: 100%;
|
|
33
|
+
position: absolute;
|
|
34
|
+
bottom: 0;
|
|
35
|
+
left: 0;
|
|
36
|
+
text-align: center;
|
|
37
|
+
|
|
38
|
+
.badge {
|
|
39
|
+
border-radius: 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
> img {
|
|
43
|
+
width: 40px;
|
|
44
|
+
z-index: 1000;
|
|
45
|
+
position: absolute;
|
|
46
|
+
top: 0;
|
|
47
|
+
right: 0;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.course-card-banners {
|
|
53
|
+
> .alert {
|
|
54
|
+
border-radius: 0;
|
|
55
|
+
box-shadow: none;
|
|
56
|
+
padding: map-get($spacers, 3) map-get($spacers, 4);
|
|
57
|
+
|
|
58
|
+
&:last-of-type {
|
|
59
|
+
border-bottom-left-radius: $alert-border-radius;
|
|
60
|
+
border-bottom-right-radius: $alert-border-radius;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.related-programs-banner {
|
|
65
|
+
.related-programs-list-container {
|
|
66
|
+
list-style: none;
|
|
67
|
+
display: inline;
|
|
68
|
+
|
|
69
|
+
> li {
|
|
70
|
+
line-height: 1rem;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`CourseCard component snapshot: collapsed 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className="mb-4.5 course-card"
|
|
6
|
+
data-testid="CourseCard"
|
|
7
|
+
id="test-card-id"
|
|
8
|
+
>
|
|
9
|
+
<Card
|
|
10
|
+
orientation="vertical"
|
|
11
|
+
>
|
|
12
|
+
<div
|
|
13
|
+
className="d-flex flex-column w-100"
|
|
14
|
+
>
|
|
15
|
+
<div>
|
|
16
|
+
<CourseCardImage
|
|
17
|
+
cardId="test-card-id"
|
|
18
|
+
orientation="horizontal"
|
|
19
|
+
/>
|
|
20
|
+
<Card.Body>
|
|
21
|
+
<Card.Header
|
|
22
|
+
actions={
|
|
23
|
+
<CourseCardMenu
|
|
24
|
+
cardId="test-card-id"
|
|
25
|
+
/>
|
|
26
|
+
}
|
|
27
|
+
title={
|
|
28
|
+
<CourseCardTitle
|
|
29
|
+
cardId="test-card-id"
|
|
30
|
+
/>
|
|
31
|
+
}
|
|
32
|
+
/>
|
|
33
|
+
<Card.Section
|
|
34
|
+
className="pt-0"
|
|
35
|
+
>
|
|
36
|
+
<CourseCardDetails
|
|
37
|
+
cardId="test-card-id"
|
|
38
|
+
/>
|
|
39
|
+
</Card.Section>
|
|
40
|
+
<Card.Footer
|
|
41
|
+
orientation="vertical"
|
|
42
|
+
>
|
|
43
|
+
<CourseCardActions
|
|
44
|
+
cardId="test-card-id"
|
|
45
|
+
/>
|
|
46
|
+
</Card.Footer>
|
|
47
|
+
</Card.Body>
|
|
48
|
+
</div>
|
|
49
|
+
<CourseCardBanners
|
|
50
|
+
cardId="test-card-id"
|
|
51
|
+
/>
|
|
52
|
+
</div>
|
|
53
|
+
</Card>
|
|
54
|
+
</div>
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
exports[`CourseCard component snapshot: not collapsed 1`] = `
|
|
58
|
+
<div
|
|
59
|
+
className="mb-4.5 course-card"
|
|
60
|
+
data-testid="CourseCard"
|
|
61
|
+
id="test-card-id"
|
|
62
|
+
>
|
|
63
|
+
<Card
|
|
64
|
+
orientation="horizontal"
|
|
65
|
+
>
|
|
66
|
+
<div
|
|
67
|
+
className="d-flex flex-column w-100"
|
|
68
|
+
>
|
|
69
|
+
<div
|
|
70
|
+
className="d-flex"
|
|
71
|
+
>
|
|
72
|
+
<CourseCardImage
|
|
73
|
+
cardId="test-card-id"
|
|
74
|
+
orientation="horizontal"
|
|
75
|
+
/>
|
|
76
|
+
<Card.Body>
|
|
77
|
+
<Card.Header
|
|
78
|
+
actions={
|
|
79
|
+
<CourseCardMenu
|
|
80
|
+
cardId="test-card-id"
|
|
81
|
+
/>
|
|
82
|
+
}
|
|
83
|
+
title={
|
|
84
|
+
<CourseCardTitle
|
|
85
|
+
cardId="test-card-id"
|
|
86
|
+
/>
|
|
87
|
+
}
|
|
88
|
+
/>
|
|
89
|
+
<Card.Section
|
|
90
|
+
className="pt-0"
|
|
91
|
+
>
|
|
92
|
+
<CourseCardDetails
|
|
93
|
+
cardId="test-card-id"
|
|
94
|
+
/>
|
|
95
|
+
</Card.Section>
|
|
96
|
+
<Card.Footer
|
|
97
|
+
orientation="horizontal"
|
|
98
|
+
>
|
|
99
|
+
<CourseCardActions
|
|
100
|
+
cardId="test-card-id"
|
|
101
|
+
/>
|
|
102
|
+
</Card.Footer>
|
|
103
|
+
</Card.Body>
|
|
104
|
+
</div>
|
|
105
|
+
<CourseCardBanners
|
|
106
|
+
cardId="test-card-id"
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
</Card>
|
|
110
|
+
</div>
|
|
111
|
+
`;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ActionButton snapshot is collapsed 1`] = `
|
|
4
|
+
<Button
|
|
5
|
+
arbitary="props"
|
|
6
|
+
size="sm"
|
|
7
|
+
/>
|
|
8
|
+
`;
|
|
9
|
+
|
|
10
|
+
exports[`ActionButton snapshot is not collapsed 1`] = `
|
|
11
|
+
<Button
|
|
12
|
+
arbitary="props"
|
|
13
|
+
/>
|
|
14
|
+
`;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useWindowSize, breakpoints } from '@openedx/paragon';
|
|
2
|
+
import useIsCollapsed from './hooks';
|
|
3
|
+
|
|
4
|
+
describe('useIsCollapsed', () => {
|
|
5
|
+
it('returns true only when it is between medium and small', () => {
|
|
6
|
+
// make sure all three breakpoints gap is large enough for test
|
|
7
|
+
expect(
|
|
8
|
+
(breakpoints.large.maxWidth - 1)
|
|
9
|
+
> (breakpoints.medium.maxWidth - 1)
|
|
10
|
+
&& (breakpoints.medium.maxWidth - 1)
|
|
11
|
+
> (breakpoints.small.maxWidth - 1),
|
|
12
|
+
).toBe(true);
|
|
13
|
+
|
|
14
|
+
useWindowSize.mockReturnValue({ width: breakpoints.large.maxWidth - 1 });
|
|
15
|
+
expect(useIsCollapsed()).toEqual(false);
|
|
16
|
+
useWindowSize.mockReturnValue({ width: breakpoints.medium.maxWidth - 1 });
|
|
17
|
+
expect(useIsCollapsed()).toEqual(true);
|
|
18
|
+
useWindowSize.mockReturnValue({ width: breakpoints.small.maxWidth - 1 });
|
|
19
|
+
expect(useIsCollapsed()).toEqual(false);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button } from '@openedx/paragon';
|
|
3
|
+
|
|
4
|
+
import useIsCollapsed from './hooks';
|
|
5
|
+
|
|
6
|
+
export const ActionButton = (props) => {
|
|
7
|
+
const isSmall = useIsCollapsed();
|
|
8
|
+
return (
|
|
9
|
+
<Button
|
|
10
|
+
{...props}
|
|
11
|
+
{...isSmall && { size: 'sm' }}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default ActionButton;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { shallow } from '@edx/react-unit-test-utils';
|
|
2
|
+
|
|
3
|
+
import ActionButton from '.';
|
|
4
|
+
|
|
5
|
+
import useIsCollapsed from './hooks';
|
|
6
|
+
|
|
7
|
+
jest.mock('./hooks', () => jest.fn());
|
|
8
|
+
|
|
9
|
+
describe('ActionButton', () => {
|
|
10
|
+
const props = {
|
|
11
|
+
arbitary: 'props',
|
|
12
|
+
};
|
|
13
|
+
describe('snapshot', () => {
|
|
14
|
+
test('is collapsed', () => {
|
|
15
|
+
useIsCollapsed.mockReturnValueOnce(true);
|
|
16
|
+
const wrapper = shallow(<ActionButton {...props} />);
|
|
17
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
test('is not collapsed', () => {
|
|
20
|
+
useIsCollapsed.mockReturnValueOnce(false);
|
|
21
|
+
const wrapper = shallow(<ActionButton {...props} />);
|
|
22
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { useIntl } from '@openedx/frontend-base';
|
|
5
|
+
|
|
6
|
+
import track from '../../../../tracking';
|
|
7
|
+
import { reduxHooks } from '../../../../hooks';
|
|
8
|
+
|
|
9
|
+
import useActionDisabledState from '../hooks';
|
|
10
|
+
import ActionButton from './ActionButton';
|
|
11
|
+
import messages from './messages';
|
|
12
|
+
|
|
13
|
+
export const BeginCourseButton = ({ cardId }) => {
|
|
14
|
+
const { formatMessage } = useIntl();
|
|
15
|
+
const { homeUrl } = reduxHooks.useCardCourseRunData(cardId);
|
|
16
|
+
const execEdTrackingParam = reduxHooks.useCardExecEdTrackingParam(cardId);
|
|
17
|
+
const { disableBeginCourse } = useActionDisabledState(cardId);
|
|
18
|
+
|
|
19
|
+
const handleClick = reduxHooks.useTrackCourseEvent(
|
|
20
|
+
track.course.enterCourseClicked,
|
|
21
|
+
cardId,
|
|
22
|
+
homeUrl + execEdTrackingParam,
|
|
23
|
+
);
|
|
24
|
+
return (
|
|
25
|
+
<ActionButton
|
|
26
|
+
disabled={disableBeginCourse}
|
|
27
|
+
as="a"
|
|
28
|
+
href="#"
|
|
29
|
+
onClick={handleClick}
|
|
30
|
+
>
|
|
31
|
+
{formatMessage(messages.beginCourse)}
|
|
32
|
+
</ActionButton>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
BeginCourseButton.propTypes = {
|
|
36
|
+
cardId: PropTypes.string.isRequired,
|
|
37
|
+
};
|
|
38
|
+
export default BeginCourseButton;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { shallow } from '@edx/react-unit-test-utils';
|
|
2
|
+
|
|
3
|
+
import { reduxHooks } from 'hooks';
|
|
4
|
+
import track from 'tracking';
|
|
5
|
+
import useActionDisabledState from '../hooks';
|
|
6
|
+
import BeginCourseButton from './BeginCourseButton';
|
|
7
|
+
|
|
8
|
+
jest.mock('tracking', () => ({
|
|
9
|
+
course: {
|
|
10
|
+
enterCourseClicked: jest.fn().mockName('segment.enterCourseClicked'),
|
|
11
|
+
},
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
jest.mock('hooks', () => ({
|
|
15
|
+
reduxHooks: {
|
|
16
|
+
useCardCourseRunData: jest.fn(),
|
|
17
|
+
useCardExecEdTrackingParam: jest.fn(),
|
|
18
|
+
useTrackCourseEvent: jest.fn(),
|
|
19
|
+
},
|
|
20
|
+
}));
|
|
21
|
+
jest.mock('../hooks', () => jest.fn(() => ({ disableBeginCourse: false })));
|
|
22
|
+
jest.mock('./ActionButton', () => 'ActionButton');
|
|
23
|
+
|
|
24
|
+
let wrapper;
|
|
25
|
+
const homeUrl = 'home-url';
|
|
26
|
+
reduxHooks.useCardCourseRunData.mockReturnValue({ homeUrl });
|
|
27
|
+
const execEdPath = (cardId) => `exec-ed-tracking-path=${cardId}`;
|
|
28
|
+
reduxHooks.useCardExecEdTrackingParam.mockImplementation(execEdPath);
|
|
29
|
+
reduxHooks.useTrackCourseEvent.mockImplementation(
|
|
30
|
+
(eventName, cardId, url) => ({ trackCourseEvent: { eventName, cardId, url } }),
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
describe('BeginCourseButton', () => {
|
|
34
|
+
const props = {
|
|
35
|
+
cardId: 'cardId',
|
|
36
|
+
};
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
jest.clearAllMocks();
|
|
39
|
+
});
|
|
40
|
+
describe('behavior', () => {
|
|
41
|
+
it('initializes course run data with cardId', () => {
|
|
42
|
+
wrapper = shallow(<BeginCourseButton {...props} />);
|
|
43
|
+
expect(reduxHooks.useCardCourseRunData).toHaveBeenCalledWith(props.cardId);
|
|
44
|
+
});
|
|
45
|
+
it('loads exec education path param', () => {
|
|
46
|
+
wrapper = shallow(<BeginCourseButton {...props} />);
|
|
47
|
+
expect(reduxHooks.useCardExecEdTrackingParam).toHaveBeenCalledWith(props.cardId);
|
|
48
|
+
});
|
|
49
|
+
it('loads disabled states for begin action from action hooks', () => {
|
|
50
|
+
wrapper = shallow(<BeginCourseButton {...props} />);
|
|
51
|
+
expect(useActionDisabledState).toHaveBeenCalledWith(props.cardId);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
describe('snapshot', () => {
|
|
55
|
+
describe('disabled', () => {
|
|
56
|
+
beforeEach(() => {
|
|
57
|
+
useActionDisabledState.mockReturnValueOnce({ disableBeginCourse: true });
|
|
58
|
+
wrapper = shallow(<BeginCourseButton {...props} />);
|
|
59
|
+
});
|
|
60
|
+
test('snapshot', () => {
|
|
61
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
62
|
+
});
|
|
63
|
+
it('should be disabled', () => {
|
|
64
|
+
expect(wrapper.instance.props.disabled).toEqual(true);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
describe('enabled', () => {
|
|
68
|
+
beforeEach(() => {
|
|
69
|
+
wrapper = shallow(<BeginCourseButton {...props} />);
|
|
70
|
+
});
|
|
71
|
+
test('snapshot', () => {
|
|
72
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
73
|
+
});
|
|
74
|
+
it('should be enabled', () => {
|
|
75
|
+
expect(wrapper.instance.props.disabled).toEqual(false);
|
|
76
|
+
});
|
|
77
|
+
it('should track enter course clicked event on click, with exec ed param', () => {
|
|
78
|
+
expect(wrapper.instance.props.onClick).toEqual(reduxHooks.useTrackCourseEvent(
|
|
79
|
+
track.course.enterCourseClicked,
|
|
80
|
+
props.cardId,
|
|
81
|
+
homeUrl + execEdPath(props.cardId),
|
|
82
|
+
));
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { useIntl } from '@openedx/frontend-base';
|
|
5
|
+
|
|
6
|
+
import track from '../../../../tracking';
|
|
7
|
+
import { reduxHooks } from '../../../../hooks';
|
|
8
|
+
|
|
9
|
+
import useActionDisabledState from '../hooks';
|
|
10
|
+
import ActionButton from './ActionButton';
|
|
11
|
+
import messages from './messages';
|
|
12
|
+
|
|
13
|
+
export const ResumeButton = ({ cardId }) => {
|
|
14
|
+
const { formatMessage } = useIntl();
|
|
15
|
+
const { resumeUrl } = reduxHooks.useCardCourseRunData(cardId);
|
|
16
|
+
const execEdTrackingParam = reduxHooks.useCardExecEdTrackingParam(cardId);
|
|
17
|
+
const { disableResumeCourse } = useActionDisabledState(cardId);
|
|
18
|
+
|
|
19
|
+
const handleClick = reduxHooks.useTrackCourseEvent(
|
|
20
|
+
track.course.enterCourseClicked,
|
|
21
|
+
cardId,
|
|
22
|
+
resumeUrl + execEdTrackingParam,
|
|
23
|
+
);
|
|
24
|
+
return (
|
|
25
|
+
<ActionButton
|
|
26
|
+
disabled={disableResumeCourse}
|
|
27
|
+
as="a"
|
|
28
|
+
href="#"
|
|
29
|
+
onClick={handleClick}
|
|
30
|
+
>
|
|
31
|
+
{formatMessage(messages.resume)}
|
|
32
|
+
</ActionButton>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
ResumeButton.propTypes = {
|
|
36
|
+
cardId: PropTypes.string.isRequired,
|
|
37
|
+
};
|
|
38
|
+
export default ResumeButton;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { shallow } from '@edx/react-unit-test-utils';
|
|
2
|
+
|
|
3
|
+
import { reduxHooks } from 'hooks';
|
|
4
|
+
import track from 'tracking';
|
|
5
|
+
import useActionDisabledState from '../hooks';
|
|
6
|
+
import ResumeButton from './ResumeButton';
|
|
7
|
+
|
|
8
|
+
jest.mock('tracking', () => ({
|
|
9
|
+
course: {
|
|
10
|
+
enterCourseClicked: jest.fn().mockName('segment.enterCourseClicked'),
|
|
11
|
+
},
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
jest.mock('hooks', () => ({
|
|
15
|
+
reduxHooks: {
|
|
16
|
+
useCardCourseRunData: jest.fn(),
|
|
17
|
+
useCardExecEdTrackingParam: jest.fn(),
|
|
18
|
+
useTrackCourseEvent: jest.fn(),
|
|
19
|
+
},
|
|
20
|
+
}));
|
|
21
|
+
jest.mock('../hooks', () => jest.fn(() => ({ disableResumeCourse: false })));
|
|
22
|
+
jest.mock('./ActionButton', () => 'ActionButton');
|
|
23
|
+
|
|
24
|
+
const resumeUrl = 'resume-url';
|
|
25
|
+
reduxHooks.useCardCourseRunData.mockReturnValue({ resumeUrl });
|
|
26
|
+
const execEdPath = (cardId) => `exec-ed-tracking-path=${cardId}`;
|
|
27
|
+
reduxHooks.useCardExecEdTrackingParam.mockImplementation(execEdPath);
|
|
28
|
+
reduxHooks.useTrackCourseEvent.mockImplementation(
|
|
29
|
+
(eventName, cardId, url) => ({ trackCourseEvent: { eventName, cardId, url } }),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
let wrapper;
|
|
33
|
+
|
|
34
|
+
describe('ResumeButton', () => {
|
|
35
|
+
const props = {
|
|
36
|
+
cardId: 'cardId',
|
|
37
|
+
};
|
|
38
|
+
describe('behavior', () => {
|
|
39
|
+
it('initializes course run data with cardId', () => {
|
|
40
|
+
wrapper = shallow(<ResumeButton {...props} />);
|
|
41
|
+
expect(reduxHooks.useCardCourseRunData).toHaveBeenCalledWith(props.cardId);
|
|
42
|
+
});
|
|
43
|
+
it('loads exec education path param', () => {
|
|
44
|
+
wrapper = shallow(<ResumeButton {...props} />);
|
|
45
|
+
expect(reduxHooks.useCardExecEdTrackingParam).toHaveBeenCalledWith(props.cardId);
|
|
46
|
+
});
|
|
47
|
+
it('loads disabled states for resume action from action hooks', () => {
|
|
48
|
+
wrapper = shallow(<ResumeButton {...props} />);
|
|
49
|
+
expect(useActionDisabledState).toHaveBeenCalledWith(props.cardId);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
describe('snapshot', () => {
|
|
53
|
+
describe('disabled', () => {
|
|
54
|
+
beforeEach(() => {
|
|
55
|
+
useActionDisabledState.mockReturnValueOnce({ disableResumeCourse: true });
|
|
56
|
+
wrapper = shallow(<ResumeButton {...props} />);
|
|
57
|
+
});
|
|
58
|
+
test('snapshot', () => {
|
|
59
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
60
|
+
});
|
|
61
|
+
it('should be disabled', () => {
|
|
62
|
+
expect(wrapper.instance.props.disabled).toEqual(true);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
describe('enabled', () => {
|
|
66
|
+
beforeEach(() => {
|
|
67
|
+
wrapper = shallow(<ResumeButton {...props} />);
|
|
68
|
+
});
|
|
69
|
+
test('snapshot', () => {
|
|
70
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
71
|
+
});
|
|
72
|
+
it('should be enabled', () => {
|
|
73
|
+
expect(wrapper.instance.props.disabled).toEqual(false);
|
|
74
|
+
});
|
|
75
|
+
it('should track enter course clicked event on click, with exec ed param', () => {
|
|
76
|
+
expect(wrapper.instance.props.onClick).toEqual(reduxHooks.useTrackCourseEvent(
|
|
77
|
+
track.course.enterCourseClicked,
|
|
78
|
+
props.cardId,
|
|
79
|
+
resumeUrl + execEdPath(props.cardId),
|
|
80
|
+
));
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { useIntl } from '@openedx/frontend-base';
|
|
5
|
+
|
|
6
|
+
import { reduxHooks } from '../../../../hooks';
|
|
7
|
+
|
|
8
|
+
import useActionDisabledState from '../hooks';
|
|
9
|
+
import ActionButton from './ActionButton';
|
|
10
|
+
import messages from './messages';
|
|
11
|
+
|
|
12
|
+
export const SelectSessionButton = ({ cardId }) => {
|
|
13
|
+
const { formatMessage } = useIntl();
|
|
14
|
+
const { disableSelectSession } = useActionDisabledState(cardId);
|
|
15
|
+
const openSessionModal = reduxHooks.useUpdateSelectSessionModalCallback(cardId);
|
|
16
|
+
return (
|
|
17
|
+
<ActionButton
|
|
18
|
+
disabled={disableSelectSession}
|
|
19
|
+
onClick={openSessionModal}
|
|
20
|
+
>
|
|
21
|
+
{formatMessage(messages.selectSession)}
|
|
22
|
+
</ActionButton>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
SelectSessionButton.propTypes = {
|
|
26
|
+
cardId: PropTypes.string.isRequired,
|
|
27
|
+
};
|
|
28
|
+
export default SelectSessionButton;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { shallow } from '@edx/react-unit-test-utils';
|
|
2
|
+
|
|
3
|
+
import { reduxHooks } from 'hooks';
|
|
4
|
+
import useActionDisabledState from '../hooks';
|
|
5
|
+
|
|
6
|
+
import SelectSessionButton from './SelectSessionButton';
|
|
7
|
+
|
|
8
|
+
jest.mock('hooks', () => ({
|
|
9
|
+
reduxHooks: {
|
|
10
|
+
useUpdateSelectSessionModalCallback: () => jest.fn().mockName('mockOpenSessionModal'),
|
|
11
|
+
},
|
|
12
|
+
}));
|
|
13
|
+
jest.mock('../hooks', () => jest.fn(() => ({ disableSelectSession: false })));
|
|
14
|
+
jest.mock('./ActionButton', () => 'ActionButton');
|
|
15
|
+
|
|
16
|
+
let wrapper;
|
|
17
|
+
|
|
18
|
+
describe('SelectSessionButton', () => {
|
|
19
|
+
const props = { cardId: 'cardId' };
|
|
20
|
+
it('default render', () => {
|
|
21
|
+
wrapper = shallow(<SelectSessionButton {...props} />);
|
|
22
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
23
|
+
expect(wrapper.instance.props.disabled).toEqual(false);
|
|
24
|
+
expect(wrapper.instance.props.onClick.getMockName()).toEqual(
|
|
25
|
+
reduxHooks.useUpdateSelectSessionModalCallback().getMockName(),
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
test('disabled states', () => {
|
|
29
|
+
useActionDisabledState.mockReturnValueOnce({ disableSelectSession: true });
|
|
30
|
+
wrapper = shallow(<SelectSessionButton {...props} />);
|
|
31
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
32
|
+
expect(wrapper.instance.props.disabled).toEqual(true);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { useIntl } from '@openedx/frontend-base';
|
|
5
|
+
|
|
6
|
+
import track from '../../../../tracking';
|
|
7
|
+
import { reduxHooks } from '../../../../hooks';
|
|
8
|
+
|
|
9
|
+
import useActionDisabledState from '../hooks';
|
|
10
|
+
import ActionButton from './ActionButton';
|
|
11
|
+
import messages from './messages';
|
|
12
|
+
|
|
13
|
+
export const ViewCourseButton = ({ cardId }) => {
|
|
14
|
+
const { formatMessage } = useIntl();
|
|
15
|
+
const { homeUrl } = reduxHooks.useCardCourseRunData(cardId);
|
|
16
|
+
const { disableViewCourse } = useActionDisabledState(cardId);
|
|
17
|
+
|
|
18
|
+
const handleClick = reduxHooks.useTrackCourseEvent(
|
|
19
|
+
track.course.enterCourseClicked,
|
|
20
|
+
cardId,
|
|
21
|
+
homeUrl,
|
|
22
|
+
);
|
|
23
|
+
return (
|
|
24
|
+
<ActionButton
|
|
25
|
+
disabled={disableViewCourse}
|
|
26
|
+
as="a"
|
|
27
|
+
href="#"
|
|
28
|
+
onClick={handleClick}
|
|
29
|
+
>
|
|
30
|
+
{formatMessage(messages.viewCourse)}
|
|
31
|
+
</ActionButton>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
ViewCourseButton.propTypes = {
|
|
35
|
+
cardId: PropTypes.string.isRequired,
|
|
36
|
+
};
|
|
37
|
+
export default ViewCourseButton;
|