Skip to content

Commit

Permalink
Merge pull request #44734 from bernhardoj/fix/38925-disable-ws-row-wh…
Browse files Browse the repository at this point in the history
…en-pending

Disable newly added workspace member row if the personal detail is optimistic
  • Loading branch information
techievivek authored Jul 4, 2024
2 parents 83eb7e6 + fcb80e0 commit 58be9ba
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/components/SelectionList/TableListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function TableListItem<TItem extends ListItem>({
return (
<BaseListItem
item={item}
pressableStyle={[[styles.selectionListPressableItemWrapper, item.isSelected && styles.activeComponentBG, isFocused && styles.sidebarLinkActive]]}
pressableStyle={[[styles.selectionListPressableItemWrapper, item.isSelected && styles.activeComponentBG, isFocused && styles.sidebarLinkActive, item.cursorStyle]]}
wrapperStyle={[styles.flexRow, styles.flex1, styles.justifyContentBetween, styles.userSelectNone, styles.alignItemsCenter]}
containerStyle={styles.mb3}
isFocused={isFocused}
Expand All @@ -69,9 +69,9 @@ function TableListItem<TItem extends ListItem>({
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
disabled={isDisabled || item.isDisabledCheckbox}
onPress={handleCheckboxPress}
style={[styles.cursorUnset, StyleUtils.getCheckboxPressableStyle(), item.isDisabledCheckbox && styles.cursorDisabled, styles.mr3]}
style={[styles.cursorUnset, StyleUtils.getCheckboxPressableStyle(), item.isDisabledCheckbox && styles.cursorDisabled, styles.mr3, item.cursorStyle]}
>
<View style={[StyleUtils.getCheckboxContainerStyle(20), StyleUtils.getMultiselectListStyles(!!item.isSelected, !!item.isDisabled)]}>
<View style={[StyleUtils.getCheckboxContainerStyle(20), StyleUtils.getMultiselectListStyles(!!item.isSelected, !!item.isDisabled), item.cursorStyle]}>
{item.isSelected && (
<Icon
src={Expensicons.Checkmark}
Expand Down
5 changes: 5 additions & 0 deletions src/components/SelectionList/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type {MutableRefObject, ReactElement, ReactNode} from 'react';
import type {GestureResponderEvent, InputModeOptions, LayoutChangeEvent, SectionListData, StyleProp, TextInput, TextStyle, ViewStyle} from 'react-native';
import type {BrickRoad} from '@libs/WorkspacesSettingsUtils';
// eslint-disable-next-line no-restricted-imports
import type CursorStyles from '@styles/utils/cursor/types';
import type CONST from '@src/CONST';
import type {Errors, Icon, PendingAction} from '@src/types/onyx/OnyxCommon';
import type {SearchAccountDetails, SearchReport, SearchTransaction} from '@src/types/onyx/SearchResults';
Expand Down Expand Up @@ -131,6 +133,9 @@ type ListItem = {

/** Whether item pressable wrapper should be focusable */
tabIndex?: 0 | -1;

/** The style to override the cursor appearance */
cursorStyle?: CursorStyles[keyof CursorStyles];
};

type TransactionListItemType = ListItem &
Expand Down
1 change: 1 addition & 0 deletions src/libs/PersonalDetailsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ function getPersonalDetailsOnyxDataForOptimisticUsers(newLogins: string[], newAc
login,
accountID,
displayName: LocalePhoneNumber.formatPhoneNumber(login),
isOptimisticPersonalDetail: true,
};

/**
Expand Down
6 changes: 5 additions & 1 deletion src/pages/workspace/WorkspaceMembersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,10 @@ function WorkspaceMembersPage({personalDetails, invitedEmailsToAccountIDsDraft,
accountID,
isSelected,
isDisabledCheckbox: !(isPolicyAdmin && accountID !== policy?.ownerAccountID && accountID !== session?.accountID),
isDisabled: isPolicyAdmin && (policyEmployee.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || !isEmptyObject(policyEmployee.errors)),
isDisabled:
!!details.isOptimisticPersonalDetail ||
(isPolicyAdmin && (policyEmployee.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || !isEmptyObject(policyEmployee.errors))),
cursorStyle: details.isOptimisticPersonalDetail ? styles.cursorDefault : {},
text: formatPhoneNumber(PersonalDetailsUtils.getDisplayNameOrDefault(details)),
alternateText: formatPhoneNumber(details?.login ?? ''),
rightElement: roleBadge,
Expand Down Expand Up @@ -390,6 +393,7 @@ function WorkspaceMembersPage({personalDetails, invitedEmailsToAccountIDsDraft,
selectedEmployees,
session?.accountID,
translate,
styles.cursorDefault,
]);

const data = useMemo(() => getUsers(), [getUsers]);
Expand Down

0 comments on commit 58be9ba

Please sign in to comment.