Skip to content

Commit

Permalink
migrate search page to chat finder page
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgrzybowski committed Apr 11, 2024
1 parent 7d19f82 commit 46b6a09
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 65 deletions.
3 changes: 2 additions & 1 deletion src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,8 @@ const CONST = {
},
TIMING: {
CALCULATE_MOST_RECENT_LAST_MODIFIED_ACTION: 'calc_most_recent_last_modified_action',
SEARCH_RENDER: 'search_render',
// ASK: Should we also update this name?
CHAT_FINDER_RENDER: 'chat_finder',
CHAT_RENDER: 'chat_render',
OPEN_REPORT: 'open_report',
HOMEPAGE_INITIAL_RENDER: 'homepage_initial_render',
Expand Down
2 changes: 1 addition & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const ROUTES = {
route: 'flag/:reportID/:reportActionID',
getRoute: (reportID: string, reportActionID: string) => `flag/${reportID}/${reportActionID}` as const,
},
SEARCH: 'search',
CHAT_FINDER: 'chat-finder',
DETAILS: {
route: 'details',
getRoute: (login: string) => `details?login=${encodeURIComponent(login)}` as const,
Expand Down
4 changes: 2 additions & 2 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const SCREENS = {
ROOT: 'SaveTheWorld_Root',
},
LEFT_MODAL: {
SEARCH: 'Search',
CHAT_FINDER: 'ChatFinder',
WORKSPACE_SWITCHER: 'WorkspaceSwitcher',
},
WORKSPACE_SWITCHER: {
Expand Down Expand Up @@ -312,7 +312,7 @@ const SCREENS = {
REPORT_PARTICIPANTS_ROOT: 'ReportParticipants_Root',
ROOM_MEMBERS_ROOT: 'RoomMembers_Root',
ROOM_INVITE_ROOT: 'RoomInvite_Root',
SEARCH_ROOT: 'Search_Root',
CHAT_FINDER_ROOT: 'ChatFinder_Root',
FLAG_COMMENT_ROOT: 'FlagComment_Root',
REIMBURSEMENT_ACCOUNT: 'ReimbursementAccount',
GET_ASSISTANCE: 'GetAssistance',
Expand Down
3 changes: 2 additions & 1 deletion src/libs/E2E/reactNativeLaunchingTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ if (!appInstanceId) {
// import your test here, define its name and config first in e2e/config.js
const tests: Tests = {
[E2EConfig.TEST_NAMES.AppStartTime]: require('./tests/appStartTimeTest.e2e').default,
[E2EConfig.TEST_NAMES.OpenSearchPage]: require('./tests/openSearchPageTest.e2e').default,
// ASK: Should we also update this name?
[E2EConfig.TEST_NAMES.OpenChatFinderPage]: require('./tests/openChatFinderPageTest.e2e').default,
[E2EConfig.TEST_NAMES.ChatOpening]: require('./tests/chatOpeningTest.e2e').default,
[E2EConfig.TEST_NAMES.ReportTyping]: require('./tests/reportTypingTest.e2e').default,
[E2EConfig.TEST_NAMES.Linking]: require('./tests/linkingTest.e2e').default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ROUTES from '@src/ROUTES';

const test = () => {
// check for login (if already logged in the action will simply resolve)
console.debug('[E2E] Logging in for search');
console.debug('[E2E] Logging in for chat finding');

E2ELogin().then((neededLogin: boolean): Promise<Response> | undefined => {
if (neededLogin) {
Expand All @@ -19,12 +19,12 @@ const test = () => {
);
}

console.debug('[E2E] Logged in, getting search metrics and submitting them…');
console.debug('[E2E] Logged in, getting chat finding metrics and submitting them…');

Performance.subscribeToMeasurements((entry) => {
if (entry.name === CONST.TIMING.SIDEBAR_LOADED) {
console.debug(`[E2E] Sidebar loaded, navigating to search route…`);
Navigation.navigate(ROUTES.SEARCH);
console.debug(`[E2E] Sidebar loaded, navigating to chat finder route…`);
Navigation.navigate(ROUTES.CHAT_FINDER);
return;
}

Expand All @@ -36,7 +36,7 @@ const test = () => {
console.debug(`[E2E] Submitting!`);
E2EClient.submitTestResults({
branch: Config.E2E_BRANCH,
name: 'Open Search Page TTI',
name: 'Open Chat Finder Page TTI',
duration: entry.duration,
})
.then(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
const unsubscribeSearchShortcut = KeyboardShortcut.subscribe(
searchShortcutConfig.shortcutKey,
() => {
Modal.close(Session.checkIfActionIsAllowed(() => Navigation.navigate(ROUTES.SEARCH)));
Modal.close(Session.checkIfActionIsAllowed(() => Navigation.navigate(ROUTES.CHAT_FINDER)));
},
shortcutsOverviewShortcutConfig.descriptionKey,
shortcutsOverviewShortcutConfig.modifiers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {createStackNavigator} from '@react-navigation/stack';
import React from 'react';
import type {
AddPersonalBankAccountNavigatorParamList,
ChatFinderNavigatorParamList,
DetailsNavigatorParamList,
EditRequestNavigatorParamList,
EnablePaymentsNavigatorParamList,
Expand All @@ -22,7 +23,6 @@ import type {
ReportSettingsNavigatorParamList,
RoomInviteNavigatorParamList,
RoomMembersNavigatorParamList,
SearchNavigatorParamList,
SettingsNavigatorParamList,
SignInNavigatorParamList,
SplitDetailsNavigatorParamList,
Expand Down Expand Up @@ -143,8 +143,8 @@ const RoomInviteModalStackNavigator = createModalStackNavigator<RoomInviteNaviga
[SCREENS.ROOM_INVITE_ROOT]: () => require('../../../../pages/RoomInvitePage').default as React.ComponentType,
});

const SearchModalStackNavigator = createModalStackNavigator<SearchNavigatorParamList>({
[SCREENS.SEARCH_ROOT]: () => require('../../../../pages/SearchPage').default as React.ComponentType,
const ChatFinderModalStackNavigator = createModalStackNavigator<ChatFinderNavigatorParamList>({
[SCREENS.CHAT_FINDER_ROOT]: () => require('../../../../pages/ChatFinderPage').default as React.ComponentType,
});

const NewChatModalStackNavigator = createModalStackNavigator<NewChatNavigatorParamList>({
Expand Down Expand Up @@ -338,7 +338,7 @@ export {
ReportDescriptionModalStackNavigator,
RoomInviteModalStackNavigator,
RoomMembersModalStackNavigator,
SearchModalStackNavigator,
ChatFinderModalStackNavigator,
SettingsModalStackNavigator,
SignInModalStackNavigator,
SplitDetailsModalStackNavigator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ function LeftModalNavigator({navigation}: LeftModalNavigatorProps) {
<View style={styles.LHPNavigatorContainer(isSmallScreenWidth)}>
<Stack.Navigator screenOptions={screenOptions}>
<Stack.Screen
name={SCREENS.LEFT_MODAL.SEARCH}
component={ModalStackNavigators.SearchModalStackNavigator}
name={SCREENS.LEFT_MODAL.CHAT_FINDER}
component={ModalStackNavigators.ChatFinderModalStackNavigator}
/>
<Stack.Screen
name={SCREENS.LEFT_MODAL.WORKSPACE_SWITCHER}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function TopBar({policy, session}: TopBarProps) {
<PressableWithoutFeedback
accessibilityLabel={translate('sidebarScreen.buttonSearch')}
style={[styles.flexRow, styles.mr2]}
onPress={Session.checkIfActionIsAllowed(() => Navigation.navigate(ROUTES.SEARCH))}
onPress={Session.checkIfActionIsAllowed(() => Navigation.navigate(ROUTES.CHAT_FINDER))}
>
<Icon
src={Expensicons.MagnifyingGlass}
Expand Down
4 changes: 2 additions & 2 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[SCREENS.NOT_FOUND]: '*',
[NAVIGATORS.LEFT_MODAL_NAVIGATOR]: {
screens: {
[SCREENS.LEFT_MODAL.SEARCH]: {
[SCREENS.LEFT_MODAL.CHAT_FINDER]: {
screens: {
[SCREENS.SEARCH_ROOT]: ROUTES.SEARCH,
[SCREENS.CHAT_FINDER_ROOT]: ROUTES.CHAT_FINDER,
},
},
[SCREENS.LEFT_MODAL.WORKSPACE_SWITCHER]: {
Expand Down
10 changes: 5 additions & 5 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ type NewChatNavigatorParamList = {
[SCREENS.NEW_CHAT.ROOT]: undefined;
};

type SearchNavigatorParamList = {
[SCREENS.SEARCH_ROOT]: undefined;
type ChatFinderNavigatorParamList = {
[SCREENS.CHAT_FINDER_ROOT]: undefined;
};

type DetailsNavigatorParamList = {
Expand Down Expand Up @@ -568,7 +568,7 @@ type PrivateNotesNavigatorParamList = {
};

type LeftModalNavigatorParamList = {
[SCREENS.LEFT_MODAL.SEARCH]: NavigatorScreenParams<SearchNavigatorParamList>;
[SCREENS.LEFT_MODAL.CHAT_FINDER]: NavigatorScreenParams<ChatFinderNavigatorParamList>;
[SCREENS.LEFT_MODAL.WORKSPACE_SWITCHER]: NavigatorScreenParams<WorkspaceSwitcherNavigatorParamList>;
};

Expand Down Expand Up @@ -744,7 +744,7 @@ type AuthScreensParamList = SharedScreensParamList & {
};
};

type RootStackParamList = PublicScreensParamList & AuthScreensParamList & SearchNavigatorParamList;
type RootStackParamList = PublicScreensParamList & AuthScreensParamList & ChatFinderNavigatorParamList;

type BottomTabName = keyof BottomTabNavigatorParamList;

Expand Down Expand Up @@ -788,7 +788,7 @@ export type {
ParticipantsNavigatorParamList,
RoomMembersNavigatorParamList,
RoomInviteNavigatorParamList,
SearchNavigatorParamList,
ChatFinderNavigatorParamList,
NewChatNavigatorParamList,
NewTaskNavigatorParamList,
TeachersUniteNavigatorParamList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ReferralProgramCTA from '@components/ReferralProgramCTA';
import useThemeStyles from '@hooks/useThemeStyles';
import CONST from '@src/CONST';

function SearchPageFooter() {
function ChatFinderPageFooter() {
const themeStyles = useThemeStyles();

return (
Expand All @@ -14,6 +14,6 @@ function SearchPageFooter() {
);
}

SearchPageFooter.displayName = 'SearchPageFooter';
ChatFinderPageFooter.displayName = 'ChatFinderPageFooter';

export default SearchPageFooter;
export default ChatFinderPageFooter;
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,36 @@ import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
import type * as OnyxTypes from '@src/types/onyx';
import SearchPageFooter from './SearchPageFooter';
import ChatFinderPageFooter from './ChatFinderPageFooter';

type SearchPageOnyxProps = {
type ChatFinderPageOnyxProps = {
/** Beta features list */
betas: OnyxEntry<OnyxTypes.Beta[]>;

/** Whether or not we are searching for reports on the server */
isSearchingForReports: OnyxEntry<boolean>;
};

type SearchPageProps = SearchPageOnyxProps & StackScreenProps<RootStackParamList, typeof SCREENS.SEARCH_ROOT>;
type ChatFinderPageProps = ChatFinderPageOnyxProps & StackScreenProps<RootStackParamList, typeof SCREENS.CHAT_FINDER_ROOT>;

type Options = OptionsListUtils.Options & {headerMessage: string};

type SearchPageSectionItem = {
type ChatFinderPageSectionItem = {
data: OptionData[];
shouldShow: boolean;
};

type SearchPageSectionList = SearchPageSectionItem[];
type ChatFinderPageSectionList = ChatFinderPageSectionItem[];

const setPerformanceTimersEnd = () => {
Timing.end(CONST.TIMING.SEARCH_RENDER);
Performance.markEnd(CONST.TIMING.SEARCH_RENDER);
// ASK: Should we also update this name?
Timing.end(CONST.TIMING.CHAT_FINDER_RENDER);
Performance.markEnd(CONST.TIMING.CHAT_FINDER_RENDER);
};

const SearchPageFooterInstance = <SearchPageFooter />;
const ChatFinderPageFooterInstance = <ChatFinderPageFooter />;

function SearchPage({betas, isSearchingForReports, navigation}: SearchPageProps) {
function ChatFinderPage({betas, isSearchingForReports, navigation}: ChatFinderPageProps) {
const [isScreenTransitionEnd, setIsScreenTransitionEnd] = useState(false);
const {translate} = useLocalize();
const {isOffline} = useNetwork();
Expand All @@ -67,8 +68,9 @@ function SearchPage({betas, isSearchingForReports, navigation}: SearchPageProps)
const [searchValue, debouncedSearchValue, setSearchValue] = useDebouncedState('');

useEffect(() => {
Timing.start(CONST.TIMING.SEARCH_RENDER);
Performance.markStart(CONST.TIMING.SEARCH_RENDER);
// ASK: Should we also update this name?
Timing.start(CONST.TIMING.CHAT_FINDER_RENDER);
Performance.markStart(CONST.TIMING.CHAT_FINDER_RENDER);
}, []);

useEffect(() => {
Expand Down Expand Up @@ -115,8 +117,8 @@ function SearchPage({betas, isSearchingForReports, navigation}: SearchPageProps)

const {recentReports, personalDetails: localPersonalDetails, userToInvite, headerMessage} = debouncedSearchValue.trim() !== '' ? filteredOptions : searchOptions;

const sections = useMemo((): SearchPageSectionList => {
const newSections: SearchPageSectionList = [];
const sections = useMemo((): ChatFinderPageSectionList => {
const newSections: ChatFinderPageSectionList = [];

if (recentReports?.length > 0) {
newSections.push({
Expand Down Expand Up @@ -162,14 +164,15 @@ function SearchPage({betas, isSearchingForReports, navigation}: SearchPageProps)
return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
testID={SearchPage.displayName}
testID={ChatFinderPage.displayName}
onEntryTransitionEnd={handleScreenTransitionEnd}
shouldEnableMaxHeight
navigation={navigation}
>
{({safeAreaPaddingBottomStyle}) => (
<>
<HeaderWithBackButton
// ASK: What text do we want to use for the title?
title={translate('common.search')}
onBackButtonPress={Navigation.goBack}
/>
Expand All @@ -186,7 +189,7 @@ function SearchPage({betas, isSearchingForReports, navigation}: SearchPageProps)
onLayout={setPerformanceTimersEnd}
onSelectRow={selectReport}
showLoadingPlaceholder={!areOptionsInitialized}
footerContent={SearchPageFooterInstance}
footerContent={ChatFinderPageFooterInstance}
isLoadingNewOptions={isSearchingForReports ?? undefined}
/>
</View>
Expand All @@ -196,14 +199,14 @@ function SearchPage({betas, isSearchingForReports, navigation}: SearchPageProps)
);
}

SearchPage.displayName = 'SearchPage';
ChatFinderPage.displayName = 'ChatFinderPage';

export default withOnyx<SearchPageProps, SearchPageOnyxProps>({
export default withOnyx<ChatFinderPageProps, ChatFinderPageOnyxProps>({
betas: {
key: ONYXKEYS.BETAS,
},
isSearchingForReports: {
key: ONYXKEYS.IS_SEARCHING_FOR_REPORTS,
initWithStoredValues: false,
},
})(SearchPage);
})(ChatFinderPage);
7 changes: 4 additions & 3 deletions tests/e2e/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const OUTPUT_DIR = process.env.WORKING_DIRECTORY || './tests/e2e/results';
// add your test name here …
const TEST_NAMES = {
AppStartTime: 'App start time',
OpenSearchPage: 'Open search page TTI',
// ASK: Should we also update this name?
OpenChatFinderPage: 'Open chat finder page TTI',
ReportTyping: 'Report typing',
ChatOpening: 'Chat opening',
Linking: 'Linking',
Expand Down Expand Up @@ -71,8 +72,8 @@ export default {

// ... any additional config you might need
},
[TEST_NAMES.OpenSearchPage]: {
name: TEST_NAMES.OpenSearchPage,
[TEST_NAMES.OpenChatFinderPage]: {
name: TEST_NAMES.OpenChatFinderPage,
},
// TODO: Fix text and enable again
// [TEST_NAMES.ReportTyping]: {
Expand Down
Loading

0 comments on commit 46b6a09

Please sign in to comment.