From 85e2df59f5696320ac16a25417fb89970fb7020f Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 1 Apr 2025 00:48:48 +0700 Subject: [PATCH 1/4] fix: Use profiling option is missing --- .../settings/Troubleshoot/TroubleshootPage.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx index 41e5673c34af3..c27eb32b6978f 100644 --- a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx +++ b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx @@ -12,6 +12,7 @@ import ImportOnyxState from '@components/ImportOnyxState'; import LottieAnimations from '@components/LottieAnimations'; import MenuItemList from '@components/MenuItemList'; import {useOptionsList} from '@components/OptionListContextProvider'; +import ProfilingToolMenu from '@components/ProfilingToolMenu'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import Section from '@components/Section'; @@ -26,10 +27,12 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import useWaitForNavigation from '@hooks/useWaitForNavigation'; import {setShouldMaskOnyxState} from '@libs/actions/MaskOnyx'; +import {getBrowser, isChromeIOS} from '@libs/Browser'; import ExportOnyxState from '@libs/ExportOnyxState'; import Navigation from '@libs/Navigation/Navigation'; import {clearOnyxAndResetApp} from '@userActions/App'; import * as Report from '@userActions/Report'; +import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; @@ -61,6 +64,17 @@ function TroubleshootPage() { }); }, [shouldMaskOnyxState]); + const shouldShowProfileTool = useMemo(() => { + const browser = getBrowser(); + const isSafariOrFirefox = browser === CONST.BROWSER.SAFARI || browser === CONST.BROWSER.FIREFOX; + + if (isSafariOrFirefox || isChromeIOS()) { + return false; + } + + return true; + }, []); + const menuItems = useMemo(() => { const debugConsoleItem: BaseMenuItem = { translationKey: 'initialSettingsPage.troubleshoot.viewConsole', @@ -136,6 +150,7 @@ function TroubleshootPage() { > + {shouldShowProfileTool && } Date: Tue, 1 Apr 2025 00:52:51 +0700 Subject: [PATCH 2/4] fix eslint --- src/pages/settings/Troubleshoot/TroubleshootPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx index c27eb32b6978f..cbc2961473f31 100644 --- a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx +++ b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx @@ -31,7 +31,7 @@ import {getBrowser, isChromeIOS} from '@libs/Browser'; import ExportOnyxState from '@libs/ExportOnyxState'; import Navigation from '@libs/Navigation/Navigation'; import {clearOnyxAndResetApp} from '@userActions/App'; -import * as Report from '@userActions/Report'; +import {navigateToConciergeChat} from '@userActions/Report'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -140,7 +140,7 @@ function TroubleshootPage() { {translate('initialSettingsPage.troubleshoot.description')}{' '} Report.navigateToConciergeChat()} + onPress={() => navigateToConciergeChat()} > {translate('initialSettingsPage.troubleshoot.submitBug')} From 81820d639b83f38324ea4e80862c05435dee1183 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 1 Apr 2025 01:30:22 +0700 Subject: [PATCH 3/4] create a new action function --- src/components/TestToolsModal.tsx | 18 +++--------------- src/libs/actions/TestTool.ts | 12 ++++++++++++ .../settings/Troubleshoot/TroubleshootPage.tsx | 16 ++-------------- 3 files changed, 17 insertions(+), 29 deletions(-) diff --git a/src/components/TestToolsModal.tsx b/src/components/TestToolsModal.tsx index 0d39860a2dc7d..bfa6af2173684 100644 --- a/src/components/TestToolsModal.tsx +++ b/src/components/TestToolsModal.tsx @@ -1,4 +1,4 @@ -import React, {useMemo} from 'react'; +import React from 'react'; import {useOnyx} from 'react-native-onyx'; import useIsAuthenticated from '@hooks/useIsAuthenticated'; import useLocalize from '@hooks/useLocalize'; @@ -6,9 +6,8 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; -import {getBrowser, isChromeIOS} from '@libs/Browser'; import Navigation from '@navigation/Navigation'; -import toggleTestToolsModal from '@userActions/TestTool'; +import toggleTestToolsModal, {shouldShowProfileTool} from '@userActions/TestTool'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; @@ -39,17 +38,6 @@ function TestToolsModal() { const isAuthenticated = useIsAuthenticated(); const route = getRouteBasedOnAuthStatus(isAuthenticated, activeRoute); - const shouldShowProfileTool = useMemo(() => { - const browser = getBrowser(); - const isSafariOrFirefox = browser === CONST.BROWSER.SAFARI || browser === CONST.BROWSER.FIREFOX; - - if (isSafariOrFirefox || isChromeIOS()) { - return false; - } - - return true; - }, []); - return ( {translate('initialSettingsPage.troubleshoot.releaseOptions')} - {shouldShowProfileTool && } + {shouldShowProfileTool() && } {!!shouldStoreLogs && ( diff --git a/src/libs/actions/TestTool.ts b/src/libs/actions/TestTool.ts index eb686a6d265c0..b034ccde14f04 100644 --- a/src/libs/actions/TestTool.ts +++ b/src/libs/actions/TestTool.ts @@ -1,5 +1,6 @@ import throttle from 'lodash/throttle'; import Onyx from 'react-native-onyx'; +import {getBrowser, isChromeIOS} from '@libs/Browser'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import * as Modal from './Modal'; @@ -29,4 +30,15 @@ function toggleTestToolsModal() { throttledToggle(); } +function shouldShowProfileTool() { + const browser = getBrowser(); + const isSafariOrFirefox = browser === CONST.BROWSER.SAFARI || browser === CONST.BROWSER.FIREFOX; + + if (isSafariOrFirefox || isChromeIOS()) { + return false; + } + return true; +} + +export {shouldShowProfileTool}; export default toggleTestToolsModal; diff --git a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx index cbc2961473f31..f7c040bb95f10 100644 --- a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx +++ b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx @@ -27,12 +27,11 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import useWaitForNavigation from '@hooks/useWaitForNavigation'; import {setShouldMaskOnyxState} from '@libs/actions/MaskOnyx'; -import {getBrowser, isChromeIOS} from '@libs/Browser'; import ExportOnyxState from '@libs/ExportOnyxState'; import Navigation from '@libs/Navigation/Navigation'; import {clearOnyxAndResetApp} from '@userActions/App'; import {navigateToConciergeChat} from '@userActions/Report'; -import CONST from '@src/CONST'; +import {shouldShowProfileTool} from '@userActions/TestTool'; import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; @@ -64,17 +63,6 @@ function TroubleshootPage() { }); }, [shouldMaskOnyxState]); - const shouldShowProfileTool = useMemo(() => { - const browser = getBrowser(); - const isSafariOrFirefox = browser === CONST.BROWSER.SAFARI || browser === CONST.BROWSER.FIREFOX; - - if (isSafariOrFirefox || isChromeIOS()) { - return false; - } - - return true; - }, []); - const menuItems = useMemo(() => { const debugConsoleItem: BaseMenuItem = { translationKey: 'initialSettingsPage.troubleshoot.viewConsole', @@ -150,7 +138,7 @@ function TroubleshootPage() { > - {shouldShowProfileTool && } + {shouldShowProfileTool() && } Date: Tue, 1 Apr 2025 01:32:53 +0700 Subject: [PATCH 4/4] fix lint --- src/libs/actions/TestTool.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/TestTool.ts b/src/libs/actions/TestTool.ts index b034ccde14f04..b3a3f2257a93f 100644 --- a/src/libs/actions/TestTool.ts +++ b/src/libs/actions/TestTool.ts @@ -3,7 +3,7 @@ import Onyx from 'react-native-onyx'; import {getBrowser, isChromeIOS} from '@libs/Browser'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import * as Modal from './Modal'; +import {close} from './Modal'; let isTestToolsModalOpen = false; Onyx.connect({ @@ -21,7 +21,7 @@ function toggleTestToolsModal() { Onyx.set(ONYXKEYS.IS_TEST_TOOLS_MODAL_OPEN, !isTestToolsModalOpen); }; if (!isTestToolsModalOpen) { - Modal.close(toggleIsTestToolsModalOpen); + close(toggleIsTestToolsModalOpen); return; } toggleIsTestToolsModalOpen();