Skip to content

Commit

Permalink
fix: prevent content tools from displaying over chat sidebar (openedx…
Browse files Browse the repository at this point in the history
  • Loading branch information
alangsto authored Aug 31, 2023
1 parent 645ac2c commit 32bd319
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 18 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@edx/brand": "npm:@edx/brand-openedx@1.2.0",
"@edx/frontend-component-footer": "12.0.0",
"@edx/frontend-component-header": "4.0.0",
"@edx/frontend-lib-learning-assistant": "^1.9.3",
"@edx/frontend-lib-learning-assistant": "^1.9.4",
"@edx/frontend-lib-special-exams": "2.20.1",
"@edx/frontend-platform": "4.3.0",
"@edx/paragon": "20.46.0",
Expand Down
1 change: 1 addition & 0 deletions src/courseware/course/Course.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const Course = ({
enrollmentMode={course.enrollmentMode}
isStaff={isStaff}
courseId={courseId}
contentToolsEnabled={course.showCalculator || course.notes.enabled}
/>
<SidebarTriggers />
</>
Expand Down
4 changes: 3 additions & 1 deletion src/courseware/course/chat/Chat.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Chat = ({
enrollmentMode,
isStaff,
courseId,
contentToolsEnabled,
}) => {
const VERIFIED_MODES = [
'professional',
Expand All @@ -34,7 +35,7 @@ const Chat = ({
<>
{/* Use a portal to ensure that component overlay does not compete with learning MFE styles. */}
{shouldDisplayChat && (createPortal(
<Xpert courseId={courseId} />,
<Xpert courseId={courseId} contentToolsEnabled={contentToolsEnabled} />,
document.body,
))}
</>
Expand All @@ -46,6 +47,7 @@ Chat.propTypes = {
enabled: PropTypes.bool.isRequired,
enrollmentMode: PropTypes.string,
courseId: PropTypes.string.isRequired,
contentToolsEnabled: PropTypes.bool.isRequired,
};

Chat.defaultProps = {
Expand Down
3 changes: 3 additions & 0 deletions src/courseware/course/chat/Chat.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('Chat', () => {
isStaff={false}
enabled
courseId={courseId}
contentToolsEnabled={false}
/>
</BrowserRouter>,
{ store },
Expand Down Expand Up @@ -74,6 +75,7 @@ describe('Chat', () => {
isStaff
enabled
courseId={courseId}
contentToolsEnabled={false}
/>
</BrowserRouter>,
{ store },
Expand Down Expand Up @@ -134,6 +136,7 @@ describe('Chat', () => {
isStaff={test.isStaff}
enabled={test.enabled}
courseId={courseId}
contentToolsEnabled={false}
/>
</BrowserRouter>,
{ store },
Expand Down
33 changes: 21 additions & 12 deletions src/courseware/course/content-tools/ContentTools.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
import React from 'react';
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';

import Calculator from './calculator';
import NotesVisibility from './notes-visibility';

const ContentTools = ({
course,
}) => (
<div className="content-tools">
<div className="d-flex justify-content-end align-items-end m-0">
{course.showCalculator && (
<Calculator />
)}
{course.notes.enabled && (
<NotesVisibility course={course} />
)}
</div>
</div>
);
}) => {
const {
sidebarIsOpen,
} = useSelector(state => state.learningAssistant);

return (
!sidebarIsOpen && (
<div className="content-tools">
<div className="d-flex justify-content-end align-items-end m-0">
{course.showCalculator && (
<Calculator />
)}
{course.notes.enabled && (
<NotesVisibility course={course} />
)}
</div>
</div>
)
);
};

ContentTools.propTypes = {
course: PropTypes.shape({
Expand Down

0 comments on commit 32bd319

Please sign in to comment.