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: Disable admin checkbox and checkbox all #21375

Merged
merged 6 commits into from
Jun 28, 2023
Merged
Changes from 2 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
24 changes: 21 additions & 3 deletions src/pages/workspace/WorkspaceMembersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ function WorkspaceMembersPage(props) {
*/
const renderItem = useCallback(
({item}) => {
const disabled = props.session.email === item.login || item.role === 'admin';
Copy link
Contributor

Choose a reason for hiding this comment

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

Hello! I believe that bug #23890 could have been addressed within this PR. In offline mode, it's important to consider disabling users who have pending delete actions.

const hasError = !_.isEmpty(item.errors) || errors[item.accountID];
const isChecked = _.contains(selectedEmployees, Number(item.accountID));
return (
Expand All @@ -302,6 +303,7 @@ function WorkspaceMembersPage(props) {
>
<PressableWithFeedback
style={[styles.peopleRow, (_.isEmpty(item.errors) || errors[item.accountID]) && styles.peopleRowBorderBottom, hasError && styles.borderColorDanger]}
disabled={disabled}
onPress={() => toggleUser(item.accountID, item.pendingAction)}
accessibilityRole="checkbox"
accessibilityState={{
Expand All @@ -313,12 +315,14 @@ function WorkspaceMembersPage(props) {
pressDimmingValue={0.7}
>
<Checkbox
disabled={disabled}
isChecked={isChecked}
onPress={() => toggleUser(item.accountID, item.pendingAction)}
/>
<View style={styles.flex1}>
<OptionRow
boldStyle
isDisabled={disabled}
option={{
text: props.formatPhoneNumber(item.displayName),
alternateText: props.formatPhoneNumber(item.login),
Expand Down Expand Up @@ -448,10 +452,24 @@ function WorkspaceMembersPage(props) {
{data.length > 0 ? (
<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(selectedEmployees, Number(accountID)))}
<PressableWithFeedback
disabled={_.isEmpty(removableMembers)}
onPress={() => toggleAllUsers(removableMembers)}
/>
accessibilityRole="checkbox"
accessibilityState={{
checked: !_.isEmpty(removableMembers) && _.every(_.keys(removableMembers), (accountID) => _.contains(selectedEmployees, Number(accountID))),
}}
accessibilityLabel={props.translate('workspace.people.selectAll')}
// disable hover dimming
dukenv0307 marked this conversation as resolved.
Show resolved Hide resolved
hoverDimmingValue={1}
pressDimmingValue={0.7}
>
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a console error. You need to add accessibilityLabel.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Just updated

<Checkbox
disabled={_.isEmpty(removableMembers)}
isChecked={!_.isEmpty(removableMembers) && _.every(_.keys(removableMembers), (accountID) => _.contains(selectedEmployees, Number(accountID)))}
onPress={() => toggleAllUsers(removableMembers)}
/>
</PressableWithFeedback>
<View style={[styles.flex1]}>
<Text style={[styles.textStrong, styles.ph5]}>{props.translate('workspace.people.selectAll')}</Text>
</View>
Expand Down