-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: install Xpert chatbot from frontend-lib-learning-assistant
This commit installs the Xpert chatbot feature from the frontend-lib-learning-assistant repository into the frontend-lib-learning application. This component is rendered by the Course component. The component is only rendered when a few conditions are satisfied.
- Loading branch information
1 parent
2e90e21
commit 4ba1cde
Showing
18 changed files
with
338 additions
and
260 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
"@edx/frontend-component-footer": "12.0.0", | ||
"@edx/frontend-component-header": "4.0.0", | ||
"@edx/frontend-lib-special-exams": "2.20.1", | ||
"@edx/frontend-lib-learning-assistant": "^1.4.0", | ||
"@edx/frontend-platform": "4.3.0", | ||
"@edx/paragon": "20.46.0", | ||
"@edx/react-unit-test-utils": "npm:@edx/[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { createPortal } from 'react-dom'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import { Xpert } from '@edx/frontend-lib-learning-assistant'; | ||
import { injectIntl } from '@edx/frontend-platform/i18n'; | ||
|
||
const Chat = ({ | ||
enabled, | ||
enrollmentMode, | ||
isStaff, | ||
courseId, | ||
}) => { | ||
const VERIFIED_MODES = [ | ||
'professional', | ||
'verified', | ||
'no-id-professional', | ||
'credit', | ||
'masters', | ||
'executive-education', | ||
]; | ||
|
||
const isVerifiedEnrollmentMode = ( | ||
enrollmentMode !== null | ||
&& enrollmentMode !== undefined | ||
&& VERIFIED_MODES.some(mode => mode === enrollmentMode) | ||
); | ||
|
||
const shouldDisplayChat = ( | ||
enabled | ||
&& (isVerifiedEnrollmentMode || isStaff) // display only to non-audit or staff | ||
); | ||
|
||
return ( | ||
<> | ||
{/* Use a portal to ensure that component overlay does not compete with learning MFE styles. */} | ||
{shouldDisplayChat && (createPortal( | ||
<Xpert courseId={courseId} />, | ||
document.body, | ||
))} | ||
</> | ||
); | ||
}; | ||
|
||
Chat.propTypes = { | ||
isStaff: PropTypes.bool.isRequired, | ||
enabled: PropTypes.bool.isRequired, | ||
enrollmentMode: PropTypes.string, | ||
courseId: PropTypes.string.isRequired, | ||
}; | ||
|
||
Chat.defaultProps = { | ||
enrollmentMode: null, | ||
}; | ||
|
||
export default injectIntl(Chat); |
Oops, something went wrong.