Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added implementation for new sidebar #1260

Merged
merged 11 commits into from
Jan 8, 2024
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ TWITTER_HASHTAG=''
TWITTER_URL=''
USER_INFO_COOKIE_NAME=''
OPTIMIZELY_FULL_STACK_SDK_KEY=''
ENABLE_SIDEBAR_NEW_VIEW='false'
sundasnoreen12 marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ SESSION_COOKIE_DOMAIN='localhost'
CHAT_RESPONSE_URL='http://localhost:18000/api/learning_assistant/v1/course_id'
PRIVACY_POLICY_URL='http://localhost:18000/privacy'
OPTIMIZELY_FULL_STACK_SDK_KEY=''
ENABLE_SIDEBAR_NEW_VIEW='false'
sundasnoreen12 marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 8 additions & 3 deletions src/courseware/course/Course.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import ContentTools from './content-tools';
import CourseBreadcrumbs from './CourseBreadcrumbs';
import SidebarProvider from './sidebar/SidebarContextProvider';
import SidebarTriggers from './sidebar/SidebarTriggers';
import NewSidebarProvider from './new-sidebar/SidebarContextProvider';
import NewSidebarTriggers from './new-sidebar/SidebarTriggers';

import { useModel } from '../../generic/model-store';

Expand All @@ -34,6 +36,7 @@ const Course = ({
} = useModel('courseHomeMeta', courseId);
const sequence = useModel('sequences', sequenceId);
const section = useModel('sections', sequence ? sequence.sectionId : null);
const showSidebarNewView = getConfig().ENABLE_SIDEBAR_NEW_VIEW;
sundasnoreen12 marked this conversation as resolved.
Show resolved Hide resolved

const pageTitleBreadCrumbs = [
sequence,
Expand Down Expand Up @@ -64,8 +67,10 @@ const Course = ({
));
}, [sequenceId]);

const SidebarProviderComponent = showSidebarNewView === 'true' ? NewSidebarProvider : SidebarProvider;

return (
<SidebarProvider courseId={courseId} unitId={unitId}>
<SidebarProviderComponent courseId={courseId} unitId={unitId}>
<Helmet>
<title>{`${pageTitleBreadCrumbs.join(' | ')} | ${getConfig().SITE_NAME}`}</title>
</Helmet>
Expand All @@ -86,7 +91,7 @@ const Course = ({
courseId={courseId}
contentToolsEnabled={course.showCalculator || course.notes.enabled}
/>
<SidebarTriggers />
{ showSidebarNewView === 'true' ? <NewSidebarTriggers /> : <SidebarTriggers /> }
</>
)}
</div>
Expand All @@ -112,7 +117,7 @@ const Course = ({
onClose={() => setWeeklyGoalCelebrationOpen(false)}
/>
<ContentTools course={course} />
</SidebarProvider>
</SidebarProviderComponent>
);
};

Expand Down
41 changes: 41 additions & 0 deletions src/courseware/course/new-sidebar/NewSidebarIcon.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { Icon } from '@edx/paragon';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React, { useContext } from 'react';
import { RightSidebarFilled, RightSidebarOutlined } from './icons/index';
sundasnoreen12 marked this conversation as resolved.
Show resolved Hide resolved
import SidebarContext from './SidebarContext';
import messages from '../messages';

const SidebarIcon = ({
intl,
status,
sidebarColor,
}) => {
const { currentSidebar } = useContext(SidebarContext);
return (

Check warning on line 16 in src/courseware/course/new-sidebar/NewSidebarIcon.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/NewSidebarIcon.jsx#L14-L16

Added lines #L14 - L16 were not covered by tests
<>
<Icon src={currentSidebar ? RightSidebarFilled : RightSidebarOutlined} className="m-0 m-auto" alt={intl.formatMessage(messages.openNotificationTrigger)} />
sundasnoreen12 marked this conversation as resolved.
Show resolved Hide resolved
{status === 'active'
? (
<span

Check warning on line 21 in src/courseware/course/new-sidebar/NewSidebarIcon.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/NewSidebarIcon.jsx#L21

Added line #L21 was not covered by tests
className={classNames(sidebarColor, 'rounded-circle p-1 position-absolute')}
data-testid="notification-dot"
style={{
top: '0.3rem',
right: '0.55rem',
}}
/>
)
: null}

Check warning on line 30 in src/courseware/course/new-sidebar/NewSidebarIcon.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/NewSidebarIcon.jsx#L30

Added line #L30 was not covered by tests
</>
sundasnoreen12 marked this conversation as resolved.
Show resolved Hide resolved
);
};

SidebarIcon.propTypes = {
intl: intlShape.isRequired,
status: PropTypes.string.isRequired,
sidebarColor: PropTypes.string.isRequired,
};

export default injectIntl(SidebarIcon);
sundasnoreen12 marked this conversation as resolved.
Show resolved Hide resolved
91 changes: 91 additions & 0 deletions src/courseware/course/new-sidebar/NewSidebarTrigger.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import PropTypes from 'prop-types';
import React, { useContext, useEffect, useMemo } from 'react';
import { useDispatch } from 'react-redux';
import { getConfig } from '@edx/frontend-platform';
import { getLocalStorage, setLocalStorage } from '../../../data/localStorage';
import { getSessionStorage, setSessionStorage } from '../../../data/sessionStorage';
import messages from './messages';
import SidebarTriggerBase from './common/TriggerBase';
import SidebarContext from './SidebarContext';
import { useModel } from '../../../generic/model-store';
import { getCourseDiscussionTopics } from '../../data/thunks';
import NewSidebarIcon from './NewSidebarIcon';

const NewSideBarTrigger = ({
intl,
onClick,
}) => {

Check warning on line 18 in src/courseware/course/new-sidebar/NewSidebarTrigger.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/NewSidebarTrigger.jsx#L18

Added line #L18 was not covered by tests
const {
courseId,
notificationStatus,
setNotificationStatus,
upgradeNotificationCurrentState,
isNotificationbarAvailable,
isDiscussionbarAvailable,
} = useContext(SidebarContext);

Check warning on line 26 in src/courseware/course/new-sidebar/NewSidebarTrigger.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/NewSidebarTrigger.jsx#L26

Added line #L26 was not covered by tests

const dispatch = useDispatch();
const { tabs } = useModel('courseHomeMeta', courseId);
const baseUrl = getConfig().DISCUSSIONS_MFE_BASE_URL;
const edxProvider = useMemo(
() => tabs?.find(tab => tab.slug === 'discussion'),

Check warning on line 32 in src/courseware/course/new-sidebar/NewSidebarTrigger.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/NewSidebarTrigger.jsx#L28-L32

Added lines #L28 - L32 were not covered by tests
[tabs],
);

useEffect(() => {

Check warning on line 36 in src/courseware/course/new-sidebar/NewSidebarTrigger.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/NewSidebarTrigger.jsx#L36

Added line #L36 was not covered by tests
if (baseUrl && edxProvider) {
dispatch(getCourseDiscussionTopics(courseId));

Check warning on line 38 in src/courseware/course/new-sidebar/NewSidebarTrigger.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/NewSidebarTrigger.jsx#L38

Added line #L38 was not covered by tests
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [courseId, baseUrl, edxProvider]);

/* Re-show a red dot beside the notification trigger for each of the 7 UpgradeNotification stages
The upgradeNotificationCurrentState prop will be available after UpgradeNotification mounts. Once available,
compare with the last state they've seen, and if it's different then set dot back to red */
function updateUpgradeNotificationLastSeen() {

Check warning on line 46 in src/courseware/course/new-sidebar/NewSidebarTrigger.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/NewSidebarTrigger.jsx#L46

Added line #L46 was not covered by tests
if (upgradeNotificationCurrentState) {
if (getLocalStorage(`upgradeNotificationLastSeen.${courseId}`) !== upgradeNotificationCurrentState) {
setNotificationStatus('active');
setLocalStorage(`notificationStatus.${courseId}`, 'active');
setLocalStorage(`upgradeNotificationLastSeen.${courseId}`, upgradeNotificationCurrentState);

Check warning on line 51 in src/courseware/course/new-sidebar/NewSidebarTrigger.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/NewSidebarTrigger.jsx#L49-L51

Added lines #L49 - L51 were not covered by tests
}
}
}

if (!getLocalStorage(`notificationStatus.${courseId}`)) {
setLocalStorage(`notificationStatus.${courseId}`, 'active'); // Show red dot on notificationTrigger until seen

Check warning on line 57 in src/courseware/course/new-sidebar/NewSidebarTrigger.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/NewSidebarTrigger.jsx#L57

Added line #L57 was not covered by tests
}

if (!getLocalStorage(`upgradeNotificationCurrentState.${courseId}`)) {
setLocalStorage(`upgradeNotificationCurrentState.${courseId}`, 'initialize');

Check warning on line 61 in src/courseware/course/new-sidebar/NewSidebarTrigger.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/NewSidebarTrigger.jsx#L61

Added line #L61 was not covered by tests
}

useEffect(() => {
updateUpgradeNotificationLastSeen();

Check warning on line 65 in src/courseware/course/new-sidebar/NewSidebarTrigger.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/NewSidebarTrigger.jsx#L64-L65

Added lines #L64 - L65 were not covered by tests
});

const handleClick = () => {

Check warning on line 68 in src/courseware/course/new-sidebar/NewSidebarTrigger.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/NewSidebarTrigger.jsx#L68

Added line #L68 was not covered by tests
if (getSessionStorage(`notificationTrayStatus.${courseId}`) === 'open') {
setSessionStorage(`notificationTrayStatus.${courseId}`, 'closed');
} else {
setSessionStorage(`notificationTrayStatus.${courseId}`, 'open');

Check warning on line 72 in src/courseware/course/new-sidebar/NewSidebarTrigger.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/NewSidebarTrigger.jsx#L70-L72

Added lines #L70 - L72 were not covered by tests
}
onClick();

Check warning on line 74 in src/courseware/course/new-sidebar/NewSidebarTrigger.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/NewSidebarTrigger.jsx#L74

Added line #L74 was not covered by tests
};

if (!isDiscussionbarAvailable && !isNotificationbarAvailable) { return null; }

return (

Check warning on line 79 in src/courseware/course/new-sidebar/NewSidebarTrigger.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/NewSidebarTrigger.jsx#L79

Added line #L79 was not covered by tests
<SidebarTriggerBase onClick={handleClick} ariaLabel={intl.formatMessage(messages.openSidebarTrigger)}>
<NewSidebarIcon status={notificationStatus} sidebarColor="bg-danger-500" />
</SidebarTriggerBase>
);
};

NewSideBarTrigger.propTypes = {
intl: intlShape.isRequired,
onClick: PropTypes.func.isRequired,
};

export default injectIntl(NewSideBarTrigger);
46 changes: 46 additions & 0 deletions src/courseware/course/new-sidebar/Sidebar.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React, { useContext } from 'react';
import { ArrowBackIos } from '@edx/paragon/icons';
import { useIntl } from '@edx/frontend-platform/i18n';
import { Icon } from '@edx/paragon';
import classNames from 'classnames';
import NotificationTray from './sidebars/notifications/NotificationTray';
import DiscussionsSidebar from './sidebars/discussions/DiscussionsSidebar';
import SidebarContext from './SidebarContext';
import messages from './messages';

const Sidebar = () => {
const intl = useIntl();

Check warning on line 12 in src/courseware/course/new-sidebar/Sidebar.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/Sidebar.jsx#L12

Added line #L12 was not covered by tests

const {
toggleSidebar,
shouldDisplayFullScreen,
currentSidebar,
} = useContext(SidebarContext);

Check warning on line 18 in src/courseware/course/new-sidebar/Sidebar.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/Sidebar.jsx#L18

Added line #L18 was not covered by tests

if (currentSidebar === null) { return null; }

return (

Check warning on line 22 in src/courseware/course/new-sidebar/Sidebar.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/Sidebar.jsx#L22

Added line #L22 was not covered by tests
<div className={classNames('vh-100 d-flex flex-column', { 'bg-white fixed-top': shouldDisplayFullScreen })}>
{shouldDisplayFullScreen
&& (
<div

Check warning on line 26 in src/courseware/course/new-sidebar/Sidebar.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/Sidebar.jsx#L26

Added line #L26 was not covered by tests
className="pt-2 pb-2.5 border-bottom border-light-400 d-flex align-items-center ml-2"
onClick={() => toggleSidebar(null)}
onKeyDown={() => toggleSidebar(null)}

Check warning on line 29 in src/courseware/course/new-sidebar/Sidebar.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/Sidebar.jsx#L28-L29

Added lines #L28 - L29 were not covered by tests
role="button"
tabIndex="0"
alt={intl.formatMessage(messages.responsiveCloseSidebarTray)}
>
<Icon src={ArrowBackIos} />
<span className="font-weight-bold m-2 d-inline-block">
{intl.formatMessage(messages.responsiveCloseSidebarTray)}
</span>
</div>
)}
<NotificationTray />
<DiscussionsSidebar />
</div>
);
};

export default Sidebar;
5 changes: 5 additions & 0 deletions src/courseware/course/new-sidebar/SidebarContext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react';

const SidebarContext = React.createContext({});

export default SidebarContext;
121 changes: 121 additions & 0 deletions src/courseware/course/new-sidebar/SidebarContextProvider.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import { breakpoints, useWindowSize } from '@edx/paragon';
import PropTypes from 'prop-types';
import React, {
useEffect, useState, useMemo, useCallback,
} from 'react';
import isEmpty from 'lodash/isEmpty';
import { SidebarID, Notifications, Discussions } from './constants';
import { getLocalStorage, setLocalStorage } from '../../../data/localStorage';
import SidebarContext from './SidebarContext';
import { useModel } from '../../../generic/model-store';

const SidebarProvider = ({
courseId,
unitId,
children,
}) => {
const shouldDisplayFullScreen = useWindowSize().width < breakpoints.large.minWidth;
const shouldDisplaySidebarOpen = useWindowSize().width > breakpoints.medium.minWidth;
const query = new URLSearchParams(window.location.search);

Check warning on line 19 in src/courseware/course/new-sidebar/SidebarContextProvider.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/SidebarContextProvider.jsx#L16-L19

Added lines #L16 - L19 were not covered by tests
const initialSidebar = (shouldDisplaySidebarOpen || query.get('sidebar') === 'true') ? SidebarID : null;
const [currentSidebar, setCurrentSidebar] = useState(initialSidebar);
const [hideDiscussionbar, setHideDiscussionbar] = useState(false);
const [isDiscussionbarAvailable, setIsDiscussionbarAvailable] = useState(true);
const [hideNotificationbar, setHideNotificationbar] = useState(false);
const [isNotificationbarAvailable, setIsNotificationbarAvailable] = useState(true);

Check warning on line 25 in src/courseware/course/new-sidebar/SidebarContextProvider.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/SidebarContextProvider.jsx#L21-L25

Added lines #L21 - L25 were not covered by tests

const [notificationStatus, setNotificationStatus] = useState(getLocalStorage(`notificationStatus.${courseId}`));
const [upgradeNotificationCurrentState, setUpgradeNotificationCurrentState] = useState(getLocalStorage(`upgradeNotificationCurrentState.${courseId}`));
const topic = useModel('discussionTopics', unitId);
const { verifiedMode } = useModel('courseHomeMeta', courseId);

Check warning on line 30 in src/courseware/course/new-sidebar/SidebarContextProvider.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/SidebarContextProvider.jsx#L27-L30

Added lines #L27 - L30 were not covered by tests

useEffect(() => {

Check warning on line 32 in src/courseware/course/new-sidebar/SidebarContextProvider.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/SidebarContextProvider.jsx#L32

Added line #L32 was not covered by tests
if (!topic?.id || !topic?.enabledInContext) {
setIsDiscussionbarAvailable(false);
setHideDiscussionbar(true);
} else {
setIsDiscussionbarAvailable(true);
setHideDiscussionbar(false);

Check warning on line 38 in src/courseware/course/new-sidebar/SidebarContextProvider.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/SidebarContextProvider.jsx#L34-L38

Added lines #L34 - L38 were not covered by tests
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [topic]);

useEffect(() => {

Check warning on line 43 in src/courseware/course/new-sidebar/SidebarContextProvider.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/SidebarContextProvider.jsx#L43

Added line #L43 was not covered by tests
if (isEmpty(verifiedMode)) {
setIsNotificationbarAvailable(false);
setHideNotificationbar(true);
} else {
setIsNotificationbarAvailable(true);
setHideNotificationbar(false);

Check warning on line 49 in src/courseware/course/new-sidebar/SidebarContextProvider.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/SidebarContextProvider.jsx#L45-L49

Added lines #L45 - L49 were not covered by tests
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [verifiedMode]);

useEffect(() => {
setCurrentSidebar(SidebarID);

Check warning on line 55 in src/courseware/course/new-sidebar/SidebarContextProvider.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/SidebarContextProvider.jsx#L54-L55

Added lines #L54 - L55 were not covered by tests
if (isDiscussionbarAvailable) { setHideDiscussionbar(false); } else { setHideDiscussionbar(true); }
if (isNotificationbarAvailable) { setHideNotificationbar(false); } else { setHideNotificationbar(true); }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [unitId, isDiscussionbarAvailable, isNotificationbarAvailable]);

const onNotificationSeen = useCallback(() => {
setNotificationStatus('inactive');
setLocalStorage(`notificationStatus.${courseId}`, 'inactive');

Check warning on line 63 in src/courseware/course/new-sidebar/SidebarContextProvider.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/SidebarContextProvider.jsx#L61-L63

Added lines #L61 - L63 were not covered by tests
}, [courseId]);

useEffect(() => {

Check warning on line 66 in src/courseware/course/new-sidebar/SidebarContextProvider.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/SidebarContextProvider.jsx#L66

Added line #L66 was not covered by tests
if (hideDiscussionbar && hideNotificationbar) {
setCurrentSidebar(null);

Check warning on line 68 in src/courseware/course/new-sidebar/SidebarContextProvider.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/SidebarContextProvider.jsx#L68

Added line #L68 was not covered by tests
}
}, [hideDiscussionbar, hideNotificationbar]);

const toggleSidebar = useCallback((sidebarId, tabId) => {

Check warning on line 72 in src/courseware/course/new-sidebar/SidebarContextProvider.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/SidebarContextProvider.jsx#L72

Added line #L72 was not covered by tests
if (tabId === Discussions) {
setHideDiscussionbar(true);

Check warning on line 74 in src/courseware/course/new-sidebar/SidebarContextProvider.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/SidebarContextProvider.jsx#L74

Added line #L74 was not covered by tests
} else if (tabId === Notifications) {
setHideNotificationbar(true);
} else {

Check warning on line 77 in src/courseware/course/new-sidebar/SidebarContextProvider.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/SidebarContextProvider.jsx#L76-L77

Added lines #L76 - L77 were not covered by tests
setCurrentSidebar(prevSidebar => (sidebarId === prevSidebar ? null : sidebarId));
if (isDiscussionbarAvailable) { setHideDiscussionbar(false); }
if (isNotificationbarAvailable) { setHideNotificationbar(false); }
}
}, [isNotificationbarAvailable, isDiscussionbarAvailable]);

const contextValue = useMemo(() => ({

Check warning on line 84 in src/courseware/course/new-sidebar/SidebarContextProvider.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/SidebarContextProvider.jsx#L84

Added line #L84 was not covered by tests
toggleSidebar,
onNotificationSeen,
setNotificationStatus,
currentSidebar,
notificationStatus,
upgradeNotificationCurrentState,
setUpgradeNotificationCurrentState,
shouldDisplaySidebarOpen,
shouldDisplayFullScreen,
courseId,
unitId,
hideDiscussionbar,
hideNotificationbar,
isNotificationbarAvailable,
isDiscussionbarAvailable,
awais-ansari marked this conversation as resolved.
Show resolved Hide resolved
}), [courseId, currentSidebar, notificationStatus, onNotificationSeen, shouldDisplayFullScreen,
shouldDisplaySidebarOpen, toggleSidebar, unitId, upgradeNotificationCurrentState, hideDiscussionbar,
hideNotificationbar, isNotificationbarAvailable, isDiscussionbarAvailable]);

return (

Check warning on line 104 in src/courseware/course/new-sidebar/SidebarContextProvider.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/SidebarContextProvider.jsx#L104

Added line #L104 was not covered by tests
<SidebarContext.Provider value={contextValue}>
{children}
</SidebarContext.Provider>
);
};

SidebarProvider.propTypes = {
courseId: PropTypes.string.isRequired,
unitId: PropTypes.string.isRequired,
children: PropTypes.node,
};

SidebarProvider.defaultProps = {
children: null,
};

export default SidebarProvider;
28 changes: 28 additions & 0 deletions src/courseware/course/new-sidebar/SidebarTriggers.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import classNames from 'classnames';
import React, { useContext } from 'react';
import SidebarContext from './SidebarContext';
import NewSidebarTrigger from './NewSidebarTrigger';
import { SidebarID } from './constants';

const SidebarTriggers = () => {
const {
toggleSidebar,
currentSidebar,
} = useContext(SidebarContext);
const isActive = currentSidebar === SidebarID;
return (

Check warning on line 13 in src/courseware/course/new-sidebar/SidebarTriggers.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/SidebarTriggers.jsx#L11-L13

Added lines #L11 - L13 were not covered by tests
<div className="d-flex ml-auto">
<div
className={classNames('mt-3', { 'border-primary-700': isActive })}
style={{ borderBottom: isActive ? '2px solid' : null }}
key={SidebarID}
>
<NewSidebarTrigger onClick={() => toggleSidebar(SidebarID)} key={SidebarID} />

Check warning on line 20 in src/courseware/course/new-sidebar/SidebarTriggers.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/new-sidebar/SidebarTriggers.jsx#L20

Added line #L20 was not covered by tests
</div>
</div>
);
};

SidebarTriggers.propTypes = {};

export default SidebarTriggers;
Loading