From 26facec54c85f0cf08f8e8655676aa162afe2c61 Mon Sep 17 00:00:00 2001 From: dominictb Date: Wed, 12 Jun 2024 17:10:40 +0700 Subject: [PATCH 1/7] feat: add shortcut to open troubleshoot modal Signed-off-by: dominictb --- src/CONST.ts | 10 ++++++++++ src/libs/Navigation/AppNavigator/AuthScreens.tsx | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/CONST.ts b/src/CONST.ts index 62d838a63ae3..97a2e353fcff 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/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index a160b6765f87..e5e9ddcaf249 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(); }; From d064e70a318d2598279be53b1ab8803fe455b9d6 Mon Sep 17 00:00:00 2001 From: dominictb Date: Thu, 13 Jun 2024 09:21:07 +0700 Subject: [PATCH 2/7] feat: add translation keys for debug shortcut Signed-off-by: dominictb --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index bc8f21deb457..3811c8876b61 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2787,6 +2787,7 @@ export default { search: 'Open search dialog', newChat: 'New chat screen', copy: 'Copy comment', + openDebug: 'Open testing preferences', }, }, guides: { diff --git a/src/languages/es.ts b/src/languages/es.ts index 34ebcaa64aea..69ef82076188 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2829,6 +2829,7 @@ export default { search: 'Abrir diálogo de búsqueda', newChat: 'Nueva pantalla de chat', copy: 'Copiar comentario', + openDebug: 'Open testing preferences', }, }, guides: { From 8763e2683ef55f465db234226ae2108cd60af440 Mon Sep 17 00:00:00 2001 From: dominictb Date: Thu, 13 Jun 2024 10:22:38 +0700 Subject: [PATCH 3/7] chore: disable client side logging in native Signed-off-by: dominictb --- .../index.android.tsx | 44 +------------------ .../ClientSideLoggingToolMenu/index.ios.tsx | 37 +--------------- 2 files changed, 2 insertions(+), 79 deletions(-) diff --git a/src/components/ClientSideLoggingToolMenu/index.android.tsx b/src/components/ClientSideLoggingToolMenu/index.android.tsx index aa1bc215b719..fbd351fa723f 100644 --- a/src/components/ClientSideLoggingToolMenu/index.android.tsx +++ b/src/components/ClientSideLoggingToolMenu/index.android.tsx @@ -1,47 +1,5 @@ -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'; - 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..fbd351fa723f 100644 --- a/src/components/ClientSideLoggingToolMenu/index.ios.tsx +++ b/src/components/ClientSideLoggingToolMenu/index.ios.tsx @@ -1,40 +1,5 @@ -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'; - 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'; From db72341d0e9dc28db34a87f0503de6c06d9369e6 Mon Sep 17 00:00:00 2001 From: dominictb Date: Fri, 14 Jun 2024 15:25:55 +0700 Subject: [PATCH 4/7] fix: add comment for client-side logging menu on native Signed-off-by: dominictb --- src/components/ClientSideLoggingToolMenu/index.android.tsx | 5 +++++ src/components/ClientSideLoggingToolMenu/index.ios.tsx | 5 +++++ src/languages/en.ts | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/ClientSideLoggingToolMenu/index.android.tsx b/src/components/ClientSideLoggingToolMenu/index.android.tsx index fbd351fa723f..54114eb6b5da 100644 --- a/src/components/ClientSideLoggingToolMenu/index.android.tsx +++ b/src/components/ClientSideLoggingToolMenu/index.android.tsx @@ -1,3 +1,8 @@ +/** + * 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-2154609239 + */ function ClientSideLoggingToolMenu() { return null; } diff --git a/src/components/ClientSideLoggingToolMenu/index.ios.tsx b/src/components/ClientSideLoggingToolMenu/index.ios.tsx index fbd351fa723f..54114eb6b5da 100644 --- a/src/components/ClientSideLoggingToolMenu/index.ios.tsx +++ b/src/components/ClientSideLoggingToolMenu/index.ios.tsx @@ -1,3 +1,8 @@ +/** + * 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-2154609239 + */ function ClientSideLoggingToolMenu() { return null; } diff --git a/src/languages/en.ts b/src/languages/en.ts index c38a59f548d4..86cf2d9cd1cd 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2789,7 +2789,7 @@ export default { search: 'Open search dialog', newChat: 'New chat screen', copy: 'Copy comment', - openDebug: 'Open testing preferences', + openDebug: 'Open testing preferences dialog', }, }, guides: { From 6dc49e9fba428348fa7a445568d2096d2074186e Mon Sep 17 00:00:00 2001 From: Dominic <165644294+dominictb@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:10:55 +0700 Subject: [PATCH 5/7] chore: update translation --- src/languages/es.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index bbfc99fb5bd0..7adf3d2a0d49 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2831,7 +2831,7 @@ export default { search: 'Abrir diálogo de búsqueda', newChat: 'Nueva pantalla de chat', copy: 'Copiar comentario', - openDebug: 'Open testing preferences', + openDebug: 'Abrir el diálogo de preferencias de pruebas', }, }, guides: { From ecd069697fcd3d31ae23d233f9b85d9d22864edb Mon Sep 17 00:00:00 2001 From: Dominic <165644294+dominictb@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:46:20 +0700 Subject: [PATCH 6/7] fix: link to the correct issue comment ID Co-authored-by: Jayesh Mangwani <35371050+jayeshmangwani@users.noreply.github.com> --- src/components/ClientSideLoggingToolMenu/index.android.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ClientSideLoggingToolMenu/index.android.tsx b/src/components/ClientSideLoggingToolMenu/index.android.tsx index 54114eb6b5da..298299e37fb9 100644 --- a/src/components/ClientSideLoggingToolMenu/index.android.tsx +++ b/src/components/ClientSideLoggingToolMenu/index.android.tsx @@ -1,7 +1,7 @@ /** * 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-2154609239 + * See comment here: https://github.com/Expensify/App/issues/43256#issuecomment-2154610196 */ function ClientSideLoggingToolMenu() { return null; From b54e4cd1cf6e66024ef630e396679369a6a06690 Mon Sep 17 00:00:00 2001 From: Dominic <165644294+dominictb@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:46:44 +0700 Subject: [PATCH 7/7] fix: link to the correct issue comment Co-authored-by: Jayesh Mangwani <35371050+jayeshmangwani@users.noreply.github.com> --- src/components/ClientSideLoggingToolMenu/index.ios.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ClientSideLoggingToolMenu/index.ios.tsx b/src/components/ClientSideLoggingToolMenu/index.ios.tsx index 54114eb6b5da..298299e37fb9 100644 --- a/src/components/ClientSideLoggingToolMenu/index.ios.tsx +++ b/src/components/ClientSideLoggingToolMenu/index.ios.tsx @@ -1,7 +1,7 @@ /** * 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-2154609239 + * See comment here: https://github.com/Expensify/App/issues/43256#issuecomment-2154610196 */ function ClientSideLoggingToolMenu() { return null;