-
Notifications
You must be signed in to change notification settings - Fork 19
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
fix: ensure email setting model functions as expected #1136
Merged
adamstankiewicz
merged 1 commit into
openedx:master
from
zwidekalanga:zwidekalanga/ENT-9273
Aug 12, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The issue with removing
hasEmailsEnabled
stuff altogether is that not all course enrollment card types/variants should include the email settings dropdown. For example, assignment cards (AssignedCourseCard
) should not expose the "Emails settings" dropdown given the assignment is not yet a legit course enrollment (i.e., learner hasn't accepted their assignment yet), so the user would likely face an error when trying to submit the email settings modal to save their choice.As is, removing this logic, incorrectly exposes the "Email settings" dropdown item for assignments:
When keeping this
hasEmailsEnabled
logic, it might be falsey for the following reasons:BaseCourseCard
is of type/variantAssignedCourseCard
, wherehasEmailsEnabled
isundefined
.BaseCourseCard
is not of type/variantAssignedCourseCard
, wherehasEmailsEnabled
represents the state of the whether the learners's current choice of whether emails are enabled for the course enrollment (i.e.,false
,true
).The modal previously wasn't opening when a learner has emails disabled for an enrollment because of the (2) case above, whereby
false
is falsey, fulfilling this condition and thus returningnull
.We would only want to short-circuit the rendering of the
EmailSettingsModal
whenhasEmailsEnabled
is a legit, defined value (i.e., notundefined
/null
).For all
BaseCourseCard
types/variants, the data is run through thetransformCourseEnrollment
function, and sets thehasEmailsEnabled
property based on theemailsEnabled
property for the given course enrollment. If theemailsEnabled
property isundefined
/null
(i.e., when the "course enrollment" here is actually representing an assignment, where email settings is not applicable).By removing the
hasEmailsEnabled
stuff altogether, notably withingetDropdownMenuItems
, the "Email settings" dropdown item is incorrectly exposed forAssignedCourseCard
, which would introduce a different bug since the related email settings API would error when called within the modal.I might suggest keeping all the
hasEmailsEnabled
stuff but make sure theBaseCourseCard
component properly handleshasEmailSettings
asundefined
/null
andfalse
as separate falsey conditions throguhout to mitigate these issues. Consider using theisDefinedAndNotNull
helper function (source), e.g.: