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

Add trip room check to disable rename functionality #54964

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
4 changes: 1 addition & 3 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1692,9 +1692,6 @@ const translations = {
roomDescriptionOptional: 'Room description (optional)',
explainerText: 'Set a custom description for the room.',
},
groupConfirmPage: {
groupName: 'Group name',
},
groupChat: {
lastMemberTitle: 'Heads up!',
lastMemberWarning: "Since you're the last person here, leaving will make this chat inaccessible to all members. Are you sure you want to leave?",
Expand Down Expand Up @@ -4562,6 +4559,7 @@ const translations = {
},
newRoomPage: {
newRoom: 'New room',
groupName: 'Group name',
roomName: 'Room name',
visibility: 'Visibility',
restrictedDescription: 'People in your workspace can find this room',
Expand Down
4 changes: 1 addition & 3 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1695,9 +1695,6 @@ const translations = {
roomDescriptionOptional: 'Descripción de la sala de chat (opcional)',
explainerText: 'Establece una descripción personalizada para la sala de chat.',
},
groupConfirmPage: {
groupName: 'Nombre del grupo',
},
groupChat: {
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?',
Expand Down Expand Up @@ -4609,6 +4606,7 @@ const translations = {
},
newRoomPage: {
newRoom: 'Nueva sala de chat',
groupName: 'Nombre del grupo',
roomName: 'Nombre de la sala',
visibility: 'Visibilidad',
restrictedDescription: 'Sólo las personas en tu espacio de trabajo pueden encontrar esta sala',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ const RoomMembersModalStackNavigator = createModalStackNavigator<RoomMembersNavi
const NewChatModalStackNavigator = createModalStackNavigator<NewChatNavigatorParamList>({
[SCREENS.NEW_CHAT.ROOT]: () => require<ReactComponentModule>('../../../../pages/NewChatSelectorPage').default,
[SCREENS.NEW_CHAT.NEW_CHAT_CONFIRM]: () => require<ReactComponentModule>('../../../../pages/NewChatConfirmPage').default,
[SCREENS.NEW_CHAT.NEW_CHAT_EDIT_NAME]: () => require<ReactComponentModule>('../../../../pages/GroupChatNameEditPage').default,
[SCREENS.NEW_CHAT.NEW_CHAT_EDIT_NAME]: () => require<ReactComponentModule>('../../../../pages/ChatNameEditPage').default,
});

const NewTaskModalStackNavigator = createModalStackNavigator<NewTaskNavigatorParamList>({
Expand Down
3 changes: 2 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7471,7 +7471,8 @@ function shouldDisableRename(report: OnyxEntry<Report>): boolean {
isPolicyExpenseChat(report) ||
isInvoiceRoom(report) ||
isInvoiceReport(report) ||
isSystemChat(report)
isSystemChat(report) ||
isTripRoom(report)
) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {useCallback, useMemo} from 'react';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import {useOnyx, withOnyx} from 'react-native-onyx';
import FormProvider from '@components/Form/FormProvider';
import InputWrapper from '@components/Form/InputWrapper';
import type {FormOnyxValues} from '@components/Form/types';
Expand All @@ -25,20 +25,18 @@ import type {Report as ReportOnyxType} from '@src/types/onyx';
import type NewGroupChatDraft from '@src/types/onyx/NewGroupChatDraft';
import type {Errors} from '@src/types/onyx/OnyxCommon';

type GroupChatNameEditPageOnyxProps = {
groupChatDraft: OnyxEntry<NewGroupChatDraft>;
type ChatNameEditPageProps = Partial<PlatformStackScreenProps<NewChatNavigatorParamList, typeof SCREENS.NEW_CHAT.NEW_CHAT_EDIT_NAME>> & {
report?: ReportOnyxType;
};

type GroupChatNameEditPageProps = GroupChatNameEditPageOnyxProps &
Partial<PlatformStackScreenProps<NewChatNavigatorParamList, typeof SCREENS.NEW_CHAT.NEW_CHAT_EDIT_NAME>> & {
report?: ReportOnyxType;
};
function ChatNameEditPage({report}: ChatNameEditPageProps) {
const [groupChatDraft] = useOnyx(ONYXKEYS.NEW_GROUP_CHAT_DRAFT);

function GroupChatNameEditPage({groupChatDraft, report}: GroupChatNameEditPageProps) {
// If we have a report this means we are using this page to update an existing Group Chat name
// In this case its better to use empty string as the reportID if there is no reportID
const reportID = report?.reportID ?? '';
const isUpdatingExistingReport = !!reportID;
const isTripRoom = ReportUtils.isTripRoom(report);

const styles = useThemeStyles();
const {translate} = useLocalize();
Expand Down Expand Up @@ -84,11 +82,11 @@ function GroupChatNameEditPage({groupChatDraft, report}: GroupChatNameEditPagePr
<ScreenWrapper
includeSafeAreaPaddingBottom
style={[styles.defaultModalContainer]}
testID={GroupChatNameEditPage.displayName}
testID={ChatNameEditPage.displayName}
shouldEnableMaxHeight
>
<HeaderWithBackButton
title={translate('groupConfirmPage.groupName')}
title={translate(isTripRoom ? 'newRoomPage.roomName' : 'newRoomPage.groupName')}
onBackButtonPress={() => Navigation.goBack(isUpdatingExistingReport ? ROUTES.REPORT_WITH_ID_DETAILS.getRoute(reportID) : ROUTES.NEW_CHAT_CONFIRM)}
/>
<FormProvider
Expand All @@ -115,10 +113,6 @@ function GroupChatNameEditPage({groupChatDraft, report}: GroupChatNameEditPagePr
);
}

GroupChatNameEditPage.displayName = 'GroupChatNameEditPage';
ChatNameEditPage.displayName = 'ChatNameEditPage';

export default withOnyx<GroupChatNameEditPageProps, GroupChatNameEditPageOnyxProps>({
groupChatDraft: {
key: ONYXKEYS.NEW_GROUP_CHAT_DRAFT,
},
})(GroupChatNameEditPage);
export default ChatNameEditPage;
2 changes: 1 addition & 1 deletion src/pages/NewChatConfirmPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function NewChatConfirmPage({newGroupDraft, allPersonalDetails}: NewChatConfirmP
onPress={navigateToEditChatName}
shouldShowRightIcon
shouldCheckActionAllowedOnPress={false}
description={translate('groupConfirmPage.groupName')}
description={translate('newRoomPage.groupName')}
wrapperStyle={[styles.ph4]}
/>
<View style={[styles.flex1, styles.mt3]}>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,11 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
? chatRoomSubtitle
: `${translate('threads.in')} ${chatRoomSubtitle}`;

let roomDescription;
let roomDescription: string | undefined;
if (caseID === CASES.MONEY_REQUEST) {
roomDescription = translate('common.name');
} else if (isGroupChat) {
roomDescription = translate('groupConfirmPage.groupName');
roomDescription = translate('newRoomPage.groupName');
} else {
roomDescription = translate('newRoomPage.roomName');
}
Expand Down
7 changes: 4 additions & 3 deletions src/pages/settings/Report/NamePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import * as ReportUtils from '@libs/ReportUtils';
import type {ReportSettingsNavigatorParamList} from '@navigation/types';
import GroupChatNameEditPage from '@pages/GroupChatNameEditPage';
import ChatNameEditPage from '@pages/ChatNameEditPage';
import withReportOrNotFound from '@pages/home/report/withReportOrNotFound';
import type {WithReportOrNotFoundProps} from '@pages/home/report/withReportOrNotFound';
import type SCREENS from '@src/SCREENS';
Expand All @@ -11,9 +11,10 @@ import RoomNamePage from './RoomNamePage';
type NamePageProps = WithReportOrNotFoundProps & PlatformStackScreenProps<ReportSettingsNavigatorParamList, typeof SCREENS.REPORT_SETTINGS.NAME>;

function NamePage({report}: NamePageProps) {
if (ReportUtils.isGroupChat(report)) {
return <GroupChatNameEditPage report={report} />;
if (ReportUtils.isGroupChat(report) || ReportUtils.isTripRoom(report)) {
return <ChatNameEditPage report={report} />;
}

return <RoomNamePage report={report} />;
}

Expand Down
Loading