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: select all workspace invite comparison #20826

Merged
Merged
22 changes: 12 additions & 10 deletions src/pages/workspace/WorkspaceMembersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class WorkspaceMembersPage extends React.Component {
this.setState((prevState) => ({
selectedEmployees: _.intersection(
prevState.selectedEmployees,
_.keys(PolicyUtils.getClientPolicyMemberEmailsToAccountIDs(this.props.policyMembers, this.props.personalDetails)),
_.map(_.keys(PolicyUtils.getClientPolicyMemberEmailsToAccountIDs(this.props.policyMembers, this.props.personalDetails)), (accountID) => Number(accountID)),
BeeMargarida marked this conversation as resolved.
Show resolved Hide resolved
),
}));
}
Expand Down Expand Up @@ -214,10 +214,10 @@ class WorkspaceMembersPage extends React.Component {
* @param {Object} memberList
*/
toggleAllUsers(memberList) {
const emailList = _.keys(memberList);
const accountIDList = _.map(_.keys(memberList), (member) => Number(member));
BeeMargarida marked this conversation as resolved.
Show resolved Hide resolved
this.setState(
(prevState) => ({
selectedEmployees: !_.every(emailList, (memberEmail) => _.contains(prevState.selectedEmployees, memberEmail)) ? emailList : [],
selectedEmployees: !_.every(accountIDList, (memberAccountID) => _.contains(prevState.selectedEmployees, Number(memberAccountID))) ? accountIDList : [],
BeeMargarida marked this conversation as resolved.
Show resolved Hide resolved
}),
() => this.validate(),
);
Expand All @@ -236,17 +236,17 @@ class WorkspaceMembersPage extends React.Component {
}

// Add or remove the user if the checkbox is enabled
if (_.contains(this.state.selectedEmployees, accountID)) {
this.removeUser(accountID);
if (_.contains(this.state.selectedEmployees, Number(accountID))) {
this.removeUser(Number(accountID));
} else {
this.addUser(accountID);
this.addUser(Number(accountID));
}
}

/**
* Add user from the selectedEmployees list
*
* @param {String} accountID
* @param {Number} accountID
*/
addUser(accountID) {
this.setState(
Expand All @@ -260,7 +260,7 @@ class WorkspaceMembersPage extends React.Component {
/**
* Remove user from the selectedEmployees list
*
* @param {String} accountID
* @param {Number} accountID
*/
removeUser(accountID) {
this.setState(
Expand Down Expand Up @@ -320,7 +320,7 @@ class WorkspaceMembersPage extends React.Component {
*/
renderItem({item}) {
const hasError = !_.isEmpty(item.errors) || this.state.errors[item.login];
const isChecked = _.contains(this.state.selectedEmployees, item.accountID);
const isChecked = _.contains(this.state.selectedEmployees, Number(item.accountID));
return (
<OfflineWithFeedback
onClose={() => this.dismissError(item)}
Expand Down Expand Up @@ -474,7 +474,9 @@ class WorkspaceMembersPage extends React.Component {
<View style={[styles.w100, styles.mt4, styles.flex1]}>
<View style={[styles.peopleRow, styles.ph5, styles.pb3]}>
<Checkbox
isChecked={!_.isEmpty(removableMembers) && _.every(_.keys(removableMembers), (accountID) => _.contains(this.state.selectedEmployees, accountID))}
isChecked={
!_.isEmpty(removableMembers) && _.every(_.keys(removableMembers), (accountID) => _.contains(this.state.selectedEmployees, Number(accountID)))
}
onPress={() => this.toggleAllUsers(removableMembers)}
/>
<View style={[styles.flex1]}>
Expand Down