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

fix: rely on new error_reason field to determine failed learner_state reason #1079

Merged
merged 7 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/components/EnterpriseApp/EnterpriseAppRoutes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const EnterpriseAppRoutes = ({
enableContentHighlightsPage,
}) => {
const { canManageLearnerCredit } = useContext(EnterpriseSubsidiesContext);
console.log('EnterpriseAppRoutes!!!');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[context] These erroneous console.log statements slipped through in the previous PR that merged while debugging one of the review comments. Removing the console.log statements in this PR.

return (
<Switch>
<Route
Expand Down
6 changes: 1 addition & 5 deletions src/components/EnterpriseApp/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,16 @@ class EnterpriseApp extends React.Component {
} = this.props;
this.props.fetchPortalConfiguration(enterpriseSlug);
this.props.toggleSidebarToggle(); // ensure sidebar toggle button is in header

console.log('EnterpriseApp componentDidMount!!!');
}

componentDidUpdate(prevProps, prevState) {
componentDidUpdate(prevProps) {
const {
location: { pathname },
} = this.props;

if (pathname !== prevProps.location.pathname) {
this.handleSidebarMenuItemClick();
}

console.log('EnterpriseApp componentDidUpdate!!!', { prevProps, prevState, currentProps: this.props, currentState: this.state });
}

componentWillUnmount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ import FailedBadEmail from './assignments-status-chips/FailedBadEmail';
import FailedSystem from './assignments-status-chips/FailedSystem';

const AssignmentStatusTableCell = ({ row }) => {
const { original: { learnerEmail, learnerState } } = row;
const { original } = row;
const {
learnerEmail,
learnerState,
errorReason,
} = original;

// Learner state is not available for this assignment, so don't display anything.
if (!learnerState) {
return null;
}

// Display the appropriate status chip based on the learner state.
if (learnerState === 'notifying') {
return (
<NotifyingLearner learnerEmail={learnerEmail} />
Expand All @@ -29,12 +35,8 @@ const AssignmentStatusTableCell = ({ row }) => {
}

if (learnerState === 'failed') {
// Determine the failure reason based on the actions.
const { actions } = row.original;
const mostRecentAction = actions[0]; // API returns actions in reverse chronological order.
const isBadEmailError = mostRecentAction.actionType === 'notified' && !!mostRecentAction.errorReason;

if (isBadEmailError) {
// Determine which failure chip to display based on the error reason.
if (errorReason === 'email_error') {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[inform] Added via openedx/enterprise-access#314

return (
<FailedBadEmail learnerEmail={learnerEmail} />
);
Expand All @@ -52,6 +54,7 @@ AssignmentStatusTableCell.propTypes = {
original: PropTypes.shape({
learnerEmail: PropTypes.string,
learnerState: PropTypes.string.isRequired,
errorReason: PropTypes.string,
actions: PropTypes.arrayOf(PropTypes.shape({
actionType: PropTypes.string.isRequired,
errorReason: PropTypes.string,
Expand Down
2 changes: 0 additions & 2 deletions src/components/learner-credit-management/BudgetDetailPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ const BudgetDetailPage = () => {
data: subsidyAccessPolicy,
} = useSubsidyAccessPolicy(subsidyAccessPolicyId);

console.log('BudgetDetailPage!!!');

if (isInitialLoadingSubsidyAccessPolicy) {
return (
<BudgetDetailPageWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ const BudgetDetailTabsAndRoutes = ({
enterpriseSlug,
enterpriseFeatures,
}) => {

console.log('BudgetDetailTabsAndRoutes!!!');

const { activeTabKey: routeActiveTabKey } = useParams();
const { budgetId, subsidyAccessPolicyId } = useBudgetId();
const { data: subsidyAccessPolicy } = useSubsidyAccessPolicy(subsidyAccessPolicyId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ export const NextStepsForAssignedLearners = ({ course }) => (
is calculated based on the course enrollment deadline or {ASSIGNMENT_ENROLLMENT_DEADLINE} days
past the date of assignment, whichever is sooner.
</li>
<li>
Learners will receive automated reminder emails every 10-15 days until the enrollment
deadline is reached.
</li>
Comment on lines -23 to -26
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed based on this recent Figma annotation:

image

</ul>
</div>
</Collapsible>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export const BaseCatalogSearchResults = ({
error,
setNoContent,
}) => {
console.log('BaseCatalogSearchResults!!!', searchResults);
const courseColumns = useMemo(
() => [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,17 @@ const mockSuccessfulNotifiedAction = {
completedAt: '2023-10-27',
errorReason: null,
};

const mockSuccessfulLinkedLearnerAction = {
uuid: 'test-assignment-action-uuid',
actionType: 'notified',
completedAt: '2023-10-27',
errorReason: null,
};
const mockFailedNotifiedAction = {
...mockSuccessfulNotifiedAction,
completedAt: null,
errorReason: 'bad_email',
errorReason: 'email_error',
};

const mockFailedLinkedLearnerAction = {
...mockFailedNotifiedAction,
actionType: 'learner_linked',
Expand Down Expand Up @@ -302,6 +306,7 @@ describe('<BudgetDetailPage />', () => {
learnerState: 'waiting',
recentAction: { actionType: 'assigned', timestamp: '2023-10-27' },
actions: [mockSuccessfulNotifiedAction],
errorReason: null,
},
],
numPages: 1,
Expand Down Expand Up @@ -373,6 +378,7 @@ describe('<BudgetDetailPage />', () => {
learnerState: 'waiting',
recentAction: { actionType: 'assigned', timestamp: '2023-10-27' },
actions: [mockSuccessfulNotifiedAction],
errorReason: null,
},
],
numPages: 1,
Expand Down Expand Up @@ -404,6 +410,7 @@ describe('<BudgetDetailPage />', () => {
expectedModalPopupHeading: `Notifying ${mockLearnerEmail}`,
expectedModalPopupContent: `Our system is busy emailing ${mockLearnerEmail}!`,
actions: [],
errorReason: null,
},
{
learnerState: 'notifying',
Expand All @@ -412,38 +419,43 @@ describe('<BudgetDetailPage />', () => {
expectedModalPopupHeading: 'Notifying learner',
expectedModalPopupContent: 'Our system is busy emailing the learner!',
actions: [],
errorReason: null,
},
{
learnerState: 'waiting',
hasLearnerEmail: true,
expectedChipStatus: 'Waiting for learner',
expectedModalPopupHeading: `Waiting for ${mockLearnerEmail}`,
expectedModalPopupContent: 'This learner must create an edX account and complete enrollment in the course',
actions: [mockSuccessfulNotifiedAction],
actions: [mockSuccessfulLinkedLearnerAction, mockSuccessfulNotifiedAction],
errorReason: null,
},
{
learnerState: 'waiting',
hasLearnerEmail: false,
expectedChipStatus: 'Waiting for learner',
expectedModalPopupHeading: 'Waiting for learner',
expectedModalPopupContent: 'This learner must create an edX account and complete enrollment in the course',
actions: [mockSuccessfulNotifiedAction],
actions: [mockSuccessfulLinkedLearnerAction, mockSuccessfulNotifiedAction],
errorReason: null,
},
{
learnerState: 'failed',
hasLearnerEmail: true,
expectedChipStatus: 'Failed: Bad email',
expectedModalPopupHeading: 'Failed: Bad email',
expectedModalPopupContent: `This course assignment failed because a notification to ${mockLearnerEmail} could not be sent.`,
actions: [mockFailedNotifiedAction],
actions: [mockSuccessfulLinkedLearnerAction, mockFailedNotifiedAction],
errorReason: 'email_error',
},
{
learnerState: 'failed',
hasLearnerEmail: false,
expectedChipStatus: 'Failed: Bad email',
expectedModalPopupHeading: 'Failed: Bad email',
expectedModalPopupContent: 'This course assignment failed because a notification to the learner could not be sent.',
actions: [mockFailedNotifiedAction],
actions: [mockSuccessfulLinkedLearnerAction, mockFailedNotifiedAction],
errorReason: 'email_error',
},
{
learnerState: 'failed',
Expand All @@ -452,6 +464,7 @@ describe('<BudgetDetailPage />', () => {
expectedModalPopupHeading: 'Failed: System',
expectedModalPopupContent: 'Something went wrong behind the scenes.',
actions: [mockFailedLinkedLearnerAction],
errorReason: 'internal_api_error',
},
])('renders correct status chips with assigned table data (%s)', ({
learnerState,
Expand All @@ -460,6 +473,7 @@ describe('<BudgetDetailPage />', () => {
expectedModalPopupHeading,
expectedModalPopupContent,
actions,
errorReason,
}) => {
useParams.mockReturnValue({
budgetId: mockSubsidyAccessPolicyUUID,
Expand Down Expand Up @@ -489,6 +503,7 @@ describe('<BudgetDetailPage />', () => {
learnerState,
recentAction: { actionType: 'assigned', timestamp: '2023-10-27' },
actions,
errorReason,
},
],
numPages: 1,
Expand Down Expand Up @@ -757,6 +772,7 @@ describe('<BudgetDetailPage />', () => {
learnerState: 'active',
recentAction: { actionType: 'assigned', timestamp: '2023-10-27' },
actions: [],
errorReason: null,
state: 'allocated',
},
],
Expand Down
Loading