Skip to content

Commit

Permalink
add early return for delete modal
Browse files Browse the repository at this point in the history
  • Loading branch information
luacmartins committed Jan 17, 2023
1 parent 52dd36f commit 6d0ef22
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/pages/workspace/WorkspaceMembersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ class WorkspaceMembersPage extends React.Component {
* Show the modal to confirm removal of the selected members
*/
askForConfirmationToRemove() {
if (!_.isEmpty(this.state.errors)) {
return;
}

this.setState({isRemoveMembersConfirmModalVisible: true});
}

Expand Down Expand Up @@ -157,7 +161,6 @@ class WorkspaceMembersPage extends React.Component {
*
*/
toggleUser(login, pendingAction) {
// @TODO: call validate here
if (pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) {
return;
}
Expand All @@ -168,6 +171,8 @@ class WorkspaceMembersPage extends React.Component {
} else {
this.addUser(login);
}

this.validate();
}

/**
Expand Down Expand Up @@ -205,16 +210,17 @@ class WorkspaceMembersPage extends React.Component {
}
}

// @TODO: implement method
validate() {
const error = {};
const errors = {};
_.each(this.state.selectedEmployees, (member) => {
if (member !== this.props.policy.owner && member !== this.props.session.email) {
return;
}

return error;
errors[member] = this.props.translate('workspace.people.error.cannotRemove');
});

this.setState({errors});
}

/**
Expand All @@ -233,6 +239,7 @@ class WorkspaceMembersPage extends React.Component {
item,
}) {
return (
// @TODO: display error
<OfflineWithFeedback errorRowStyles={[styles.peopleRowBorderBottom]} onClose={() => this.dismissError(item)} pendingAction={item.pendingAction} errors={item.errors}>
<TouchableOpacity
style={[styles.peopleRow, (_.isEmpty(item.errors) || this.state.errors[item.login]) && styles.peopleRowBorderBottom]}
Expand Down

0 comments on commit 6d0ef22

Please sign in to comment.