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

feat: select group learners from table individually #1438

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marlonkeating
Copy link
Contributor

Jira Ticket

Functionality-wise, this change modifies the group member management modals to add/remove group members immediately when checkbox is clicked, rather than having to check a batch and click the Add/Remove bulk action buttons.

As part of this work, there is an extensive refactoring of the email validation logic out of individual components and into a central Context store.

Testing

Setup

  • Go to the admin-portal repo and run npm run start:stage

Create Group

Add/Remove Group Members

For all changes

  • Ensure adequate tests are in place (or reviewed existing tests cover changes)

Only if submitting a visual change

  • Ensure to attach screenshots
  • Ensure to have UX team confirm screenshots

Copy link

codecov bot commented Mar 5, 2025

Codecov Report

Attention: Patch coverage is 97.29730% with 3 lines in your changes missing coverage. Please review.

Project coverage is 86.62%. Comparing base (c79ab87) to head (a26edb4).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/components/PeopleManagement/data/reducer.ts 94.87% 2 Missing ⚠️
...opleManagement/EnterpriseCustomerUserDataTable.jsx 95.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1438      +/-   ##
==========================================
+ Coverage   86.41%   86.62%   +0.21%     
==========================================
  Files         660      661       +1     
  Lines       14934    14862      -72     
  Branches     3109     3164      +55     
==========================================
- Hits        12905    12874      -31     
+ Misses       1965     1917      -48     
- Partials       64       71       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

fix: ValidateEmailsContextProvider file reference

fix: unit tests and analytics

fix: console warning

chore: remove unused code
Comment on lines +9 to +10
allEnterpriseLearners?: string[],
groupEnterpriseLearners?: string[],
Copy link
Contributor

Choose a reason for hiding this comment

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

[question] can we set this to default to an empty array [] rather than undefined if the fields are always expected to be arrays even if they're empty?

ValidatedEmailsReducer,
{ ...initialContext, ...initialContextOverride },
);
validatedEmailsState.dispatch = dispatch;
Copy link
Contributor

Choose a reason for hiding this comment

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

[question (non-blocking)] is there a reason why we are manually adding dispatch? this seems a bit unconventional. could we instead manage dispatch outside of the context to something like this?

const value = {
  ...validatedEmailsState,
  dispatch,
};

const emails = newState.lowerCasedEmails as string[];
newState.lowerCasedEmails = removeStringsFromList(emails, removedEmails);
return { ...newState };
} default: {
Copy link
Contributor

Choose a reason for hiding this comment

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

[suggestion (non-blocking)]: looks like this reducer assumes that all inputs/data are valid but can we consider adding a log in the default to catch any unexpected actions/errors?

Comment on lines +43 to +48
if (actionType === 'CLICK_ACTION') {
newState.isCreateGroupListSelection = true;
}
if (actionType === 'UPLOAD_CSV_ACTION') {
newState.isCreateGroupFileUpload = true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

[suggestion (non-blocking)]:

  const updatedState = {
    ...newState,
    isCreateGroupListSelection: actionType === 'CLICK_ACTION',
    isCreateGroupFileUpload: actionType === 'UPLOAD_CSV_ACTION',
  };

Comment on lines +49 to +56
if (clearErroredEmails) {
newState.duplicateEmails = [];
newState.emailsNotInOrg = [];
newState.invalidEmails = [];
emails = [...(newState.lowerCasedEmails || []), ...addedEmails];
} else {
emails = [...allEmails(newState), ...addedEmails];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

[suggestion (non-blocking)]: could we extract this into a helper function to merge all the emails?

const getUpdatedEmails = (newState, addedEmails, clearErroredEmails) => {
      if (clearErroredEmails) {
        newState.duplicateEmails = [];
        newState.emailsNotInOrg = [];
        newState.invalidEmails = [];
        emails = [...(newState.lowerCasedEmails || []), ...addedEmails];
      }

return [...allEmails(newState), ...addedEmails];
}

const emails = getUpdatedEmails(updatedState, addedEmails, clearErroredEmails)

}
const emailValidation = isInviteEmailAddressesInputValueValid({
learnerEmails: emails,
allEnterpriseLearners: newState.allEnterpriseLearners as string[],
Copy link
Contributor

@katrinan029 katrinan029 Mar 7, 2025

Choose a reason for hiding this comment

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

this can be updated to allEnterpriseLearners: updatedState.allEnterpriseLearners

learnerEmails: emails,
allEnterpriseLearners: newState.allEnterpriseLearners as string[],
});
return { ...newState, ...emailValidation };
Copy link
Contributor

Choose a reason for hiding this comment

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

updated to return { ...updatedState, ...emailValidation }

Copy link
Contributor

@katrinan029 katrinan029 left a comment

Choose a reason for hiding this comment

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

Looks good so far! The functionality is working as expected. I just have a couple of non-blocking suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants