Skip to content

Commit

Permalink
Merge pull request #47201 from rayane-djouah/make-room-members-view-c…
Browse files Browse the repository at this point in the history
…onsistent-with-groups-and-reports

Make the members view of rooms and expense chats consistent with groups
  • Loading branch information
MariaHCD authored Sep 9, 2024
2 parents 18e9883 + e69a45a commit 1fcba07
Show file tree
Hide file tree
Showing 20 changed files with 422 additions and 133 deletions.
8 changes: 8 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,9 @@ const CONST = {
EXPORT_TO_INTEGRATION: 'exportToIntegration',
MARK_AS_EXPORTED: 'markAsExported',
},
ROOM_MEMBERS_BULK_ACTION_TYPES: {
REMOVE: 'remove',
},
},
NEXT_STEP: {
ICONS: {
Expand Down Expand Up @@ -4206,6 +4209,11 @@ const CONST = {
*/
MAX_SELECTION_LIST_PAGE_LENGTH: 500,

/**
* We only include the members search bar when we have 8 or more members
*/
SHOULD_SHOW_MEMBERS_SEARCH_INPUT_BREAKPOINT: 8,

/**
* Bank account names
*/
Expand Down
4 changes: 4 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,10 @@ const ROUTES = {
route: 'r/:reportID/members',
getRoute: (reportID: string) => `r/${reportID}/members` as const,
},
ROOM_MEMBER_DETAILS: {
route: 'r/:reportID/members/:accountID',
getRoute: (reportID: string, accountID: string | number) => `r/${reportID}/members/${accountID}` as const,
},
ROOM_INVITE: {
route: 'r/:reportID/invite/:role?',
getRoute: (reportID: string, role?: string) => `r/${reportID}/invite/${role ?? ''}` as const,
Expand Down
8 changes: 6 additions & 2 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ const SCREENS = {
SIGN_IN: 'SignIn',
PRIVATE_NOTES: 'Private_Notes',
ROOM_MEMBERS: 'RoomMembers',
ROOM_MEMBER_DETAILS: 'RoomMembers_Details',
ROOM_INVITE: 'RoomInvite',
REFERRAL: 'Referral',
PROCESS_MONEY_REQUEST_HOLD: 'ProcessMoneyRequestHold',
Expand Down Expand Up @@ -514,8 +515,11 @@ const SCREENS = {
DETAILS: 'ReportParticipants_Details',
ROLE: 'ReportParticipants_Role',
},
ROOM_MEMBERS_ROOT: 'RoomMembers_Root',
ROOM_INVITE_ROOT: 'RoomInvite_Root',
ROOM_MEMBERS: {
ROOT: 'RoomMembers_Root',
INVITE: 'RoomMembers_Invite',
DETAILS: 'RoomMember_Details',
},
FLAG_COMMENT_ROOT: 'FlagComment_Root',
REIMBURSEMENT_ACCOUNT: 'ReimbursementAccount',
GET_ASSISTANCE: 'GetAssistance',
Expand Down
3 changes: 3 additions & 0 deletions src/components/ButtonWithDropdownMenu/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ type PaymentType = DeepValueOf<typeof CONST.IOU.PAYMENT_TYPE | typeof CONST.IOU.

type WorkspaceMemberBulkActionType = DeepValueOf<typeof CONST.POLICY.MEMBERS_BULK_ACTION_TYPES>;

type RoomMemberBulkActionType = DeepValueOf<typeof CONST.REPORT.ROOM_MEMBERS_BULK_ACTION_TYPES>;

type WorkspaceDistanceRatesBulkActionType = DeepValueOf<typeof CONST.POLICY.BULK_ACTION_TYPES>;

type WorkspaceTaxRatesBulkActionType = DeepValueOf<typeof CONST.POLICY.BULK_ACTION_TYPES>;
Expand Down Expand Up @@ -104,6 +106,7 @@ type ButtonWithDropdownMenuProps<TValueType> = {
export type {
PaymentType,
WorkspaceMemberBulkActionType,
RoomMemberBulkActionType,
WorkspaceDistanceRatesBulkActionType,
DropdownOption,
ButtonWithDropdownMenuProps,
Expand Down
2 changes: 1 addition & 1 deletion src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ function BaseSelectionList<TItem extends ListItem>(
shouldDelayFocus = true,
shouldUpdateFocusedIndex = false,
onLongPressRow,
shouldShowTextInput = !!textInputLabel || !!textInputIconLeft,
shouldShowListEmptyContent = true,
}: BaseSelectionListProps<TItem>,
ref: ForwardedRef<SelectionListHandle>,
Expand All @@ -108,7 +109,6 @@ function BaseSelectionList<TItem extends ListItem>(
const listRef = useRef<RNSectionList<TItem, SectionWithIndexOffset<TItem>>>(null);
const innerTextInputRef = useRef<RNTextInput | null>(null);
const focusTimeoutRef = useRef<NodeJS.Timeout | null>(null);
const shouldShowTextInput = !!textInputLabel || !!textInputIconLeft;
const shouldShowSelectAll = !!onSelectAll;
const activeElementRole = useActiveElementRole();
const isFocused = useIsFocused();
Expand Down
3 changes: 3 additions & 0 deletions src/components/SelectionList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ type BaseSelectionListProps<TItem extends ListItem> = Partial<ChildrenProps> & {
/** Callback to fire when an error is dismissed */
onDismissError?: (item: TItem) => void;

/** Whether to show the text input */
shouldShowTextInput?: boolean;

/** Label for the text input */
textInputLabel?: string;

Expand Down
6 changes: 3 additions & 3 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,6 @@ export default {
groupName: 'Group name',
},
groupChat: {
groupMembersListTitle: 'Directory of all group members.',
lastMemberTitle: 'Heads up!',
lastMemberWarning: "Since you're the last person here, leaving will make this chat inaccessible to all users. Are you sure you want to leave?",
defaultReportName: ({displayName}: {displayName: string}) => `${displayName}'s group chat`,
Expand Down Expand Up @@ -3171,8 +3170,9 @@ export default {
removeMembersWarningPrompt: ({memberName, ownerName}: RemoveMembersWarningPrompt) =>
`${memberName} is an approver in this workspace. When you unshare this workspace with them, we’ll replace them in the approval workflow with the workspace owner, ${ownerName}`,
removeMembersTitle: 'Remove members',
removeMemberButtonTitle: 'Remove from workspace',
removeMemberGroupButtonTitle: 'Remove from group',
removeWorkspaceMemberButtonTitle: 'Remove from workspace',
removeGroupMemberButtonTitle: 'Remove from group',
removeRoomMemberButtonTitle: 'Remove from chat',
removeMemberPrompt: ({memberName}: {memberName: string}) => `Are you sure you want to remove ${memberName}?`,
removeMemberTitle: 'Remove member',
transferOwner: 'Transfer owner',
Expand Down
6 changes: 3 additions & 3 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1535,7 +1535,6 @@ export default {
groupName: 'Nombre del grupo',
},
groupChat: {
groupMembersListTitle: 'Directorio de los miembros del grupo.',
lastMemberTitle: '¡Atención!',
lastMemberWarning: 'Ya que eres la última persona aquí, si te vas, este chat quedará inaccesible para todos los miembros. ¿Estás seguro de que quieres salir del chat?',
defaultReportName: ({displayName}: {displayName: string}) => `Chat de grupo de ${displayName}`,
Expand Down Expand Up @@ -3220,8 +3219,9 @@ export default {
removeMembersWarningPrompt: ({memberName, ownerName}: RemoveMembersWarningPrompt) =>
`${memberName} es un aprobador en este espacio de trabajo. Cuando lo elimine de este espacio de trabajo, los sustituiremos en el flujo de trabajo de aprobación por el propietario del espacio de trabajo, ${ownerName}`,
removeMembersTitle: 'Eliminar miembros',
removeMemberButtonTitle: 'Quitar del espacio de trabajo',
removeMemberGroupButtonTitle: 'Quitar del grupo',
removeWorkspaceMemberButtonTitle: 'Eliminar del espacio de trabajo',
removeGroupMemberButtonTitle: 'Eliminar del grupo',
removeRoomMemberButtonTitle: 'Eliminar del chat',
removeMemberPrompt: ({memberName}: {memberName: string}) => `¿Estás seguro de que deseas eliminar a ${memberName}?`,
removeMemberTitle: 'Eliminar miembro',
transferOwner: 'Transferir la propiedad',
Expand Down
10 changes: 3 additions & 7 deletions src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import type {
ReportDescriptionNavigatorParamList,
ReportDetailsNavigatorParamList,
ReportSettingsNavigatorParamList,
RoomInviteNavigatorParamList,
RoomMembersNavigatorParamList,
SearchAdvancedFiltersParamList,
SearchReportParamList,
Expand Down Expand Up @@ -149,11 +148,9 @@ const ReportParticipantsModalStackNavigator = createModalStackNavigator<Particip
});

const RoomMembersModalStackNavigator = createModalStackNavigator<RoomMembersNavigatorParamList>({
[SCREENS.ROOM_MEMBERS_ROOT]: () => require<ReactComponentModule>('../../../../pages/RoomMembersPage').default,
});

const RoomInviteModalStackNavigator = createModalStackNavigator<RoomInviteNavigatorParamList>({
[SCREENS.ROOM_INVITE_ROOT]: () => require<ReactComponentModule>('../../../../pages/RoomInvitePage').default,
[SCREENS.ROOM_MEMBERS.ROOT]: () => require<ReactComponentModule>('../../../../pages/RoomMembersPage').default,
[SCREENS.ROOM_MEMBERS.INVITE]: () => require<ReactComponentModule>('../../../../pages/RoomInvitePage').default,
[SCREENS.ROOM_MEMBERS.DETAILS]: () => require<ReactComponentModule>('../../../../pages/RoomMemberDetailsPage').default,
});

const NewChatModalStackNavigator = createModalStackNavigator<NewChatNavigatorParamList>({
Expand Down Expand Up @@ -571,7 +568,6 @@ export {
ReportDetailsModalStackNavigator,
ReportParticipantsModalStackNavigator,
ReportSettingsModalStackNavigator,
RoomInviteModalStackNavigator,
RoomMembersModalStackNavigator,
SettingsModalStackNavigator,
SignInModalStackNavigator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) {
name={SCREENS.RIGHT_MODAL.ROOM_MEMBERS}
component={ModalStackNavigators.RoomMembersModalStackNavigator}
/>
<Stack.Screen
name={SCREENS.RIGHT_MODAL.ROOM_INVITE}
component={ModalStackNavigators.RoomInviteModalStackNavigator}
/>
<Stack.Screen
name={SCREENS.RIGHT_MODAL.MONEY_REQUEST}
component={ModalStackNavigators.MoneyRequestModalStackNavigator}
Expand Down
9 changes: 3 additions & 6 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -904,14 +904,11 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[SCREENS.REPORT_PARTICIPANTS.ROLE]: ROUTES.REPORT_PARTICIPANTS_ROLE_SELECTION.route,
},
},
[SCREENS.RIGHT_MODAL.ROOM_INVITE]: {
screens: {
[SCREENS.ROOM_INVITE_ROOT]: ROUTES.ROOM_INVITE.route,
},
},
[SCREENS.RIGHT_MODAL.ROOM_MEMBERS]: {
screens: {
[SCREENS.ROOM_MEMBERS_ROOT]: ROUTES.ROOM_MEMBERS.route,
[SCREENS.ROOM_MEMBERS.ROOT]: ROUTES.ROOM_MEMBERS.route,
[SCREENS.ROOM_MEMBERS.INVITE]: ROUTES.ROOM_INVITE.route,
[SCREENS.ROOM_MEMBERS.DETAILS]: ROUTES.ROOM_MEMBER_DETAILS.route,
},
},
[SCREENS.RIGHT_MODAL.MONEY_REQUEST]: {
Expand Down
13 changes: 6 additions & 7 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -800,14 +800,15 @@ type ParticipantsNavigatorParamList = {
};

type RoomMembersNavigatorParamList = {
[SCREENS.ROOM_MEMBERS_ROOT]: undefined;
};

type RoomInviteNavigatorParamList = {
[SCREENS.ROOM_INVITE_ROOT]: {
[SCREENS.ROOM_MEMBERS.ROOT]: {reportID: string};
[SCREENS.ROOM_MEMBERS.INVITE]: {
reportID: string;
role?: 'accountant';
};
[SCREENS.ROOM_MEMBERS.DETAILS]: {
reportID: string;
accountID: string;
};
};

type MoneyRequestNavigatorParamList = {
Expand Down Expand Up @@ -1112,7 +1113,6 @@ type RightModalNavigatorParamList = {
[SCREENS.RIGHT_MODAL.REPORT_DESCRIPTION]: NavigatorScreenParams<ReportDescriptionNavigatorParamList>;
[SCREENS.RIGHT_MODAL.PARTICIPANTS]: NavigatorScreenParams<ParticipantsNavigatorParamList>;
[SCREENS.RIGHT_MODAL.ROOM_MEMBERS]: NavigatorScreenParams<RoomMembersNavigatorParamList>;
[SCREENS.RIGHT_MODAL.ROOM_INVITE]: NavigatorScreenParams<RoomInviteNavigatorParamList>;
[SCREENS.RIGHT_MODAL.MONEY_REQUEST]: NavigatorScreenParams<MoneyRequestNavigatorParamList>;
[SCREENS.RIGHT_MODAL.NEW_TASK]: NavigatorScreenParams<NewTaskNavigatorParamList>;
[SCREENS.RIGHT_MODAL.TEACHERS_UNITE]: NavigatorScreenParams<TeachersUniteNavigatorParamList>;
Expand Down Expand Up @@ -1410,7 +1410,6 @@ export type {
ReportDetailsNavigatorParamList,
ReportSettingsNavigatorParamList,
RightModalNavigatorParamList,
RoomInviteNavigatorParamList,
RoomMembersNavigatorParamList,
RootStackParamList,
SettingsNavigatorParamList,
Expand Down
16 changes: 14 additions & 2 deletions src/pages/InviteReportParticipantsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import ROUTES from '@src/ROUTES';
import type {InvitedEmailsToAccountIDs, PersonalDetailsList} from '@src/types/onyx';
import type {WithReportOrNotFoundProps} from './home/report/withReportOrNotFound';
import withReportOrNotFound from './home/report/withReportOrNotFound';
import SearchInputManager from './workspace/SearchInputManager';

type InviteReportParticipantsPageOnyxProps = {
/** All of the personal details for everyone */
Expand All @@ -48,6 +49,11 @@ function InviteReportParticipantsPage({betas, personalDetails, report, didScreen
const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState('');
const [selectedOptions, setSelectedOptions] = useState<ReportUtils.OptionData[]>([]);

useEffect(() => {
setSearchTerm(SearchInputManager.searchInput);
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, []);

// Any existing participants and Expensify emails should not be eligible for invitation
const excludedUsers = useMemo(
() => [...PersonalDetailsUtils.getLoginsByAccountIDs(ReportUtils.getParticipantsAccountIDsForDisplay(report, false, true)), ...CONST.EXPENSIFY_EMAILS],
Expand Down Expand Up @@ -200,7 +206,10 @@ function InviteReportParticipantsPage({betas, personalDetails, report, didScreen
<FormAlertWithSubmitButton
isDisabled={!selectedOptions.length}
buttonText={translate('common.invite')}
onSubmit={inviteUsers}
onSubmit={() => {
SearchInputManager.searchInput = '';
inviteUsers();
}}
containerStyles={[styles.flexReset, styles.flexGrow0, styles.flexShrink0, styles.flexBasisAuto]}
enabledWhenOffline
/>
Expand Down Expand Up @@ -228,7 +237,10 @@ function InviteReportParticipantsPage({betas, personalDetails, report, didScreen
ListItem={InviteMemberListItem}
textInputLabel={translate('selectionList.nameEmailOrPhoneNumber')}
textInputValue={searchTerm}
onChangeText={setSearchTerm}
onChangeText={(value) => {
SearchInputManager.searchInput = value;
setSearchTerm(value);
}}
headerMessage={headerMessage}
onSelectRow={toggleOption}
onConfirm={inviteUsers}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/ReportParticipantDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function ReportParticipantDetails({personalDetails, report, route}: ReportPartic
{isCurrentUserAdmin && (
<>
<Button
text={translate('workspace.people.removeMemberGroupButtonTitle')}
text={translate('workspace.people.removeGroupMemberButtonTitle')}
onPress={() => setIsRemoveMemberConfirmModalVisible(true)}
medium
isDisabled={isSelectedMemberCurrentUser}
Expand All @@ -112,7 +112,7 @@ function ReportParticipantDetails({personalDetails, report, route}: ReportPartic
/>
<ConfirmModal
danger
title={translate('workspace.people.removeMemberGroupButtonTitle')}
title={translate('workspace.people.removeGroupMemberButtonTitle')}
isVisible={isRemoveMemberConfirmModalVisible}
onConfirm={removeUser}
onCancel={() => setIsRemoveMemberConfirmModalVisible(false)}
Expand Down
Loading

0 comments on commit 1fcba07

Please sign in to comment.