diff --git a/src/ROUTES.ts b/src/ROUTES.ts index ed6e1cd3ce38..575de486d5a5 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -276,13 +276,9 @@ const ROUTES = { route: 'r/:reportID/settings', getRoute: (reportID: string) => `r/${reportID}/settings` as const, }, - REPORT_SETTINGS_ROOM_NAME: { - route: 'r/:reportID/settings/room-name', - getRoute: (reportID: string) => `r/${reportID}/settings/room-name` as const, - }, - REPORT_SETTINGS_GROUP_NAME: { - route: 'r/:reportID/settings/group-name', - getRoute: (reportID: string) => `r/${reportID}/settings/group-name` as const, + REPORT_SETTINGS_NAME: { + route: 'r/:reportID/settings/name', + getRoute: (reportID: string) => `r/${reportID}/settings/name` as const, }, REPORT_SETTINGS_NOTIFICATION_PREFERENCES: { route: 'r/:reportID/settings/notification-preferences', diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 4e7243d0eb2c..3fe08e680f46 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -188,8 +188,7 @@ const SCREENS = { REPORT_SETTINGS: { ROOT: 'Report_Settings_Root', - ROOM_NAME: 'Report_Settings_Room_Name', - GROUP_NAME: 'Report_Settings_Group_Name', + NAME: 'Report_Settings_Name', NOTIFICATION_PREFERENCES: 'Report_Settings_Notification_Preferences', WRITE_CAPABILITY: 'Report_Settings_Write_Capability', VISIBILITY: 'Report_Settings_Visibility', diff --git a/src/components/TextInput/BaseTextInput/index.tsx b/src/components/TextInput/BaseTextInput/index.tsx index 692e3e4eef78..e1862e0a6737 100644 --- a/src/components/TextInput/BaseTextInput/index.tsx +++ b/src/components/TextInput/BaseTextInput/index.tsx @@ -399,7 +399,7 @@ function BaseTextInput( defaultValue={defaultValue} markdownStyle={markdownStyle} /> - {isFocused && !isReadOnly && shouldShowClearButton && value && setValue('')} />} + {isFocused && !isReadOnly && shouldShowClearButton && !!value && setValue('')} />} {inputProps.isLoading && ( )} - {!inputProps.secureTextEntry && icon && ( + {!inputProps.secureTextEntry && !!icon && ( ({ [SCREENS.REPORT_SETTINGS.ROOT]: () => require('../../../../pages/settings/Report/ReportSettingsPage').default as React.ComponentType, - [SCREENS.REPORT_SETTINGS.ROOM_NAME]: () => require('../../../../pages/settings/Report/RoomNamePage').default as React.ComponentType, - [SCREENS.REPORT_SETTINGS.GROUP_NAME]: () => require('../../../../pages/GroupChatNameEditPage').default as React.ComponentType, + [SCREENS.REPORT_SETTINGS.NAME]: () => require('../../../../pages/settings/Report/NamePage').default as React.ComponentType, [SCREENS.REPORT_SETTINGS.NOTIFICATION_PREFERENCES]: () => require('../../../../pages/settings/Report/NotificationPreferencePage').default as React.ComponentType, [SCREENS.REPORT_SETTINGS.WRITE_CAPABILITY]: () => require('../../../../pages/settings/Report/WriteCapabilityPage').default as React.ComponentType, [SCREENS.REPORT_SETTINGS.VISIBILITY]: () => require('../../../../pages/settings/Report/VisibilityPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index e9b86993ad43..8ec58e6a7d3e 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -518,11 +518,8 @@ const config: LinkingOptions['config'] = { [SCREENS.REPORT_SETTINGS.ROOT]: { path: ROUTES.REPORT_SETTINGS.route, }, - [SCREENS.REPORT_SETTINGS.ROOM_NAME]: { - path: ROUTES.REPORT_SETTINGS_ROOM_NAME.route, - }, - [SCREENS.REPORT_SETTINGS.GROUP_NAME]: { - path: ROUTES.REPORT_SETTINGS_GROUP_NAME.route, + [SCREENS.REPORT_SETTINGS.NAME]: { + path: ROUTES.REPORT_SETTINGS_NAME.route, }, [SCREENS.REPORT_SETTINGS.NOTIFICATION_PREFERENCES]: { path: ROUTES.REPORT_SETTINGS_NOTIFICATION_PREFERENCES.route, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 7f597e4d2210..2ea966068818 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -397,9 +397,7 @@ type SettingsNavigatorParamList = { type NewChatNavigatorParamList = { [SCREENS.NEW_CHAT.ROOT]: undefined; - [SCREENS.NEW_CHAT.NEW_CHAT_EDIT_NAME]: { - reportID?: string; - }; + [SCREENS.NEW_CHAT.NEW_CHAT_EDIT_NAME]: undefined; }; type DetailsNavigatorParamList = { @@ -425,11 +423,10 @@ type ReportDetailsNavigatorParamList = { }; type ReportSettingsNavigatorParamList = { - [SCREENS.REPORT_SETTINGS.ROOT]: undefined; - [SCREENS.REPORT_SETTINGS.ROOM_NAME]: undefined; - [SCREENS.REPORT_SETTINGS.GROUP_NAME]: undefined; - [SCREENS.REPORT_SETTINGS.NOTIFICATION_PREFERENCES]: undefined; - [SCREENS.REPORT_SETTINGS.WRITE_CAPABILITY]: undefined; + [SCREENS.REPORT_SETTINGS.ROOT]: {reportID: string}; + [SCREENS.REPORT_SETTINGS.NAME]: {reportID: string}; + [SCREENS.REPORT_SETTINGS.NOTIFICATION_PREFERENCES]: {reportID: string}; + [SCREENS.REPORT_SETTINGS.WRITE_CAPABILITY]: {reportID: string}; [SCREENS.REPORT_SETTINGS.VISIBILITY]: { reportID: string; }; diff --git a/src/pages/GroupChatNameEditPage.tsx b/src/pages/GroupChatNameEditPage.tsx index 87218fbb89cd..b3e5e9bb119c 100644 --- a/src/pages/GroupChatNameEditPage.tsx +++ b/src/pages/GroupChatNameEditPage.tsx @@ -11,15 +11,16 @@ import useAutoFocusInput from '@hooks/useAutoFocusInput'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; +import type {NewChatNavigatorParamList} from '@libs/Navigation/types'; import * as ReportUtils from '@libs/ReportUtils'; import * as ValidationUtils from '@libs/ValidationUtils'; -import type {NewChatNavigatorParamList} from '@navigation/types'; import * as Report from '@userActions/Report'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import INPUT_IDS from '@src/types/form/NewChatNameForm'; +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'; @@ -27,11 +28,14 @@ type GroupChatNameEditPageOnyxProps = { groupChatDraft: NewGroupChatDraft | null; }; -type GroupChatNameEditPageProps = StackScreenProps & GroupChatNameEditPageOnyxProps; +type GroupChatNameEditPageProps = GroupChatNameEditPageOnyxProps & + Partial> & { + report?: ReportOnyxType; + }; -function GroupChatNameEditPage({groupChatDraft, route}: GroupChatNameEditPageProps) { - // If we have a reportID this means we are using this page to update an existing Group Chat name - const reportID = route.params?.reportID ?? ''; +function GroupChatNameEditPage({groupChatDraft, report}: GroupChatNameEditPageProps) { + // If we have a report this means we are using this page to update an existing Group Chat name + const reportID = report?.reportID ?? ''; const isUpdatingExistingReport = Boolean(reportID); const styles = useThemeStyles(); diff --git a/src/pages/settings/Report/NamePage.tsx b/src/pages/settings/Report/NamePage.tsx new file mode 100644 index 000000000000..de73e59bb7da --- /dev/null +++ b/src/pages/settings/Report/NamePage.tsx @@ -0,0 +1,22 @@ +import type {StackScreenProps} from '@react-navigation/stack'; +import React from 'react'; +import * as ReportUtils from '@libs/ReportUtils'; +import type {ReportSettingsNavigatorParamList} from '@navigation/types'; +import GroupChatNameEditPage from '@pages/GroupChatNameEditPage'; +import withReportOrNotFound from '@pages/home/report/withReportOrNotFound'; +import type {WithReportOrNotFoundProps} from '@pages/home/report/withReportOrNotFound'; +import type SCREENS from '@src/SCREENS'; +import RoomNamePage from './RoomNamePage'; + +type NamePageProps = WithReportOrNotFoundProps & StackScreenProps; + +function NamePage({report}: NamePageProps) { + if (ReportUtils.isGroupChat(report)) { + return ; + } + return ; +} + +NamePage.displayName = 'NamePage'; + +export default withReportOrNotFound()(NamePage); diff --git a/src/pages/settings/Report/ReportSettingsPage.tsx b/src/pages/settings/Report/ReportSettingsPage.tsx index aabd8d2fe376..132ae06d4867 100644 --- a/src/pages/settings/Report/ReportSettingsPage.tsx +++ b/src/pages/settings/Report/ReportSettingsPage.tsx @@ -96,11 +96,7 @@ function ReportSettingsPage({report, policies}: ReportSettingsPageProps) { shouldShowRightIcon title={report?.reportName === '' ? reportName : report?.reportName} description={isGroupChat ? translate('common.name') : translate('newRoomPage.roomName')} - onPress={() => - isGroupChat - ? Navigation.navigate(ROUTES.REPORT_SETTINGS_GROUP_NAME.getRoute(reportID)) - : Navigation.navigate(ROUTES.REPORT_SETTINGS_ROOM_NAME.getRoute(reportID)) - } + onPress={() => Navigation.navigate(ROUTES.REPORT_SETTINGS_NAME.getRoute(reportID))} /> )} diff --git a/src/pages/settings/Report/RoomNamePage.tsx b/src/pages/settings/Report/RoomNamePage.tsx index 5ba85961e5ba..13c853674b4b 100644 --- a/src/pages/settings/Report/RoomNamePage.tsx +++ b/src/pages/settings/Report/RoomNamePage.tsx @@ -1,5 +1,4 @@ import {useIsFocused} from '@react-navigation/native'; -import type {StackScreenProps} from '@react-navigation/stack'; import React, {useCallback, useRef} from 'react'; import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; @@ -18,14 +17,10 @@ import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import * as ReportUtils from '@libs/ReportUtils'; import * as ValidationUtils from '@libs/ValidationUtils'; -import type {ReportSettingsNavigatorParamList} from '@navigation/types'; -import withReportOrNotFound from '@pages/home/report/withReportOrNotFound'; -import type {WithReportOrNotFoundProps} from '@pages/home/report/withReportOrNotFound'; import * as ReportActions from '@userActions/Report'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import type SCREENS from '@src/SCREENS'; import INPUT_IDS from '@src/types/form/RoomNameForm'; import type {Policy, Report} from '@src/types/onyx'; @@ -37,7 +32,9 @@ type RoomNamePageOnyxProps = { policy: OnyxEntry; }; -type RoomNamePageProps = RoomNamePageOnyxProps & WithReportOrNotFoundProps & StackScreenProps; +type RoomNamePageProps = RoomNamePageOnyxProps & { + report: Report; +}; function RoomNamePage({report, policy, reports}: RoomNamePageProps) { const styles = useThemeStyles(); @@ -111,13 +108,11 @@ function RoomNamePage({report, policy, reports}: RoomNamePageProps) { RoomNamePage.displayName = 'RoomNamePage'; -export default withReportOrNotFound()( - withOnyx({ - reports: { - key: ONYXKEYS.COLLECTION.REPORT, - }, - policy: { - key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`, - }, - })(RoomNamePage), -); +export default withOnyx({ + reports: { + key: ONYXKEYS.COLLECTION.REPORT, + }, + policy: { + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`, + }, +})(RoomNamePage);