Skip to content

Commit 5a9e3d4

Browse files
luacmartinsOSBotify
authored andcommitted
Merge pull request #61955 from Expensify/francois-revert-58608
Revert "Merge pull request #58608 from nyomanjyotisa/issue-58383" (cherry picked from commit 6569995) (cherry-picked to staging by francoisl)
1 parent 56e39a3 commit 5a9e3d4

File tree

15 files changed

+110
-267
lines changed

15 files changed

+110
-267
lines changed

src/Expensify.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import FocusModeNotification from './components/FocusModeNotification';
1111
import GrowlNotification from './components/GrowlNotification';
1212
import AppleAuthWrapper from './components/SignInButtons/AppleAuthWrapper';
1313
import SplashScreenHider from './components/SplashScreenHider';
14+
import TestToolsModal from './components/TestToolsModal';
1415
import UpdateAppModal from './components/UpdateAppModal';
1516
import CONFIG from './CONFIG';
1617
import CONST from './CONST';
@@ -305,6 +306,7 @@ function Expensify() {
305306
/>
306307
)}
307308
{shouldHideSplash && <SplashScreenHider onHide={onSplashHide} />}
309+
<TestToolsModal />
308310
</DeeplinkWrapper>
309311
);
310312
}

src/NAVIGATORS.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ export default {
1919
SEARCH_FULLSCREEN_NAVIGATOR: 'SearchFullscreenNavigator',
2020
SHARE_MODAL_NAVIGATOR: 'ShareModalNavigator',
2121
PUBLIC_RIGHT_MODAL_NAVIGATOR: 'PublicRightModalNavigator',
22-
TEST_TOOLS_MODAL_NAVIGATOR: 'TestToolsModalNavigator',
2322
} as const;

src/ROUTES.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,8 +1985,6 @@ const ROUTES = {
19851985
},
19861986
MIGRATED_USER_WELCOME_MODAL: 'onboarding/migrated-user-welcome',
19871987

1988-
TEST_TOOLS_MODAL: 'test-tools',
1989-
19901988
TRANSACTION_RECEIPT: {
19911989
route: 'r/:reportID/transaction/:transactionID/receipt/:action?/:iouType?',
19921990
getRoute: (reportID: string | undefined, transactionID: string | undefined, readonly = false, isFromReviewDuplicates = false, action?: IOUAction, iouType?: IOUType) => {

src/SCREENS.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -673,10 +673,6 @@ const SCREENS = {
673673
ROOT: 'TestDrive_Demo_Root',
674674
},
675675

676-
TEST_TOOLS_MODAL: {
677-
ROOT: 'TestToolsModal_Root',
678-
},
679-
680676
I_KNOW_A_TEACHER: 'I_Know_A_Teacher',
681677
INTRO_SCHOOL_PRINCIPAL: 'Intro_School_Principal',
682678
I_AM_A_TEACHER: 'I_Am_A_Teacher',

src/components/Search/SearchRouter/SearchRouterContext.tsx

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {useContext, useEffect, useMemo, useRef, useState} from 'react';
1+
import React, {useContext, useMemo, useRef, useState} from 'react';
22
import type {AnimatedTextInputRef} from '@components/RNTextInput';
33
import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute';
44
import {navigationRef} from '@libs/Navigation/Navigation';
@@ -16,10 +16,6 @@ type SearchRouterContext = {
1616
unregisterSearchPageInput: () => void;
1717
};
1818

19-
type HistoryState = {
20-
isSearchModalOpen?: boolean;
21-
};
22-
2319
const defaultSearchContext: SearchRouterContext = {
2420
isSearchRouterDisplayed: false,
2521
openSearchRouter: () => {},
@@ -31,43 +27,17 @@ const defaultSearchContext: SearchRouterContext = {
3127

3228
const Context = React.createContext<SearchRouterContext>(defaultSearchContext);
3329

34-
const supportsHistoryAPI = typeof window !== 'undefined' && typeof window.history !== 'undefined';
35-
const canListenPopState = typeof window !== 'undefined' && typeof window.addEventListener === 'function';
36-
3730
function SearchRouterContextProvider({children}: ChildrenProps) {
3831
const [isSearchRouterDisplayed, setIsSearchRouterDisplayed] = useState(false);
3932
const searchRouterDisplayedRef = useRef(false);
4033
const searchPageInputRef = useRef<AnimatedTextInputRef | undefined>(undefined);
4134

42-
useEffect(() => {
43-
if (!canListenPopState) {
44-
return;
45-
}
46-
47-
const handlePopState = (event: PopStateEvent) => {
48-
const state = event.state as HistoryState | null;
49-
if (state?.isSearchModalOpen) {
50-
setIsSearchRouterDisplayed(true);
51-
searchRouterDisplayedRef.current = true;
52-
} else {
53-
setIsSearchRouterDisplayed(false);
54-
searchRouterDisplayedRef.current = false;
55-
}
56-
};
57-
58-
window.addEventListener('popstate', handlePopState);
59-
return () => window.removeEventListener('popstate', handlePopState);
60-
}, []);
61-
6235
const routerContext = useMemo(() => {
6336
const openSearchRouter = () => {
6437
close(
6538
() => {
6639
setIsSearchRouterDisplayed(true);
6740
searchRouterDisplayedRef.current = true;
68-
if (supportsHistoryAPI) {
69-
window.history.pushState({isSearchModalOpen: true} satisfies HistoryState, '');
70-
}
7141
},
7242
false,
7343
true,
@@ -76,12 +46,6 @@ function SearchRouterContextProvider({children}: ChildrenProps) {
7646
const closeSearchRouter = () => {
7747
setIsSearchRouterDisplayed(false);
7848
searchRouterDisplayedRef.current = false;
79-
if (supportsHistoryAPI) {
80-
const state = window.history.state as HistoryState | null;
81-
if (state?.isSearchModalOpen) {
82-
window.history.back();
83-
}
84-
}
8549
};
8650

8751
// There are callbacks that live outside of React render-loop and interact with SearchRouter

src/components/Search/SearchRouter/SearchRouterModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
66
import useThemeStyles from '@hooks/useThemeStyles';
77
import useViewportOffsetTop from '@hooks/useViewportOffsetTop';
88
import useWindowDimensions from '@hooks/useWindowDimensions';
9-
import {isMobileIOS} from '@libs/Browser';
9+
import {isMobileChrome, isMobileIOS} from '@libs/Browser';
1010
import CONST from '@src/CONST';
1111
import SearchRouter from './SearchRouter';
1212
import {useSearchRouterContext} from './SearchRouterContext';
@@ -34,6 +34,7 @@ function SearchRouterModal() {
3434
fullscreen
3535
propagateSwipe
3636
swipeDirection={shouldUseNarrowLayout ? CONST.SWIPE_DIRECTION.RIGHT : undefined}
37+
shouldHandleNavigationBack={isMobileChrome()}
3738
onClose={closeSearchRouter}
3839
onModalHide={() => setShouldHideInputCaret(isMobileWebIOS)}
3940
onModalShow={() => setShouldHideInputCaret(false)}

src/components/TestToolsModal.tsx

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import React from 'react';
2+
import {useOnyx} from 'react-native-onyx';
3+
import useIsAuthenticated from '@hooks/useIsAuthenticated';
4+
import useLocalize from '@hooks/useLocalize';
5+
import useResponsiveLayout from '@hooks/useResponsiveLayout';
6+
import useStyleUtils from '@hooks/useStyleUtils';
7+
import useThemeStyles from '@hooks/useThemeStyles';
8+
import useWindowDimensions from '@hooks/useWindowDimensions';
9+
import Navigation from '@navigation/Navigation';
10+
import toggleTestToolsModal, {shouldShowProfileTool} from '@userActions/TestTool';
11+
import CONST from '@src/CONST';
12+
import ONYXKEYS from '@src/ONYXKEYS';
13+
import ROUTES from '@src/ROUTES';
14+
import Button from './Button';
15+
import ClientSideLoggingToolMenu from './ClientSideLoggingToolMenu';
16+
import Modal from './Modal';
17+
import ProfilingToolMenu from './ProfilingToolMenu';
18+
import ScrollView from './ScrollView';
19+
import TestToolMenu from './TestToolMenu';
20+
import TestToolRow from './TestToolRow';
21+
import Text from './Text';
22+
23+
function getRouteBasedOnAuthStatus(isAuthenticated: boolean, activeRoute: string) {
24+
return isAuthenticated ? ROUTES.SETTINGS_CONSOLE.getRoute(activeRoute) : ROUTES.PUBLIC_CONSOLE_DEBUG.getRoute(activeRoute);
25+
}
26+
27+
const modalContentMaxHeightPercentage = 0.75;
28+
29+
function TestToolsModal() {
30+
const {shouldUseNarrowLayout} = useResponsiveLayout();
31+
const [isTestToolsModalOpen = false] = useOnyx(ONYXKEYS.IS_TEST_TOOLS_MODAL_OPEN);
32+
const [shouldStoreLogs = false] = useOnyx(ONYXKEYS.SHOULD_STORE_LOGS);
33+
const {windowWidth, windowHeight} = useWindowDimensions();
34+
const StyleUtils = useStyleUtils();
35+
const styles = useThemeStyles();
36+
const {translate} = useLocalize();
37+
const activeRoute = Navigation.getActiveRoute();
38+
const isAuthenticated = useIsAuthenticated();
39+
const route = getRouteBasedOnAuthStatus(isAuthenticated, activeRoute);
40+
41+
if (!isTestToolsModalOpen) {
42+
return null;
43+
}
44+
45+
return (
46+
<Modal
47+
isVisible={!!isTestToolsModalOpen}
48+
type={shouldUseNarrowLayout ? CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED : CONST.MODAL.MODAL_TYPE.CENTERED_SMALL}
49+
onClose={toggleTestToolsModal}
50+
innerContainerStyle={styles.overflowHidden}
51+
>
52+
<ScrollView
53+
contentContainerStyle={[StyleUtils.getTestToolsModalStyle(windowWidth), shouldUseNarrowLayout && {...styles.w100, ...styles.pv0}]}
54+
style={{maxHeight: windowHeight * modalContentMaxHeightPercentage}}
55+
>
56+
<Text
57+
style={[styles.textLabelSupporting, styles.mt4, styles.mb3]}
58+
numberOfLines={1}
59+
>
60+
{translate('initialSettingsPage.troubleshoot.releaseOptions')}
61+
</Text>
62+
{shouldShowProfileTool() && <ProfilingToolMenu />}
63+
<ClientSideLoggingToolMenu />
64+
{!!shouldStoreLogs && (
65+
<TestToolRow title={translate('initialSettingsPage.troubleshoot.debugConsole')}>
66+
<Button
67+
small
68+
text={translate('initialSettingsPage.debugConsole.viewConsole')}
69+
onPress={() => {
70+
toggleTestToolsModal();
71+
Navigation.navigate(route);
72+
}}
73+
/>
74+
</TestToolRow>
75+
)}
76+
<TestToolMenu />
77+
</ScrollView>
78+
</Modal>
79+
);
80+
}
81+
82+
TestToolsModal.displayName = 'TestToolsModal';
83+
84+
export default TestToolsModal;

src/components/TestToolsModalPage.tsx

Lines changed: 0 additions & 67 deletions
This file was deleted.

src/libs/Navigation/AppNavigator/AuthScreens.tsx

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'
1515
import useOnboardingFlowRouter from '@hooks/useOnboardingFlow';
1616
import useResponsiveLayout from '@hooks/useResponsiveLayout';
1717
import {SidebarOrderedReportsContextProvider} from '@hooks/useSidebarOrderedReports';
18-
import useStyleUtils from '@hooks/useStyleUtils';
1918
import useTheme from '@hooks/useTheme';
2019
import {connect} from '@libs/actions/Delegate';
2120
import setFullscreenVisibility from '@libs/actions/setFullscreenVisibility';
@@ -27,7 +26,7 @@ import Log from '@libs/Log';
2726
import NavBarManager from '@libs/NavBarManager';
2827
import getCurrentUrl from '@libs/Navigation/currentUrl';
2928
import Navigation from '@libs/Navigation/Navigation';
30-
import Animations, {InternalPlatformAnimations} from '@libs/Navigation/PlatformStackNavigation/navigationOptions/animation';
29+
import Animations from '@libs/Navigation/PlatformStackNavigation/navigationOptions/animation';
3130
import Presentation from '@libs/Navigation/PlatformStackNavigation/navigationOptions/presentation';
3231
import type {AuthScreensParamList} from '@libs/Navigation/types';
3332
import NetworkConnection from '@libs/NetworkConnection';
@@ -70,7 +69,6 @@ import MigratedUserWelcomeModalNavigator from './Navigators/MigratedUserWelcomeM
7069
import OnboardingModalNavigator from './Navigators/OnboardingModalNavigator';
7170
import RightModalNavigator from './Navigators/RightModalNavigator';
7271
import TestDriveModalNavigator from './Navigators/TestDriveModalNavigator';
73-
import TestToolsModalNavigator from './Navigators/TestToolsModalNavigator';
7472
import WelcomeVideoModalNavigator from './Navigators/WelcomeVideoModalNavigator';
7573
import TestDriveDemoNavigator from './TestDriveDemoNavigator';
7674
import useRootNavigatorScreenOptions from './useRootNavigatorScreenOptions';
@@ -220,7 +218,6 @@ const modalScreenListenersWithCancelSearch = {
220218

221219
function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDAppliedToClient}: AuthScreensProps) {
222220
const theme = useTheme();
223-
const StyleUtils = useStyleUtils();
224221
const {shouldUseNarrowLayout} = useResponsiveLayout();
225222
const rootNavigatorScreenOptions = useRootNavigatorScreenOptions();
226223
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
@@ -713,20 +710,6 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
713710
options={rootNavigatorScreenOptions.fullScreen}
714711
component={ConnectionCompletePage}
715712
/>
716-
<RootStack.Screen
717-
name={NAVIGATORS.TEST_TOOLS_MODAL_NAVIGATOR}
718-
options={{
719-
...rootNavigatorScreenOptions.basicModalNavigator,
720-
native: {
721-
contentStyle: {
722-
...StyleUtils.getBackgroundColorWithOpacityStyle(theme.overlay, 0.72),
723-
},
724-
animation: InternalPlatformAnimations.FADE,
725-
},
726-
}}
727-
component={TestToolsModalNavigator}
728-
listeners={modalScreenListeners}
729-
/>
730713
</RootStack.Navigator>
731714
<SearchRouterModal />
732715
</ComposeProviders>

0 commit comments

Comments
 (0)