Skip to content

Commit

Permalink
Merge pull request #21023 from Pujan92/fix/20809
Browse files Browse the repository at this point in the history
Fix: Error message "Can't remove admin" isn't shown when selecting workspace admins
(cherry picked from commit 0b6a0ca)
  • Loading branch information
MonilBhavsar authored and OSBotify committed Jun 19, 2023
1 parent fc69c71 commit cb3ff62
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/pages/workspace/WorkspaceMembersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import withCurrentUserPersonalDetails from '../../components/withCurrentUserPers
import * as PolicyUtils from '../../libs/PolicyUtils';
import PressableWithFeedback from '../../components/Pressable/PressableWithFeedback';
import Log from '../../libs/Log';
import * as PersonalDetailsUtils from '../../libs/PersonalDetailsUtils';

const propTypes = {
/** The personal details of the person who is logged in */
Expand Down Expand Up @@ -286,8 +287,9 @@ class WorkspaceMembersPage extends React.Component {

validate() {
const errors = {};
const ownerAccountID = _.first(PersonalDetailsUtils.getAccountIDsByLogins([this.props.policy.owner]));
_.each(this.state.selectedEmployees, (member) => {
if (member !== this.props.policy.owner && member !== this.props.session.email) {
if (member !== ownerAccountID && member !== this.props.session.accountID) {
return;
}

Expand Down Expand Up @@ -319,7 +321,7 @@ class WorkspaceMembersPage extends React.Component {
* @returns {React.Component}
*/
renderItem({item}) {
const hasError = !_.isEmpty(item.errors) || this.state.errors[item.login];
const hasError = !_.isEmpty(item.errors) || this.state.errors[item.accountID];
const isChecked = _.contains(this.state.selectedEmployees, Number(item.accountID));
return (
<OfflineWithFeedback
Expand All @@ -328,7 +330,7 @@ class WorkspaceMembersPage extends React.Component {
errors={item.errors}
>
<PressableWithFeedback
style={[styles.peopleRow, (_.isEmpty(item.errors) || this.state.errors[item.login]) && styles.peopleRowBorderBottom, hasError && styles.borderColorDanger]}
style={[styles.peopleRow, (_.isEmpty(item.errors) || this.state.errors[item.accountID]) && styles.peopleRowBorderBottom, hasError && styles.borderColorDanger]}
onPress={() => this.toggleUser(item.accountID, item.pendingAction)}
accessibilityRole="checkbox"
accessibilityState={{
Expand Down Expand Up @@ -368,10 +370,10 @@ class WorkspaceMembersPage extends React.Component {
</View>
)}
</PressableWithFeedback>
{!_.isEmpty(this.state.errors[item.login]) && (
{!_.isEmpty(this.state.errors[item.accountID]) && (
<FormHelpMessage
isError
message={this.state.errors[item.login]}
message={this.state.errors[item.accountID]}
/>
)}
</OfflineWithFeedback>
Expand Down

0 comments on commit cb3ff62

Please sign in to comment.