diff --git a/src/CONST.ts b/src/CONST.ts index 6a936bc97087..6eb122802a38 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -523,6 +523,16 @@ const CONST = { shortcutKey: 'Tab', modifiers: [], }, + DEBUG: { + descriptionKey: 'openDebug', + shortcutKey: 'D', + modifiers: ['CTRL'], + trigger: { + DEFAULT: {input: 'd', modifierFlags: keyModifierControl}, + [PLATFORM_OS_MACOS]: {input: 'd', modifierFlags: keyModifierCommand}, + [PLATFORM_IOS]: {input: 'd', modifierFlags: keyModifierCommand}, + }, + }, }, KEYBOARD_SHORTCUTS_TYPES: { NAVIGATION_SHORTCUT: KEYBOARD_SHORTCUT_NAVIGATION_TYPE, diff --git a/src/components/ClientSideLoggingToolMenu/index.android.tsx b/src/components/ClientSideLoggingToolMenu/index.android.tsx index aa1bc215b719..298299e37fb9 100644 --- a/src/components/ClientSideLoggingToolMenu/index.android.tsx +++ b/src/components/ClientSideLoggingToolMenu/index.android.tsx @@ -1,47 +1,10 @@ -import React, {useState} from 'react'; -import RNFetchBlob from 'react-native-blob-util'; -import Share from 'react-native-share'; -import type {Log} from '@libs/Console'; -import localFileCreate from '@libs/localFileCreate'; -import CONST from '@src/CONST'; -import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu'; - +/** + * Since client-side logging is currently supported on web and desktop natively right now, + * this menu will be hidden in iOS and Android. + * See comment here: https://github.com/Expensify/App/issues/43256#issuecomment-2154610196 + */ function ClientSideLoggingToolMenu() { - const [file, setFile] = useState<{path: string; newFileName: string; size: number}>(); - - const createAndSaveFile = (logs: Log[]) => { - localFileCreate('logs', JSON.stringify(logs, null, 2)).then((localFile) => { - RNFetchBlob.MediaCollection.copyToMediaStore( - { - name: localFile.newFileName, - parentFolder: '', - mimeType: 'text/plain', - }, - 'Download', - localFile.path, - ); - setFile(localFile); - }); - }; - - const shareLogs = () => { - if (!file) { - return; - } - Share.open({ - url: `file://${file.path}`, - }); - }; - - return ( - setFile(undefined)} - onDisableLogging={createAndSaveFile} - onShareLogs={shareLogs} - displayPath={`${CONST.DOWNLOADS_PATH}/${file?.newFileName ?? ''}`} - /> - ); + return null; } ClientSideLoggingToolMenu.displayName = 'ClientSideLoggingToolMenu'; diff --git a/src/components/ClientSideLoggingToolMenu/index.ios.tsx b/src/components/ClientSideLoggingToolMenu/index.ios.tsx index 78ffccf612a2..298299e37fb9 100644 --- a/src/components/ClientSideLoggingToolMenu/index.ios.tsx +++ b/src/components/ClientSideLoggingToolMenu/index.ios.tsx @@ -1,40 +1,10 @@ -import React, {useState} from 'react'; -import Share from 'react-native-share'; -import useEnvironment from '@hooks/useEnvironment'; -import type {Log} from '@libs/Console'; -import getDownloadFolderPathSuffixForIOS from '@libs/getDownloadFolderPathSuffixForIOS'; -import localFileCreate from '@libs/localFileCreate'; -import CONST from '@src/CONST'; -import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu'; - +/** + * Since client-side logging is currently supported on web and desktop natively right now, + * this menu will be hidden in iOS and Android. + * See comment here: https://github.com/Expensify/App/issues/43256#issuecomment-2154610196 + */ function ClientSideLoggingToolMenu() { - const [file, setFile] = useState<{path: string; newFileName: string; size: number}>(); - const {environment} = useEnvironment(); - - const createFile = (logs: Log[]) => { - localFileCreate('logs', JSON.stringify(logs, null, 2)).then((localFile) => { - setFile(localFile); - }); - }; - - const shareLogs = () => { - if (!file) { - return; - } - Share.open({ - url: `file://${file.path}`, - }); - }; - - return ( - setFile(undefined)} - onDisableLogging={createFile} - onShareLogs={shareLogs} - displayPath={`${CONST.NEW_EXPENSIFY_PATH}${getDownloadFolderPathSuffixForIOS(environment)}/${file?.newFileName ?? ''}`} - /> - ); + return null; } ClientSideLoggingToolMenu.displayName = 'ClientSideLoggingToolMenu'; diff --git a/src/languages/en.ts b/src/languages/en.ts index 2469739582bf..37635746fee9 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2786,6 +2786,7 @@ export default { search: 'Open search dialog', newChat: 'New chat screen', copy: 'Copy comment', + openDebug: 'Open testing preferences dialog', }, }, guides: { diff --git a/src/languages/es.ts b/src/languages/es.ts index ec5ebb4fb827..323f2ddb5336 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2825,6 +2825,7 @@ export default { search: 'Abrir diálogo de búsqueda', newChat: 'Nueva pantalla de chat', copy: 'Copiar comentario', + openDebug: 'Abrir el diálogo de preferencias de pruebas', }, }, guides: { diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index 410caf77e3c4..2c8e2c6bfa80 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -30,6 +30,7 @@ import * as PersonalDetails from '@userActions/PersonalDetails'; import * as PriorityMode from '@userActions/PriorityMode'; import * as Report from '@userActions/Report'; import * as Session from '@userActions/Session'; +import toggleTestToolsModal from '@userActions/TestTool'; import Timing from '@userActions/Timing'; import * as User from '@userActions/User'; import CONFIG from '@src/CONFIG'; @@ -190,6 +191,7 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie const shortcutsOverviewShortcutConfig = CONST.KEYBOARD_SHORTCUTS.SHORTCUTS; const searchShortcutConfig = CONST.KEYBOARD_SHORTCUTS.SEARCH; const chatShortcutConfig = CONST.KEYBOARD_SHORTCUTS.NEW_CHAT; + const debugShortcutConfig = CONST.KEYBOARD_SHORTCUTS.DEBUG; const currentUrl = getCurrentUrl(); const isLoggingInAsNewUser = !!session?.email && SessionUtils.isLoggingInAsNewUser(currentUrl, session.email); // Sign out the current user if we're transitioning with a different user @@ -273,10 +275,21 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie true, ); + const unsubscribeDebugShortcut = KeyboardShortcut.subscribe( + debugShortcutConfig.shortcutKey, + () => { + toggleTestToolsModal(); + }, + debugShortcutConfig.descriptionKey, + debugShortcutConfig.modifiers, + true, + ); + return () => { unsubscribeShortcutsOverviewShortcut(); unsubscribeSearchShortcut(); unsubscribeChatShortcut(); + unsubscribeDebugShortcut(); Session.cleanupSession(); };