diff --git a/src/course-home/data/__factories__/index.js b/src/course-home/data/__factories__/index.js index e8ebf460..e421d00c 100644 --- a/src/course-home/data/__factories__/index.js +++ b/src/course-home/data/__factories__/index.js @@ -2,4 +2,4 @@ import './courseHomeMetadata.factory'; import './datesTabData.factory'; import './outlineTabData.factory'; import './progressTabData.factory'; -import './upgradeCardData.factory'; +import './upgradeNotificationData.factory'; diff --git a/src/course-home/data/__factories__/upgradeCardData.factory.js b/src/course-home/data/__factories__/upgradeNotificationData.factory.js similarity index 93% rename from src/course-home/data/__factories__/upgradeCardData.factory.js rename to src/course-home/data/__factories__/upgradeNotificationData.factory.js index fcabc3d4..fcb75241 100644 --- a/src/course-home/data/__factories__/upgradeCardData.factory.js +++ b/src/course-home/data/__factories__/upgradeNotificationData.factory.js @@ -1,6 +1,6 @@ import { Factory } from 'rosie'; // eslint-disable-line import/no-extraneous-dependencies -Factory.define('upgradeCardData') +Factory.define('upgradeNotificationData') .option('host', 'http://localhost:18000') .option('dateBlocks', []) .option('offer', null) diff --git a/src/course-home/outline-tab/OutlineTab.jsx b/src/course-home/outline-tab/OutlineTab.jsx index a4a2f051..d7d65715 100644 --- a/src/course-home/outline-tab/OutlineTab.jsx +++ b/src/course-home/outline-tab/OutlineTab.jsx @@ -16,7 +16,7 @@ import messages from './messages'; import Section from './Section'; import ShiftDatesAlert from '../suggested-schedule-messaging/ShiftDatesAlert'; import UpdateGoalSelector from './widgets/UpdateGoalSelector'; -import UpgradeCard from '../../generic/upgrade-card/UpgradeCard'; +import UpgradeNotification from '../../generic/upgrade-notification/UpgradeNotification'; import { useAccessExpirationAlertMasquerade } from '../../alerts/access-expiration-alert'; import UpgradeToShiftDatesAlert from '../suggested-schedule-messaging/UpgradeToShiftDatesAlert'; import useCertificateAvailableAlert from './alerts/certificate-status-alert'; @@ -216,7 +216,7 @@ function OutlineTab({ intl }) { { MMP2P.state.isEnabled ? : ( - = responsiveBreakpoints.small.minWidth; + const shouldDisplayNotificationTrigger = useWindowSize().width >= responsiveBreakpoints.small.minWidth; - const [sidebarVisible, setSidebar] = useState(true); - const isSidebarVisible = () => sidebarVisible && setSidebar; - const toggleSidebar = () => { - if (sidebarVisible) { setSidebar(false); } else { setSidebar(true); } + const [notificationTrayVisible, setNotificationTray] = verifiedMode ? useState(true) : useState(false); + const isNotificationTrayVisible = () => notificationTrayVisible && setNotificationTray; + const toggleNotificationTray = () => { + if (notificationTrayVisible) { setNotificationTray(false); } else { setNotificationTray(true); } }; /** [MM-P2P] Experiment */ @@ -102,10 +102,10 @@ function Course({ mmp2p={MMP2P} /> - { isValuePropCookieSet && shouldDisplaySidebarButton ? ( - ) : null} @@ -118,9 +118,9 @@ function Course({ unitNavigationHandler={unitNavigationHandler} nextSequenceHandler={nextSequenceHandler} previousSequenceHandler={previousSequenceHandler} - toggleSidebar={toggleSidebar} - isSidebarVisible={isSidebarVisible} - sidebarVisible={sidebarVisible} + toggleNotificationTray={toggleNotificationTray} + isNotificationTrayVisible={isNotificationTrayVisible} + notificationTrayVisible={notificationTrayVisible} isValuePropCookieSet={isValuePropCookieSet} //* * [MM-P2P] Experiment */ mmp2p={MMP2P} diff --git a/src/courseware/course/Course.test.jsx b/src/courseware/course/Course.test.jsx index 418a633f..5b795e5f 100644 --- a/src/courseware/course/Course.test.jsx +++ b/src/courseware/course/Course.test.jsx @@ -20,7 +20,7 @@ describe('Course', () => { nextSequenceHandler: () => {}, previousSequenceHandler: () => {}, unitNavigationHandler: () => {}, - toggleSidebar: () => {}, + toggleNotificationTray: () => {}, }; beforeAll(async () => { @@ -87,9 +87,9 @@ describe('Course', () => { expect(screen.getByRole('button', { name: 'Learn About Verified Certificates' })).toBeInTheDocument(); }); - it('displays sidebar notification button', async () => { - const toggleSidebar = jest.fn(); - const isSidebarVisible = jest.fn(); + it('displays notification trigger', async () => { + const toggleNotificationTray = jest.fn(); + const isNotificationTrayVisible = jest.fn(); // REV-2297 TODO: remove cookie related code once temporary value prop cookie code is removed. const cookieName = 'value_prop_cookie'; @@ -101,15 +101,15 @@ describe('Course', () => { const testStore = await initializeTestStore({ courseMetadata, excludeFetchSequence: true }, false); const testData = { ...mockData, - toggleSidebar, - isSidebarVisible, + toggleNotificationTray, + isNotificationTrayVisible, }; render(, { store: testStore }); - const sidebarOpenButton = screen.getByRole('button', { name: /Show sidebar notification/i }); + const notificationOpenButton = screen.getByRole('button', { name: /Show notification tray/i }); expect(getSpy).toBeCalledWith(cookieName); - expect(sidebarOpenButton).toBeInTheDocument(); + expect(notificationOpenButton).toBeInTheDocument(); }); it('displays offer and expiration alert', async () => { diff --git a/src/courseware/course/NotificationIcon.jsx b/src/courseware/course/NotificationIcon.jsx index 7f982ed1..da8f0112 100644 --- a/src/courseware/course/NotificationIcon.jsx +++ b/src/courseware/course/NotificationIcon.jsx @@ -11,7 +11,7 @@ import messages from './messages'; function NotificationIcon({ intl, status, notificationColor }) { return (
- + {status === 'active' ? : null} diff --git a/src/courseware/course/Sidebar.jsx b/src/courseware/course/NotificationTray.jsx similarity index 60% rename from src/courseware/course/Sidebar.jsx rename to src/courseware/course/NotificationTray.jsx index 4721e9d0..85b83d19 100644 --- a/src/courseware/course/Sidebar.jsx +++ b/src/courseware/course/NotificationTray.jsx @@ -9,10 +9,10 @@ import { ArrowBackIos, Close } from '@edx/paragon/icons'; import messages from './messages'; import { useModel } from '../../generic/model-store'; import useWindowSize, { responsiveBreakpoints } from '../../generic/tabs/useWindowSize'; -import UpgradeCard from '../../generic/upgrade-card/UpgradeCard'; +import UpgradeNotification from '../../generic/upgrade-notification/UpgradeNotification'; -function Sidebar({ - intl, toggleSidebar, +function NotificationTray({ + intl, toggleNotificationTray, }) { const { courseId, @@ -33,23 +33,23 @@ function Sidebar({ const shouldDisplayFullScreen = useWindowSize().width < responsiveBreakpoints.large.minWidth; return ( -
+
{shouldDisplayFullScreen ? ( -
{ toggleSidebar(); }} onKeyDown={() => { toggleSidebar(); }} role="button" tabIndex="0" alt={intl.formatMessage(messages.responsiveCloseSidebar)}> +
{ toggleNotificationTray(); }} onKeyDown={() => { toggleNotificationTray(); }} role="button" tabIndex="0" alt={intl.formatMessage(messages.responsiveCloseNotificationTray)}> - {intl.formatMessage(messages.responsiveCloseSidebar)} + {intl.formatMessage(messages.responsiveCloseNotificationTray)}
) : null} -
+
{intl.formatMessage(messages.notificationTitle)} {shouldDisplayFullScreen ? null - : { toggleSidebar(); }} onKeyDown={() => { toggleSidebar(); }} role="button" tabIndex="0" alt={intl.formatMessage(messages.closeSidebarButton)} />} + : { toggleNotificationTray(); }} onKeyDown={() => { toggleNotificationTray(); }} role="button" tabIndex="0" alt={intl.formatMessage(messages.closeNotificationTrigger)} />}
-
+
{verifiedMode ? ( - - ) :

{intl.formatMessage(messages.noNotificationsMessage)}

} + ) :

{intl.formatMessage(messages.noNotificationsMessage)}

}
); } -Sidebar.propTypes = { +NotificationTray.propTypes = { intl: intlShape.isRequired, - toggleSidebar: PropTypes.func, + toggleNotificationTray: PropTypes.func, }; -Sidebar.defaultProps = { - toggleSidebar: null, +NotificationTray.defaultProps = { + toggleNotificationTray: null, }; -export default injectIntl(Sidebar); +export default injectIntl(NotificationTray); diff --git a/src/courseware/course/Sidebar.scss b/src/courseware/course/NotificationTray.scss similarity index 89% rename from src/courseware/course/Sidebar.scss rename to src/courseware/course/NotificationTray.scss index 2417e329..b3471a81 100644 --- a/src/courseware/course/Sidebar.scss +++ b/src/courseware/course/NotificationTray.scss @@ -1,4 +1,4 @@ -.sidebar-container { +.notification-tray-container { border: 1px solid $light-400; border-radius: 4px; width: 31rem; @@ -23,7 +23,7 @@ height: 15rem; } -.sidebar-header { +.notification-tray-header { padding: 0.625rem 0; span { @@ -35,7 +35,7 @@ float: right; } -.sidebar-divider { +.notification-tray-divider { width: 100.5%; height: 0.5rem; background: $gray-100; @@ -43,7 +43,7 @@ border-left: 0; } -.sidebar-content { +.notification-tray-content { padding: 1rem; font-size: 0.875rem; } diff --git a/src/courseware/course/Sidebar.test.jsx b/src/courseware/course/NotificationTray.test.jsx similarity index 77% rename from src/courseware/course/Sidebar.test.jsx rename to src/courseware/course/NotificationTray.test.jsx index fdb4473b..acbcf0af 100644 --- a/src/courseware/course/Sidebar.test.jsx +++ b/src/courseware/course/NotificationTray.test.jsx @@ -10,14 +10,14 @@ import { } from '../../setupTest'; import initializeStore from '../../store'; import { appendBrowserTimezoneToUrl, executeThunk } from '../../utils'; -import Sidebar from './Sidebar'; +import NotificationTray from './NotificationTray'; import useWindowSize from '../../generic/tabs/useWindowSize'; initializeMockApp(); jest.mock('../../generic/tabs/useWindowSize'); jest.mock('@edx/frontend-platform/analytics'); -describe('Sidebar', () => { +describe('NotificationTray', () => { let mockData; let axiosMock; let store; @@ -43,45 +43,45 @@ describe('Sidebar', () => { axiosMock = new MockAdapter(getAuthenticatedHttpClient()); axiosMock.onGet(courseMetadataUrl).reply(200, defaultMetadata); mockData = { - toggleSidebar: () => {}, + toggleNotificationTray: () => {}, }; }); - it('renders sidebar', async () => { + it('renders notification tray', async () => { useWindowSize.mockReturnValue({ width: 1200, height: 422 }); - await fetchAndRender(); + await fetchAndRender(); expect(screen.getByText('Notifications')).toBeInTheDocument(); expect(screen.queryByText('Back to course')).not.toBeInTheDocument(); }); it('renders upgrade card', async () => { - await fetchAndRender(); - const upgradeCard = document.querySelector('.upgrade-card'); + await fetchAndRender(); + const UpgradeNotification = document.querySelector('.upgrade-notification'); - expect(upgradeCard).toBeInTheDocument(); + expect(UpgradeNotification).toBeInTheDocument(); expect(screen.getByRole('link', { name: 'Upgrade for $149' })).toBeInTheDocument(); expect(screen.queryByText('You have no new notifications at this time.')).not.toBeInTheDocument(); }); it('renders no notifications message if no verified mode', async () => { setMetadata({ verified_mode: null }); - await fetchAndRender(); + await fetchAndRender(); expect(screen.queryByText('You have no new notifications at this time.')).toBeInTheDocument(); }); - it('renders sidebar with full screen "Back to course" at response width', async () => { + it('renders notification tray with full screen "Back to course" at response width', async () => { useWindowSize.mockReturnValue({ width: 991, height: 422 }); - const toggleSidebar = jest.fn(); + const toggleNotificationTray = jest.fn(); const testData = { ...mockData, - toggleSidebar, + toggleNotificationTray, }; - await fetchAndRender(); + await fetchAndRender(); const responsiveCloseButton = screen.getByRole('button', { name: 'Back to course' }); await waitFor(() => expect(responsiveCloseButton).toBeInTheDocument()); fireEvent.click(responsiveCloseButton); - expect(toggleSidebar).toHaveBeenCalledTimes(1); + expect(toggleNotificationTray).toHaveBeenCalledTimes(1); }); }); diff --git a/src/courseware/course/SidebarNotificationButton.jsx b/src/courseware/course/NotificationTrigger.jsx similarity index 51% rename from src/courseware/course/SidebarNotificationButton.jsx rename to src/courseware/course/NotificationTrigger.jsx index 4ff7ccc0..183a35a1 100644 --- a/src/courseware/course/SidebarNotificationButton.jsx +++ b/src/courseware/course/NotificationTrigger.jsx @@ -6,13 +6,13 @@ import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; import NotificationIcon from './NotificationIcon'; import messages from './messages'; -function SidebarNotificationButton({ intl, toggleSidebar, isSidebarVisible }) { +function NotificationTrigger({ intl, toggleNotificationTray, isNotificationTrayVisible }) { return ( ); }; return sequenceStatus === LOADED && ( -