-
Notifications
You must be signed in to change notification settings - Fork 214
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: update gating for chat component #1550
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,10 @@ import { useSelector } from 'react-redux'; | |
import PropTypes from 'prop-types'; | ||
|
||
import { Xpert } from '@edx/frontend-lib-learning-assistant'; | ||
import { getConfig } from '@edx/frontend-platform'; | ||
import { injectIntl } from '@edx/frontend-platform/i18n'; | ||
|
||
import { VERIFIED_MODES } from '@src/constants'; | ||
import { AUDIT_MODES, VERIFIED_MODES } from '@src/constants'; | ||
import { useModel } from '../../../generic/model-store'; | ||
|
||
const Chat = ({ | ||
|
@@ -21,10 +22,14 @@ const Chat = ({ | |
} = useSelector(state => state.specialExams); | ||
const course = useModel('coursewareMeta', courseId); | ||
|
||
const hasVerifiedEnrollment = ( | ||
const hasValidEnrollment = ( | ||
enrollmentMode !== null | ||
&& enrollmentMode !== undefined | ||
&& VERIFIED_MODES.includes(enrollmentMode) | ||
&& ( | ||
VERIFIED_MODES.includes(enrollmentMode) | ||
// audit learners are only eligible if Xpert has been explicitly enabled for audit | ||
|| (AUDIT_MODES.includes(enrollmentMode) && getConfig().ENABLE_XPERT_AUDIT) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! |
||
) | ||
); | ||
|
||
const validDates = () => { | ||
|
@@ -42,19 +47,30 @@ const Chat = ({ | |
|
||
const shouldDisplayChat = ( | ||
enabled | ||
&& (hasVerifiedEnrollment || isStaff) // display only to verified learners or staff | ||
&& (hasValidEnrollment || isStaff) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this rename, makes more sense since what counts as "verified" is kinda blurred by the enrollments we chose to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1! |
||
&& validDates() | ||
// it is necessary to check both whether the user is in an exam, and whether or not they are viewing an exam | ||
// this will prevent the learner from interacting with the tool at any point of the exam flow, even at the | ||
// entrance interstitial. | ||
&& !(activeAttempt?.attempt_id || exam?.id) | ||
); | ||
|
||
const isUpgradeEligible = ( | ||
enrollmentMode !== null | ||
&& enrollmentMode !== undefined | ||
&& AUDIT_MODES.includes(enrollmentMode) | ||
); | ||
|
||
return ( | ||
<> | ||
{/* Use a portal to ensure that component overlay does not compete with learning MFE styles. */} | ||
{shouldDisplayChat && (createPortal( | ||
<Xpert courseId={courseId} contentToolsEnabled={contentToolsEnabled} unitId={unitId} />, | ||
<Xpert | ||
courseId={courseId} | ||
contentToolsEnabled={contentToolsEnabled} | ||
unitId={unitId} | ||
isUpgradEligible={isUpgradeEligible} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: small typo, guessing you meant to name this |
||
/>, | ||
document.body, | ||
))} | ||
</> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,6 +175,7 @@ initialize({ | |
CHAT_RESPONSE_URL: process.env.CHAT_RESPONSE_URL || null, | ||
PRIVACY_POLICY_URL: process.env.PRIVACY_POLICY_URL || null, | ||
SHOW_UNGRADED_ASSIGNMENT_PROGRESS: process.env.SHOW_UNGRADED_ASSIGNMENT_PROGRESS || false, | ||
ENABLE_XPERT_AUDIT: process.env.ENABLE_XPERT_AUDIT || false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codecov seems to be unhappy with these lines not being covered, not sure we need (or are planning on) testing on these though? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These aren't normally tested as part of unit tests! |
||
}, 'LearnerAppConfig'); | ||
}, | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: this is just pulled from here right? https://github.com/openedx/edx-platform/blob/394a459dec831b9d306f4c1a09b7d9ece1a97388/common/djangoapps/course_modes/models.py#L208 Looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!