From 46a6c3e52188ce55edad92a107ecbe4b930f825d Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Sun, 21 Apr 2024 18:07:24 +0530
Subject: [PATCH 01/15] Show console debug logs via test tools menu
---
ios/Podfile | 17 ++
src/CONST.ts | 3 +-
src/ROUTES.ts | 2 +-
.../BaseClientSideLoggingToolMenu.tsx | 21 +-
.../ConsoleComponents.tsx | 191 ++++++++++++++++++
.../ConsoleModal.tsx | 64 ++++++
.../index.android.tsx | 4 +-
.../ClientSideLoggingToolMenu/index.ios.tsx | 4 +-
.../ClientSideLoggingToolMenu/index.tsx | 4 +-
src/components/Modal/index.tsx | 2 +-
src/components/TestToolsModal.tsx | 2 +-
src/libs/Navigation/types.ts | 1 +
src/pages/settings/AboutPage/ConsolePage.tsx | 158 +--------------
.../ShareLogList/BaseShareLogList.tsx | 10 +-
.../AboutPage/ShareLogList/index.native.tsx | 4 +-
.../settings/AboutPage/ShareLogList/index.tsx | 4 +-
src/pages/settings/AboutPage/ShareLogPage.tsx | 2 +-
.../utils/generators/ModalStyleUtils.ts | 23 +++
18 files changed, 345 insertions(+), 171 deletions(-)
create mode 100644 src/components/ClientSideLoggingToolMenu/ConsoleComponents.tsx
create mode 100644 src/components/ClientSideLoggingToolMenu/ConsoleModal.tsx
diff --git a/ios/Podfile b/ios/Podfile
index 4f00eb2adfdd..0c524878e5f7 100644
--- a/ios/Podfile
+++ b/ios/Podfile
@@ -1,3 +1,5 @@
+use_frameworks! :linkage => :static
+
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
# Set the type of Mapbox SDK to use
# This value is used by $RNMapboxMaps
@@ -111,6 +113,21 @@ target 'NewExpensify' do
end
end
end
+
+ deployment_target = '13.4'
+
+ installer.generated_projects.each do |project|
+ project.targets.each do |target|
+ target.build_configurations.each do |config|
+ config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
+ end
+ end
+ project.build_configurations.each do |config|
+ config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
+ end
+ end
+
+ `sed -i -e $'s/__IPHONE_10_0/__IPHONE_15_0/' #{installer.sandbox.root}/RCT-Folly/folly/portability/Time.h`
end
end
diff --git a/src/CONST.ts b/src/CONST.ts
index 2cd614b74816..4ded9e282d3e 100755
--- a/src/CONST.ts
+++ b/src/CONST.ts
@@ -860,6 +860,7 @@ const CONST = {
POPOVER: 'popover',
RIGHT_DOCKED: 'right_docked',
ONBOARDING: 'onboarding',
+ CENTERED_SMALL_AND_UNSWIPEABLE: 'centered_small_and_unswipeable'
},
ANCHOR_ORIGIN_VERTICAL: {
TOP: 'top',
@@ -3100,7 +3101,7 @@ const CONST = {
// Test tool menu parameters
TEST_TOOL: {
// Number of concurrent taps to open then the Test modal menu
- NUMBER_OF_TAPS: 4,
+ NUMBER_OF_TAPS: 2,
},
MENU_HELP_URLS: {
diff --git a/src/ROUTES.ts b/src/ROUTES.ts
index ceb4c217cb6e..71e673aea994 100644
--- a/src/ROUTES.ts
+++ b/src/ROUTES.ts
@@ -175,7 +175,7 @@ const ROUTES = {
SETTINGS_CONSOLE: 'settings/troubleshoot/console',
SETTINGS_SHARE_LOG: {
route: 'settings/troubleshoot/console/share-log',
- getRoute: (source: string) => `settings/troubleshoot/console/share-log?source=${encodeURI(source)}` as const,
+ getRoute: (source: string, isViaTestToolsModal = false) => `settings/troubleshoot/console/share-log?source=${encodeURI(source)}&isViaTestToolsModal=${isViaTestToolsModal}` as const,
},
SETTINGS_EXIT_SURVEY_REASON: 'settings/exit-survey/reason',
diff --git a/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx b/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
index fcad770908a6..a6bb085c949a 100644
--- a/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
+++ b/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, {useState} from 'react';
import {Alert} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
@@ -12,6 +12,7 @@ import * as Console from '@libs/actions/Console';
import {parseStringifiedMessages} from '@libs/Console';
import ONYXKEYS from '@src/ONYXKEYS';
import type {CapturedLogs, Log} from '@src/types/onyx';
+import ConsoleModal from "@components/ClientSideLoggingToolMenu/ConsoleModal";
type BaseClientSideLoggingToolMenuOnyxProps = {
/** Logs captured on the current device */
@@ -30,9 +31,11 @@ type BaseClientSideLoggingToolProps = {
onDisableLogging: (logs: Log[]) => void;
/** Action to run when enabling logging */
onEnableLogging?: () => void;
+ /** Boolean to know if this was opened via test tools modal */
+ isViaTestToolsModal: boolean
} & BaseClientSideLoggingToolMenuOnyxProps;
-function BaseClientSideLoggingToolMenu({shouldStoreLogs, capturedLogs, file, onShareLogs, onDisableLogging, onEnableLogging}: BaseClientSideLoggingToolProps) {
+function BaseClientSideLoggingToolMenu({shouldStoreLogs, capturedLogs, file, onShareLogs, onDisableLogging, onEnableLogging, isViaTestToolsModal, closeTestToolsModal}: BaseClientSideLoggingToolProps) {
const {translate} = useLocalize();
const onToggle = () => {
@@ -59,6 +62,8 @@ function BaseClientSideLoggingToolMenu({shouldStoreLogs, capturedLogs, file, onS
Console.disableLoggingAndFlushLogs();
};
const styles = useThemeStyles();
+ const [isConsoleModalVisible, setIsConsoleModalVisible] = useState(false);
+
return (
<>
@@ -68,6 +73,15 @@ function BaseClientSideLoggingToolMenu({shouldStoreLogs, capturedLogs, file, onS
onToggle={onToggle}
/>
+ {!!shouldStoreLogs && isViaTestToolsModal &&
+
+
+ }
{!!file && (
<>
{`path: ${file.path}`}
@@ -80,6 +94,9 @@ function BaseClientSideLoggingToolMenu({shouldStoreLogs, capturedLogs, file, onS
>
)}
+ {
+ setIsConsoleModalVisible(false)
+ }} closeTestToolsModal={closeTestToolsModal}/>
>
);
}
diff --git a/src/components/ClientSideLoggingToolMenu/ConsoleComponents.tsx b/src/components/ClientSideLoggingToolMenu/ConsoleComponents.tsx
new file mode 100644
index 000000000000..5de7de0e049e
--- /dev/null
+++ b/src/components/ClientSideLoggingToolMenu/ConsoleComponents.tsx
@@ -0,0 +1,191 @@
+import React, {useCallback, useEffect, useMemo, useState} from 'react';
+import {ListRenderItem, ListRenderItemInfo, View} from 'react-native';
+import CONST from "@src/CONST";
+import useThemeStyles from "@hooks/useThemeStyles";
+import useLocalize from "@hooks/useLocalize";
+import InvertedFlatList from "@components/InvertedFlatList";
+import Text from "@components/Text";
+import {CapturedLogs, Log} from "@src/types/onyx";
+import {format} from "date-fns";
+import {OnyxEntry, withOnyx} from "react-native-onyx";
+import ONYXKEYS from "@src/ONYXKEYS";
+import {createLog, parseStringifiedMessages, sanitizeConsoleInput} from "@libs/Console";
+import {addLog} from "@userActions/Console";
+import useKeyboardShortcut from "@hooks/useKeyboardShortcut";
+import localFileDownload from "@libs/localFileDownload";
+import localFileCreate from "@libs/localFileCreate";
+import Navigation from "@navigation/Navigation";
+import ROUTES from "@src/ROUTES";
+import Button from "@components/Button";
+import * as Expensicons from "@components/Icon/Expensicons";
+import TextInput from "@components/TextInput";
+import ConfirmModal from "@components/ConfirmModal";
+
+type ConsoleComponentsOnyxProps = {
+ /** Logs captured on the current device */
+ capturedLogs: OnyxEntry;
+
+ /** Whether or not logs should be stored */
+ shouldStoreLogs: OnyxEntry;
+};
+
+type ConsoleComponentsProps = {
+ /** Action to run when pressing Share button */
+ onClose?: () => void;
+ /** Boolean to know if console logs have been opened via test tools modal */
+ isViaTestToolsModal: boolean
+} & ConsoleComponentsOnyxProps;
+
+
+function ConsoleComponents({capturedLogs, shouldStoreLogs, onClose, isViaTestToolsModal}: ConsoleComponentsProps) {
+ const styles = useThemeStyles();
+ const {translate} = useLocalize();
+
+ const [input, setInput] = useState('');
+ const [logs, setLogs] = useState(capturedLogs);
+ const [isGeneratingLogsFile, setIsGeneratingLogsFile] = useState(false);
+ const [isLimitModalVisible, setIsLimitModalVisible] = useState(false);
+
+ const logsList = useMemo(
+ () =>
+ Object.entries(logs ?? {})
+ .map(([key, value]) => ({key, ...value}))
+ .reverse(),
+ [logs],
+ );
+
+ useEffect(() => {
+ if (!shouldStoreLogs) {
+ return;
+ }
+
+ setLogs((prevLogs) => ({...prevLogs, ...capturedLogs}));
+ }, [capturedLogs, shouldStoreLogs]);
+
+ const renderItem: ListRenderItem = useCallback(
+ ({item}: ListRenderItemInfo) => {
+ if (!item) {
+ return null;
+ }
+
+ return (
+
+ {`${format(new Date(item.time), CONST.DATE.FNS_DB_FORMAT_STRING)} ${item.message}`}
+
+ );
+ },
+ [styles.mb2],
+ );
+
+ const executeArbitraryCode = () => {
+ const sanitizedInput = sanitizeConsoleInput(input);
+
+ const output = createLog(sanitizedInput);
+ output.forEach((log) => addLog(log));
+ setInput('');
+ };
+
+ useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.ENTER, executeArbitraryCode);
+
+ const saveLogs = () => {
+ const logsWithParsedMessages = parseStringifiedMessages(logsList);
+
+ localFileDownload('logs', JSON.stringify(logsWithParsedMessages, null, 2));
+ };
+
+ const shareLogs = () => {
+ setIsGeneratingLogsFile(true);
+ const logsWithParsedMessages = parseStringifiedMessages(logsList);
+
+ // Generate a file with the logs and pass its path to the list of reports to share it with
+ localFileCreate('logs', JSON.stringify(logsWithParsedMessages, null, 2)).then(({path, size}) => {
+ setIsGeneratingLogsFile(false);
+
+ // if the file size is too large to send it as an attachment, show a modal and return
+ if (size > CONST.API_ATTACHMENT_VALIDATIONS.MAX_SIZE) {
+ setIsLimitModalVisible(true);
+
+ return;
+ }
+
+ if (onClose) {
+ onClose()
+ }
+ Navigation.navigate(ROUTES.SETTINGS_SHARE_LOG.getRoute(path, isViaTestToolsModal));
+ });
+ };
+
+ const mhModal = isViaTestToolsModal ? styles.mh2 : undefined;
+
+ return (
+ <>
+
+
+ {translate('initialSettingsPage.debugConsole.noLogsAvailable')}}
+ />
+
+
+
+
+
+
+
+
+
+
+ setIsLimitModalVisible(false)}
+ prompt={translate('initialSettingsPage.debugConsole.logSizeTooLarge', {
+ size: CONST.API_ATTACHMENT_VALIDATIONS.MAX_SIZE / 1024 / 1024,
+ })}
+ shouldShowCancelButton={false}
+ confirmText={translate('common.ok')}
+ />
+ >
+ );
+}
+
+ConsoleComponents.displayName = 'ConsoleModal';
+
+
+export default withOnyx({
+ capturedLogs: {
+ key: ONYXKEYS.LOGS,
+ },
+ shouldStoreLogs: {
+ key: ONYXKEYS.SHOULD_STORE_LOGS,
+ },
+})(ConsoleComponents);
diff --git a/src/components/ClientSideLoggingToolMenu/ConsoleModal.tsx b/src/components/ClientSideLoggingToolMenu/ConsoleModal.tsx
new file mode 100644
index 000000000000..d2ee0c30271a
--- /dev/null
+++ b/src/components/ClientSideLoggingToolMenu/ConsoleModal.tsx
@@ -0,0 +1,64 @@
+import React, {useCallback, useEffect, useMemo, useState} from 'react';
+import {ListRenderItem, ListRenderItemInfo, View} from 'react-native';
+import ConsolePage from "@pages/settings/AboutPage/ConsolePage";
+import CONST from "@src/CONST";
+import Modal from "@components/Modal";
+import useWindowDimensions from "@hooks/useWindowDimensions";
+import useStyleUtils from "@hooks/useStyleUtils";
+import useThemeStyles from "@hooks/useThemeStyles";
+import useLocalize from "@hooks/useLocalize";
+import InvertedFlatList from "@components/InvertedFlatList";
+import Text from "@components/Text";
+import {CapturedLogs, Log} from "@src/types/onyx";
+import {format} from "date-fns";
+import {OnyxEntry, withOnyx} from "react-native-onyx";
+import ONYXKEYS from "@src/ONYXKEYS";
+import {createLog, parseStringifiedMessages, sanitizeConsoleInput} from "@libs/Console";
+import {addLog} from "@userActions/Console";
+import useKeyboardShortcut from "@hooks/useKeyboardShortcut";
+import localFileDownload from "@libs/localFileDownload";
+import localFileCreate from "@libs/localFileCreate";
+import Navigation from "@navigation/Navigation";
+import ROUTES from "@src/ROUTES";
+import Button from "@components/Button";
+import * as Expensicons from "@components/Icon/Expensicons";
+import TextInput from "@components/TextInput";
+import ConfirmModal from "@components/ConfirmModal";
+import ShareLogList from "@pages/settings/AboutPage/ShareLogList";
+import ConsoleComponents from "@components/ClientSideLoggingToolMenu/ConsoleComponents";
+
+type ConsoleModalProps = {
+ /** Locally created file */
+ isVisible: boolean
+ /** Action to run when pressing Share button */
+ onClose?: () => void;
+};
+
+
+function ConsoleModal({isVisible, onClose, closeTestToolsModal}: ConsoleModalProps) {
+ const {windowWidth, windowHeight} = useWindowDimensions();
+ const StyleUtils = useStyleUtils();
+
+ return (
+
+
+
+ {
+ if (onClose) {
+ onClose()
+ }
+ closeTestToolsModal()
+ }}
+ isViaTestToolsModal/>
+
+
+ );
+}
+
+ConsoleModal.displayName = 'ConsoleModal';
+
+export default ConsoleModal;
diff --git a/src/components/ClientSideLoggingToolMenu/index.android.tsx b/src/components/ClientSideLoggingToolMenu/index.android.tsx
index 0be6e96fcafe..97cd9862fa20 100644
--- a/src/components/ClientSideLoggingToolMenu/index.android.tsx
+++ b/src/components/ClientSideLoggingToolMenu/index.android.tsx
@@ -5,7 +5,7 @@ import type {Log} from '@libs/Console';
import localFileCreate from '@libs/localFileCreate';
import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu';
-function ClientSideLoggingToolMenu() {
+function ClientSideLoggingToolMenu({isViaTestToolsModal = false, closeTestToolsModal}) {
const [file, setFile] = useState<{path: string; newFileName: string; size: number}>();
const createAndSaveFile = (logs: Log[]) => {
@@ -38,6 +38,8 @@ function ClientSideLoggingToolMenu() {
onEnableLogging={() => setFile(undefined)}
onDisableLogging={createAndSaveFile}
onShareLogs={shareLogs}
+ isViaTestToolsModal={isViaTestToolsModal}
+ closeTestToolsModal={closeTestToolsModal}
/>
);
}
diff --git a/src/components/ClientSideLoggingToolMenu/index.ios.tsx b/src/components/ClientSideLoggingToolMenu/index.ios.tsx
index cc596e54a973..34adf8fdf244 100644
--- a/src/components/ClientSideLoggingToolMenu/index.ios.tsx
+++ b/src/components/ClientSideLoggingToolMenu/index.ios.tsx
@@ -4,7 +4,7 @@ import type {Log} from '@libs/Console';
import localFileCreate from '@libs/localFileCreate';
import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu';
-function ClientSideLoggingToolMenu() {
+function ClientSideLoggingToolMenu({isViaTestToolsModal = false, closeTestToolsModal}) {
const [file, setFile] = useState<{path: string; newFileName: string; size: number}>();
const createFile = (logs: Log[]) => {
@@ -28,6 +28,8 @@ function ClientSideLoggingToolMenu() {
onEnableLogging={() => setFile(undefined)}
onDisableLogging={createFile}
onShareLogs={shareLogs}
+ isViaTestToolsModal={isViaTestToolsModal}
+ closeTestToolsModal={closeTestToolsModal}
/>
);
}
diff --git a/src/components/ClientSideLoggingToolMenu/index.tsx b/src/components/ClientSideLoggingToolMenu/index.tsx
index 182c3bf99b74..99468ea32089 100644
--- a/src/components/ClientSideLoggingToolMenu/index.tsx
+++ b/src/components/ClientSideLoggingToolMenu/index.tsx
@@ -3,12 +3,12 @@ import type {Log} from '@libs/Console';
import localFileDownload from '@libs/localFileDownload';
import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu';
-function ClientSideLoggingToolMenu() {
+function ClientSideLoggingToolMenu({isViaTestToolsModal = false}) {
const downloadFile = (logs: Log[]) => {
localFileDownload('logs', JSON.stringify(logs, null, 2));
};
- return ;
+ return ;
}
ClientSideLoggingToolMenu.displayName = 'ClientSideLoggingToolMenu';
diff --git a/src/components/Modal/index.tsx b/src/components/Modal/index.tsx
index 76f4b251ec83..5c31ac60d39d 100644
--- a/src/components/Modal/index.tsx
+++ b/src/components/Modal/index.tsx
@@ -34,7 +34,7 @@ function Modal({fullscreen = true, onModalHide = () => {}, type, onModalShow = (
const showModal = () => {
const statusBarColor = StatusBar.getBackgroundColor() ?? theme.appBG;
- const isFullScreenModal = type === CONST.MODAL.MODAL_TYPE.CENTERED || type === CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE || type === CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED;
+ const isFullScreenModal = type === CONST.MODAL.MODAL_TYPE.CENTERED || type === CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE || type === CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED || type === CONST.MODAL.MODAL_TYPE.CENTERED_SMALL_AND_UNSWIPEABLE;
if (statusBarColor) {
setPreviousStatusBarColor(statusBarColor);
diff --git a/src/components/TestToolsModal.tsx b/src/components/TestToolsModal.tsx
index 026eafc7a13d..2d2ec9eb599d 100644
--- a/src/components/TestToolsModal.tsx
+++ b/src/components/TestToolsModal.tsx
@@ -45,7 +45,7 @@ function TestToolsModal({isTestToolsModalOpen = false}: TestToolsModalProps) {
{translate('initialSettingsPage.troubleshoot.releaseOptions')}
-
+
);
diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts
index bc3d0bba637e..492df5354613 100644
--- a/src/libs/Navigation/types.ts
+++ b/src/libs/Navigation/types.ts
@@ -115,6 +115,7 @@ type SettingsNavigatorParamList = {
[SCREENS.SETTINGS.SHARE_LOG]: {
/** URL of the generated file to share logs in a report */
source: string;
+ isViaTestToolsModal: boolean;
};
[SCREENS.SETTINGS.WALLET.ROOT]: undefined;
[SCREENS.SETTINGS.WALLET.CARDS_DIGITAL_DETAILS_UPDATE_ADDRESS]: undefined;
diff --git a/src/pages/settings/AboutPage/ConsolePage.tsx b/src/pages/settings/AboutPage/ConsolePage.tsx
index c9532fa041a0..350b9c088dfe 100644
--- a/src/pages/settings/AboutPage/ConsolePage.tsx
+++ b/src/pages/settings/AboutPage/ConsolePage.tsx
@@ -1,114 +1,15 @@
-import {format} from 'date-fns';
-import React, {useCallback, useEffect, useMemo, useState} from 'react';
-import {View} from 'react-native';
-import type {ListRenderItem, ListRenderItemInfo} from 'react-native';
+import React from 'react';
import {withOnyx} from 'react-native-onyx';
-import type {OnyxEntry} from 'react-native-onyx';
-import Button from '@components/Button';
-import ConfirmModal from '@components/ConfirmModal';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
-import * as Expensicons from '@components/Icon/Expensicons';
-import InvertedFlatList from '@components/InvertedFlatList';
import ScreenWrapper from '@components/ScreenWrapper';
-import Text from '@components/Text';
-import TextInput from '@components/TextInput';
-import useKeyboardShortcut from '@hooks/useKeyboardShortcut';
import useLocalize from '@hooks/useLocalize';
-import useThemeStyles from '@hooks/useThemeStyles';
-import {addLog} from '@libs/actions/Console';
-import {createLog, parseStringifiedMessages, sanitizeConsoleInput} from '@libs/Console';
-import type {Log} from '@libs/Console';
-import localFileCreate from '@libs/localFileCreate';
-import localFileDownload from '@libs/localFileDownload';
import Navigation from '@libs/Navigation/Navigation';
-import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
-import type {CapturedLogs} from '@src/types/onyx';
+import ConsoleComponents from "@components/ClientSideLoggingToolMenu/ConsoleComponents";
-type ConsolePageOnyxProps = {
- /** Logs captured on the current device */
- capturedLogs: OnyxEntry;
-
- /** Whether or not logs should be stored */
- shouldStoreLogs: OnyxEntry;
-};
-
-type ConsolePageProps = ConsolePageOnyxProps;
-
-function ConsolePage({capturedLogs, shouldStoreLogs}: ConsolePageProps) {
- const [input, setInput] = useState('');
- const [logs, setLogs] = useState(capturedLogs);
- const [isGeneratingLogsFile, setIsGeneratingLogsFile] = useState(false);
- const [isLimitModalVisible, setIsLimitModalVisible] = useState(false);
+function ConsolePage() {
const {translate} = useLocalize();
- const styles = useThemeStyles();
-
- const logsList = useMemo(
- () =>
- Object.entries(logs ?? {})
- .map(([key, value]) => ({key, ...value}))
- .reverse(),
- [logs],
- );
-
- useEffect(() => {
- if (!shouldStoreLogs) {
- return;
- }
-
- setLogs((prevLogs) => ({...prevLogs, ...capturedLogs}));
- }, [capturedLogs, shouldStoreLogs]);
-
- const executeArbitraryCode = () => {
- const sanitizedInput = sanitizeConsoleInput(input);
-
- const output = createLog(sanitizedInput);
- output.forEach((log) => addLog(log));
- setInput('');
- };
-
- useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.ENTER, executeArbitraryCode);
-
- const saveLogs = () => {
- const logsWithParsedMessages = parseStringifiedMessages(logsList);
-
- localFileDownload('logs', JSON.stringify(logsWithParsedMessages, null, 2));
- };
-
- const shareLogs = () => {
- setIsGeneratingLogsFile(true);
- const logsWithParsedMessages = parseStringifiedMessages(logsList);
-
- // Generate a file with the logs and pass its path to the list of reports to share it with
- localFileCreate('logs', JSON.stringify(logsWithParsedMessages, null, 2)).then(({path, size}) => {
- setIsGeneratingLogsFile(false);
-
- // if the file size is too large to send it as an attachment, show a modal and return
- if (size > CONST.API_ATTACHMENT_VALIDATIONS.MAX_SIZE) {
- setIsLimitModalVisible(true);
-
- return;
- }
-
- Navigation.navigate(ROUTES.SETTINGS_SHARE_LOG.getRoute(path));
- });
- };
-
- const renderItem: ListRenderItem = useCallback(
- ({item}: ListRenderItemInfo) => {
- if (!item) {
- return null;
- }
-
- return (
-
- {`${format(new Date(item.time), CONST.DATE.FNS_DB_FORMAT_STRING)} ${item.message}`}
-
- );
- },
- [styles.mb2],
- );
return (
@@ -116,58 +17,7 @@ function ConsolePage({capturedLogs, shouldStoreLogs}: ConsolePageProps) {
title={translate('initialSettingsPage.troubleshoot.debugConsole')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_TROUBLESHOOT)}
/>
-
- {translate('initialSettingsPage.debugConsole.noLogsAvailable')}}
- />
-
-
-
-
-
-
-
-
-
- setIsLimitModalVisible(false)}
- prompt={translate('initialSettingsPage.debugConsole.logSizeTooLarge', {
- size: CONST.API_ATTACHMENT_VALIDATIONS.MAX_SIZE / 1024 / 1024,
- })}
- shouldShowCancelButton={false}
- confirmText={translate('common.ok')}
- />
+
);
}
diff --git a/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx b/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx
index 578efbe5317b..58ddac79321b 100644
--- a/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx
+++ b/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx
@@ -16,7 +16,7 @@ import ROUTES from '@src/ROUTES';
import type {Report} from '@src/types/onyx';
import type {BaseShareLogListProps} from './types';
-function BaseShareLogList({onAttachLogToReport}: BaseShareLogListProps) {
+function BaseShareLogList({onAttachLogToReport, isViaTestToolsModal = false}: BaseShareLogListProps) {
const [searchValue, debouncedSearchValue, setSearchValue] = useDebouncedState('');
const {isOffline} = useNetwork();
const {translate} = useLocalize();
@@ -91,7 +91,13 @@ function BaseShareLogList({onAttachLogToReport}: BaseShareLogListProps) {
<>
Navigation.goBack(ROUTES.SETTINGS_CONSOLE)}
+ onBackButtonPress={() => {
+ if (isViaTestToolsModal) {
+ Navigation.goBack();
+ return;
+ }
+ Navigation.goBack(ROUTES.SETTINGS_CONSOLE)
+ }}
/>
{
if (!reportID || !logSource) {
return;
@@ -17,7 +17,7 @@ function ShareLogList({logSource}: ShareLogListProps) {
Navigation.navigate(routeToNavigate);
};
- return ;
+ return ;
}
export default ShareLogList;
diff --git a/src/pages/settings/AboutPage/ShareLogList/index.tsx b/src/pages/settings/AboutPage/ShareLogList/index.tsx
index 555e44e53747..87657575a35c 100644
--- a/src/pages/settings/AboutPage/ShareLogList/index.tsx
+++ b/src/pages/settings/AboutPage/ShareLogList/index.tsx
@@ -6,7 +6,7 @@ import ROUTES from '@src/ROUTES';
import BaseShareLogList from './BaseShareLogList';
import type {ShareLogListProps} from './types';
-function ShareLogList({logSource}: ShareLogListProps) {
+function ShareLogList({logSource, isViaTestToolsModal = false}: ShareLogListProps) {
const onAttachLogToReport = (reportID: string, filename: string) => {
FileUtils.readFileAsync(
logSource,
@@ -20,7 +20,7 @@ function ShareLogList({logSource}: ShareLogListProps) {
() => {},
);
};
- return ;
+ return ;
}
export default ShareLogList;
diff --git a/src/pages/settings/AboutPage/ShareLogPage.tsx b/src/pages/settings/AboutPage/ShareLogPage.tsx
index 8f0623f99d32..5c402f023819 100644
--- a/src/pages/settings/AboutPage/ShareLogPage.tsx
+++ b/src/pages/settings/AboutPage/ShareLogPage.tsx
@@ -7,7 +7,7 @@ import ShareLogList from './ShareLogList';
type ShareLogPageProps = StackScreenProps;
function ShareLogPage({route}: ShareLogPageProps) {
- return ;
+ return ;
}
export default ShareLogPage;
diff --git a/src/styles/utils/generators/ModalStyleUtils.ts b/src/styles/utils/generators/ModalStyleUtils.ts
index 335ef8382941..94b39a400367 100644
--- a/src/styles/utils/generators/ModalStyleUtils.ts
+++ b/src/styles/utils/generators/ModalStyleUtils.ts
@@ -164,6 +164,29 @@ const createModalStyleUtils: StyleUtilGenerator = ({the
shouldAddTopSafeAreaPadding = false;
shouldAddBottomSafeAreaPadding = false;
break;
+ case CONST.MODAL.MODAL_TYPE.CENTERED_SMALL_AND_UNSWIPEABLE:
+ // A centered modal that takes up the minimum possible screen space on all devices and is unswipeable
+ modalStyle = {
+ ...modalStyle,
+ ...{
+ alignItems: 'center',
+ },
+ };
+ modalContainerStyle = {
+ boxShadow: '0px 0px 5px 5px rgba(0, 0, 0, 0.1)',
+ borderRadius: 12,
+ borderWidth: 0,
+ };
+
+ // Allow this modal to be dismissed with a swipe down or swipe right
+ swipeDirection = undefined;
+ animationIn = isSmallScreenWidth ? 'slideInRight' : 'fadeIn';
+ animationOut = isSmallScreenWidth ? 'slideOutRight' : 'fadeOut';
+ shouldAddTopSafeAreaMargin = false;
+ shouldAddBottomSafeAreaMargin = false;
+ shouldAddTopSafeAreaPadding = false;
+ shouldAddBottomSafeAreaPadding = false;
+ break;
case CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED:
modalStyle = {
...modalStyle,
From a323a21b0bbc837bb650a1d915c68efe3899c9a2 Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Mon, 22 Apr 2024 01:19:04 +0530
Subject: [PATCH 02/15] Update
---
ios/Podfile | 17 --------
.../BaseClientSideLoggingToolMenu.tsx | 6 +--
.../ConsoleComponents.tsx | 42 +++----------------
.../ConsoleModal.tsx | 30 ++-----------
src/components/TestToolsModal.tsx | 2 +-
src/languages/en.ts | 1 +
src/languages/es.ts | 1 +
7 files changed, 15 insertions(+), 84 deletions(-)
diff --git a/ios/Podfile b/ios/Podfile
index 0c524878e5f7..4f00eb2adfdd 100644
--- a/ios/Podfile
+++ b/ios/Podfile
@@ -1,5 +1,3 @@
-use_frameworks! :linkage => :static
-
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
# Set the type of Mapbox SDK to use
# This value is used by $RNMapboxMaps
@@ -113,21 +111,6 @@ target 'NewExpensify' do
end
end
end
-
- deployment_target = '13.4'
-
- installer.generated_projects.each do |project|
- project.targets.each do |target|
- target.build_configurations.each do |config|
- config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
- end
- end
- project.build_configurations.each do |config|
- config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
- end
- end
-
- `sed -i -e $'s/__IPHONE_10_0/__IPHONE_15_0/' #{installer.sandbox.root}/RCT-Folly/folly/portability/Time.h`
end
end
diff --git a/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx b/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
index a6bb085c949a..0a64f8f6c353 100644
--- a/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
+++ b/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
@@ -12,7 +12,7 @@ import * as Console from '@libs/actions/Console';
import {parseStringifiedMessages} from '@libs/Console';
import ONYXKEYS from '@src/ONYXKEYS';
import type {CapturedLogs, Log} from '@src/types/onyx';
-import ConsoleModal from "@components/ClientSideLoggingToolMenu/ConsoleModal";
+import ConsoleModal from "./ConsoleModal";
type BaseClientSideLoggingToolMenuOnyxProps = {
/** Logs captured on the current device */
@@ -74,10 +74,10 @@ function BaseClientSideLoggingToolMenu({shouldStoreLogs, capturedLogs, file, onS
/>
{!!shouldStoreLogs && isViaTestToolsModal &&
-
+
diff --git a/src/components/ClientSideLoggingToolMenu/ConsoleComponents.tsx b/src/components/ClientSideLoggingToolMenu/ConsoleComponents.tsx
index 5de7de0e049e..b14a1e94c9f3 100644
--- a/src/components/ClientSideLoggingToolMenu/ConsoleComponents.tsx
+++ b/src/components/ClientSideLoggingToolMenu/ConsoleComponents.tsx
@@ -1,13 +1,15 @@
import React, {useCallback, useEffect, useMemo, useState} from 'react';
-import {ListRenderItem, ListRenderItemInfo, View} from 'react-native';
+import type {ListRenderItem, ListRenderItemInfo} from 'react-native';
+import {View} from 'react-native';
import CONST from "@src/CONST";
import useThemeStyles from "@hooks/useThemeStyles";
import useLocalize from "@hooks/useLocalize";
import InvertedFlatList from "@components/InvertedFlatList";
import Text from "@components/Text";
-import {CapturedLogs, Log} from "@src/types/onyx";
+import type {CapturedLogs, Log} from "@src/types/onyx";
import {format} from "date-fns";
-import {OnyxEntry, withOnyx} from "react-native-onyx";
+import {withOnyx} from "react-native-onyx";
+import type {OnyxEntry} from "react-native-onyx";
import ONYXKEYS from "@src/ONYXKEYS";
import {createLog, parseStringifiedMessages, sanitizeConsoleInput} from "@libs/Console";
import {addLog} from "@userActions/Console";
@@ -130,40 +132,6 @@ function ConsoleComponents({capturedLogs, shouldStoreLogs, onClose, isViaTestToo
/>
-
-
-
-
-
-
-
-
+ }} isViaTestToolsModal/>
);
diff --git a/src/components/TestToolsModal.tsx b/src/components/TestToolsModal.tsx
index 2d2ec9eb599d..aa05a56f3aaf 100644
--- a/src/components/TestToolsModal.tsx
+++ b/src/components/TestToolsModal.tsx
@@ -32,7 +32,7 @@ function TestToolsModal({isTestToolsModalOpen = false}: TestToolsModalProps) {
return (
diff --git a/src/languages/en.ts b/src/languages/en.ts
index 87864e7e65f1..730a71631a37 100755
--- a/src/languages/en.ts
+++ b/src/languages/en.ts
@@ -914,6 +914,7 @@ export default {
noLogsAvailable: 'No logs available',
logSizeTooLarge: ({size}: LogSizeParams) => `Log size exceeds the limit of ${size} MB. Please use "Save log" to download the log file instead.`,
logs: 'Logs',
+ viewConsole: 'View console',
},
security: 'Security',
signOut: 'Sign out',
diff --git a/src/languages/es.ts b/src/languages/es.ts
index 7572c7f7d28b..d6d89bcdea27 100644
--- a/src/languages/es.ts
+++ b/src/languages/es.ts
@@ -909,6 +909,7 @@ export default {
noLogsAvailable: 'No hay registros disponibles',
logSizeTooLarge: ({size}: LogSizeParams) => `El tamaño del registro excede el límite de ${size} MB. Utilice "Guardar registro" para descargar el archivo de registro.`,
logs: 'Logs',
+ viewConsole: 'Ver consola',
},
security: 'Seguridad',
restoreStashed: 'Restablecer login guardado',
From d9ec2143ec81fa277e606611a1b24d5b33540fda Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Mon, 22 Apr 2024 01:19:55 +0530
Subject: [PATCH 03/15] Fix number of taps
---
src/CONST.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/CONST.ts b/src/CONST.ts
index 4ded9e282d3e..893dc008786b 100755
--- a/src/CONST.ts
+++ b/src/CONST.ts
@@ -3101,7 +3101,7 @@ const CONST = {
// Test tool menu parameters
TEST_TOOL: {
// Number of concurrent taps to open then the Test modal menu
- NUMBER_OF_TAPS: 2,
+ NUMBER_OF_TAPS: 4,
},
MENU_HELP_URLS: {
From 64873ddd18eda80972b63c95c8518e29e308b3ef Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Mon, 22 Apr 2024 01:20:52 +0530
Subject: [PATCH 04/15] Fix test tools modal visibility condition
---
src/components/TestToolsModal.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/TestToolsModal.tsx b/src/components/TestToolsModal.tsx
index aa05a56f3aaf..2d2ec9eb599d 100644
--- a/src/components/TestToolsModal.tsx
+++ b/src/components/TestToolsModal.tsx
@@ -32,7 +32,7 @@ function TestToolsModal({isTestToolsModalOpen = false}: TestToolsModalProps) {
return (
From 65e43381b8e5f626618f315b338c6047202869d9 Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Mon, 22 Apr 2024 01:48:50 +0530
Subject: [PATCH 05/15] Typecheck fixes
---
.../BaseClientSideLoggingToolMenu.tsx | 14 +++++---
.../ConsoleComponents.tsx | 34 +++++++++++++++++++
.../ConsoleModal.tsx | 4 ++-
.../index.android.tsx | 3 +-
.../ClientSideLoggingToolMenu/index.ios.tsx | 3 +-
.../ClientSideLoggingToolMenu/index.tsx | 9 +++--
.../ClientSideLoggingToolMenu/types.ts | 8 +++++
src/pages/settings/AboutPage/ConsolePage.tsx | 9 +----
.../settings/AboutPage/ShareLogList/types.ts | 2 ++
9 files changed, 69 insertions(+), 17 deletions(-)
create mode 100644 src/components/ClientSideLoggingToolMenu/types.ts
diff --git a/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx b/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
index 0a64f8f6c353..297d63dbc7fe 100644
--- a/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
+++ b/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
@@ -32,7 +32,9 @@ type BaseClientSideLoggingToolProps = {
/** Action to run when enabling logging */
onEnableLogging?: () => void;
/** Boolean to know if this was opened via test tools modal */
- isViaTestToolsModal: boolean
+ isViaTestToolsModal: boolean;
+ /** Action to close the test tools modal */
+ closeTestToolsModal: () => void;
} & BaseClientSideLoggingToolMenuOnyxProps;
function BaseClientSideLoggingToolMenu({shouldStoreLogs, capturedLogs, file, onShareLogs, onDisableLogging, onEnableLogging, isViaTestToolsModal, closeTestToolsModal}: BaseClientSideLoggingToolProps) {
@@ -94,9 +96,13 @@ function BaseClientSideLoggingToolMenu({shouldStoreLogs, capturedLogs, file, onS
>
)}
- {
- setIsConsoleModalVisible(false)
- }} closeTestToolsModal={closeTestToolsModal}/>
+ {
+ setIsConsoleModalVisible(false)
+ }}
+ closeTestToolsModal={closeTestToolsModal}
+ />
>
);
}
diff --git a/src/components/ClientSideLoggingToolMenu/ConsoleComponents.tsx b/src/components/ClientSideLoggingToolMenu/ConsoleComponents.tsx
index b14a1e94c9f3..d7e53223c3a5 100644
--- a/src/components/ClientSideLoggingToolMenu/ConsoleComponents.tsx
+++ b/src/components/ClientSideLoggingToolMenu/ConsoleComponents.tsx
@@ -132,6 +132,40 @@ function ConsoleComponents({capturedLogs, shouldStoreLogs, onClose, isViaTestToo
/>
+
+
+
+
+
+
+
+
void;
+ onClose: () => void;
+ /** Action to close the test tools modal */
+ closeTestToolsModal: () => void;
};
diff --git a/src/components/ClientSideLoggingToolMenu/index.android.tsx b/src/components/ClientSideLoggingToolMenu/index.android.tsx
index 97cd9862fa20..8970f92bae17 100644
--- a/src/components/ClientSideLoggingToolMenu/index.android.tsx
+++ b/src/components/ClientSideLoggingToolMenu/index.android.tsx
@@ -4,8 +4,9 @@ import Share from 'react-native-share';
import type {Log} from '@libs/Console';
import localFileCreate from '@libs/localFileCreate';
import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu';
+import ClientSideLoggingToolMenuProps from "@components/ClientSideLoggingToolMenu/types";
-function ClientSideLoggingToolMenu({isViaTestToolsModal = false, closeTestToolsModal}) {
+function ClientSideLoggingToolMenu({isViaTestToolsModal = false, closeTestToolsModal}: ClientSideLoggingToolMenuProps) {
const [file, setFile] = useState<{path: string; newFileName: string; size: number}>();
const createAndSaveFile = (logs: Log[]) => {
diff --git a/src/components/ClientSideLoggingToolMenu/index.ios.tsx b/src/components/ClientSideLoggingToolMenu/index.ios.tsx
index 34adf8fdf244..1361be073b9f 100644
--- a/src/components/ClientSideLoggingToolMenu/index.ios.tsx
+++ b/src/components/ClientSideLoggingToolMenu/index.ios.tsx
@@ -3,8 +3,9 @@ import Share from 'react-native-share';
import type {Log} from '@libs/Console';
import localFileCreate from '@libs/localFileCreate';
import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu';
+import ClientSideLoggingToolMenuProps from "@components/ClientSideLoggingToolMenu/types";
-function ClientSideLoggingToolMenu({isViaTestToolsModal = false, closeTestToolsModal}) {
+function ClientSideLoggingToolMenu({isViaTestToolsModal = false, closeTestToolsModal}: ClientSideLoggingToolMenuProps) {
const [file, setFile] = useState<{path: string; newFileName: string; size: number}>();
const createFile = (logs: Log[]) => {
diff --git a/src/components/ClientSideLoggingToolMenu/index.tsx b/src/components/ClientSideLoggingToolMenu/index.tsx
index 99468ea32089..33b0343936fc 100644
--- a/src/components/ClientSideLoggingToolMenu/index.tsx
+++ b/src/components/ClientSideLoggingToolMenu/index.tsx
@@ -2,13 +2,18 @@ import React from 'react';
import type {Log} from '@libs/Console';
import localFileDownload from '@libs/localFileDownload';
import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu';
+import type ClientSideLoggingToolMenuProps from "@components/ClientSideLoggingToolMenu/types";
-function ClientSideLoggingToolMenu({isViaTestToolsModal = false}) {
+function ClientSideLoggingToolMenu({isViaTestToolsModal = false, closeTestToolsModal}: ClientSideLoggingToolMenuProps) {
const downloadFile = (logs: Log[]) => {
localFileDownload('logs', JSON.stringify(logs, null, 2));
};
- return ;
+ return ;
}
ClientSideLoggingToolMenu.displayName = 'ClientSideLoggingToolMenu';
diff --git a/src/components/ClientSideLoggingToolMenu/types.ts b/src/components/ClientSideLoggingToolMenu/types.ts
new file mode 100644
index 000000000000..0d5b9b43f977
--- /dev/null
+++ b/src/components/ClientSideLoggingToolMenu/types.ts
@@ -0,0 +1,8 @@
+type ClientSideLoggingToolMenuProps = {
+ /** Boolean to know if this was opened via test tools modal */
+ isViaTestToolsModal: boolean;
+ /** Action to close the test tools modal */
+ closeTestToolsModal: () => void;
+};
+
+export default ClientSideLoggingToolMenuProps;
diff --git a/src/pages/settings/AboutPage/ConsolePage.tsx b/src/pages/settings/AboutPage/ConsolePage.tsx
index 350b9c088dfe..bd1456b61fb4 100644
--- a/src/pages/settings/AboutPage/ConsolePage.tsx
+++ b/src/pages/settings/AboutPage/ConsolePage.tsx
@@ -24,11 +24,4 @@ function ConsolePage() {
ConsolePage.displayName = 'ConsolePage';
-export default withOnyx({
- capturedLogs: {
- key: ONYXKEYS.LOGS,
- },
- shouldStoreLogs: {
- key: ONYXKEYS.SHOULD_STORE_LOGS,
- },
-})(ConsolePage);
+export default ConsolePage;
diff --git a/src/pages/settings/AboutPage/ShareLogList/types.ts b/src/pages/settings/AboutPage/ShareLogList/types.ts
index 500641a3da42..eea65dd368a0 100644
--- a/src/pages/settings/AboutPage/ShareLogList/types.ts
+++ b/src/pages/settings/AboutPage/ShareLogList/types.ts
@@ -1,6 +1,8 @@
type ShareLogListProps = {
/** The source of the log file to share */
logSource: string;
+ /** Boolean to know if this was opened via test tools modal */
+ isViaTestToolsModal: boolean;
};
type BaseShareLogListProps = {
From 8af99fe5c7b06289132b7d04e7ca1f9dfce8379d Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Mon, 22 Apr 2024 19:46:45 +0530
Subject: [PATCH 06/15] Update
---
.../BaseClientSideLoggingToolMenu.tsx | 2 +-
src/components/ClientSideLoggingToolMenu/ConsoleModal.tsx | 8 ++++----
.../ClientSideLoggingToolMenu/index.android.tsx | 2 +-
src/components/ClientSideLoggingToolMenu/index.ios.tsx | 2 +-
src/components/ClientSideLoggingToolMenu/index.tsx | 4 ++--
src/components/ClientSideLoggingToolMenu/types.ts | 2 +-
src/pages/settings/AboutPage/ConsolePage.tsx | 4 +---
.../settings/AboutPage/ShareLogList/index.native.tsx | 2 +-
src/pages/settings/AboutPage/ShareLogList/index.tsx | 2 +-
src/pages/settings/AboutPage/ShareLogList/types.ts | 2 ++
src/pages/settings/AboutPage/ShareLogPage.tsx | 2 +-
src/pages/settings/Troubleshoot/TroubleshootPage.tsx | 2 +-
12 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx b/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
index 297d63dbc7fe..9b5faac55bc4 100644
--- a/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
+++ b/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
@@ -34,7 +34,7 @@ type BaseClientSideLoggingToolProps = {
/** Boolean to know if this was opened via test tools modal */
isViaTestToolsModal: boolean;
/** Action to close the test tools modal */
- closeTestToolsModal: () => void;
+ closeTestToolsModal?: () => void;
} & BaseClientSideLoggingToolMenuOnyxProps;
function BaseClientSideLoggingToolMenu({shouldStoreLogs, capturedLogs, file, onShareLogs, onDisableLogging, onEnableLogging, isViaTestToolsModal, closeTestToolsModal}: BaseClientSideLoggingToolProps) {
diff --git a/src/components/ClientSideLoggingToolMenu/ConsoleModal.tsx b/src/components/ClientSideLoggingToolMenu/ConsoleModal.tsx
index 89aef6353f82..4d405db69226 100644
--- a/src/components/ClientSideLoggingToolMenu/ConsoleModal.tsx
+++ b/src/components/ClientSideLoggingToolMenu/ConsoleModal.tsx
@@ -12,7 +12,7 @@ type ConsoleModalProps = {
/** Action to run when pressing Share button */
onClose: () => void;
/** Action to close the test tools modal */
- closeTestToolsModal: () => void;
+ closeTestToolsModal?: () => void;
};
@@ -29,10 +29,10 @@ function ConsoleModal({isVisible, onClose, closeTestToolsModal}: ConsoleModalPro
{
- if (onClose) {
- onClose()
+ onClose()
+ if (closeTestToolsModal) {
+ closeTestToolsModal()
}
- closeTestToolsModal()
}} isViaTestToolsModal/>
diff --git a/src/components/ClientSideLoggingToolMenu/index.android.tsx b/src/components/ClientSideLoggingToolMenu/index.android.tsx
index 8970f92bae17..272c563f8e91 100644
--- a/src/components/ClientSideLoggingToolMenu/index.android.tsx
+++ b/src/components/ClientSideLoggingToolMenu/index.android.tsx
@@ -4,7 +4,7 @@ import Share from 'react-native-share';
import type {Log} from '@libs/Console';
import localFileCreate from '@libs/localFileCreate';
import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu';
-import ClientSideLoggingToolMenuProps from "@components/ClientSideLoggingToolMenu/types";
+import type ClientSideLoggingToolMenuProps from "./types";
function ClientSideLoggingToolMenu({isViaTestToolsModal = false, closeTestToolsModal}: ClientSideLoggingToolMenuProps) {
const [file, setFile] = useState<{path: string; newFileName: string; size: number}>();
diff --git a/src/components/ClientSideLoggingToolMenu/index.ios.tsx b/src/components/ClientSideLoggingToolMenu/index.ios.tsx
index 1361be073b9f..f5de90b00140 100644
--- a/src/components/ClientSideLoggingToolMenu/index.ios.tsx
+++ b/src/components/ClientSideLoggingToolMenu/index.ios.tsx
@@ -3,7 +3,7 @@ import Share from 'react-native-share';
import type {Log} from '@libs/Console';
import localFileCreate from '@libs/localFileCreate';
import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu';
-import ClientSideLoggingToolMenuProps from "@components/ClientSideLoggingToolMenu/types";
+import type ClientSideLoggingToolMenuProps from "./types";
function ClientSideLoggingToolMenu({isViaTestToolsModal = false, closeTestToolsModal}: ClientSideLoggingToolMenuProps) {
const [file, setFile] = useState<{path: string; newFileName: string; size: number}>();
diff --git a/src/components/ClientSideLoggingToolMenu/index.tsx b/src/components/ClientSideLoggingToolMenu/index.tsx
index 33b0343936fc..9cb86b46b797 100644
--- a/src/components/ClientSideLoggingToolMenu/index.tsx
+++ b/src/components/ClientSideLoggingToolMenu/index.tsx
@@ -1,10 +1,10 @@
import React from 'react';
import type {Log} from '@libs/Console';
import localFileDownload from '@libs/localFileDownload';
+import type ClientSideLoggingToolMenuProps from "./types";
import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu';
-import type ClientSideLoggingToolMenuProps from "@components/ClientSideLoggingToolMenu/types";
-function ClientSideLoggingToolMenu({isViaTestToolsModal = false, closeTestToolsModal}: ClientSideLoggingToolMenuProps) {
+function ClientSideLoggingToolMenu({isViaTestToolsModal, closeTestToolsModal}: ClientSideLoggingToolMenuProps) {
const downloadFile = (logs: Log[]) => {
localFileDownload('logs', JSON.stringify(logs, null, 2));
};
diff --git a/src/components/ClientSideLoggingToolMenu/types.ts b/src/components/ClientSideLoggingToolMenu/types.ts
index 0d5b9b43f977..86ad66dfd33c 100644
--- a/src/components/ClientSideLoggingToolMenu/types.ts
+++ b/src/components/ClientSideLoggingToolMenu/types.ts
@@ -2,7 +2,7 @@ type ClientSideLoggingToolMenuProps = {
/** Boolean to know if this was opened via test tools modal */
isViaTestToolsModal: boolean;
/** Action to close the test tools modal */
- closeTestToolsModal: () => void;
+ closeTestToolsModal?: () => void;
};
export default ClientSideLoggingToolMenuProps;
diff --git a/src/pages/settings/AboutPage/ConsolePage.tsx b/src/pages/settings/AboutPage/ConsolePage.tsx
index bd1456b61fb4..48847757dac4 100644
--- a/src/pages/settings/AboutPage/ConsolePage.tsx
+++ b/src/pages/settings/AboutPage/ConsolePage.tsx
@@ -1,10 +1,8 @@
import React from 'react';
-import {withOnyx} from 'react-native-onyx';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
import useLocalize from '@hooks/useLocalize';
import Navigation from '@libs/Navigation/Navigation';
-import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import ConsoleComponents from "@components/ClientSideLoggingToolMenu/ConsoleComponents";
@@ -17,7 +15,7 @@ function ConsolePage() {
title={translate('initialSettingsPage.troubleshoot.debugConsole')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_TROUBLESHOOT)}
/>
-
+
);
}
diff --git a/src/pages/settings/AboutPage/ShareLogList/index.native.tsx b/src/pages/settings/AboutPage/ShareLogList/index.native.tsx
index 3badbe33b200..720209fe9fd2 100644
--- a/src/pages/settings/AboutPage/ShareLogList/index.native.tsx
+++ b/src/pages/settings/AboutPage/ShareLogList/index.native.tsx
@@ -5,7 +5,7 @@ import ROUTES from '@src/ROUTES';
import BaseShareLogList from './BaseShareLogList';
import type {ShareLogListProps} from './types';
-function ShareLogList({logSource, isViaTestToolsModal = false}: ShareLogListProps) {
+function ShareLogList({logSource, isViaTestToolsModal}: ShareLogListProps) {
const onAttachLogToReport = (reportID: string, filename: string) => {
if (!reportID || !logSource) {
return;
diff --git a/src/pages/settings/AboutPage/ShareLogList/index.tsx b/src/pages/settings/AboutPage/ShareLogList/index.tsx
index 87657575a35c..e7bf191306d7 100644
--- a/src/pages/settings/AboutPage/ShareLogList/index.tsx
+++ b/src/pages/settings/AboutPage/ShareLogList/index.tsx
@@ -6,7 +6,7 @@ import ROUTES from '@src/ROUTES';
import BaseShareLogList from './BaseShareLogList';
import type {ShareLogListProps} from './types';
-function ShareLogList({logSource, isViaTestToolsModal = false}: ShareLogListProps) {
+function ShareLogList({logSource, isViaTestToolsModal}: ShareLogListProps) {
const onAttachLogToReport = (reportID: string, filename: string) => {
FileUtils.readFileAsync(
logSource,
diff --git a/src/pages/settings/AboutPage/ShareLogList/types.ts b/src/pages/settings/AboutPage/ShareLogList/types.ts
index eea65dd368a0..bab48c39cc27 100644
--- a/src/pages/settings/AboutPage/ShareLogList/types.ts
+++ b/src/pages/settings/AboutPage/ShareLogList/types.ts
@@ -7,6 +7,8 @@ type ShareLogListProps = {
type BaseShareLogListProps = {
onAttachLogToReport: (reportID: string, filename: string) => void;
+ /** Boolean to know if this was opened via test tools modal */
+ isViaTestToolsModal: boolean;
};
export type {BaseShareLogListProps, ShareLogListProps};
diff --git a/src/pages/settings/AboutPage/ShareLogPage.tsx b/src/pages/settings/AboutPage/ShareLogPage.tsx
index 5c402f023819..7123746059ea 100644
--- a/src/pages/settings/AboutPage/ShareLogPage.tsx
+++ b/src/pages/settings/AboutPage/ShareLogPage.tsx
@@ -7,7 +7,7 @@ import ShareLogList from './ShareLogList';
type ShareLogPageProps = StackScreenProps;
function ShareLogPage({route}: ShareLogPageProps) {
- return ;
+ return ;
}
export default ShareLogPage;
diff --git a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx
index b2523a4e039c..e14d4ac13bb3 100644
--- a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx
+++ b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx
@@ -119,7 +119,7 @@ function TroubleshootPage({shouldStoreLogs}: TroubleshootPageProps) {
>
-
+
Date: Mon, 29 Apr 2024 16:57:03 +0530
Subject: [PATCH 07/15] Navigate to console page
---
src/CONST.ts | 1 -
src/ROUTES.ts | 5 +-
.../BaseClientSideLoggingToolMenu.tsx | 22 +-
.../ConsoleComponents.tsx | 193 ------------------
.../ConsoleModal.tsx | 44 ----
.../index.android.tsx | 2 +-
.../ClientSideLoggingToolMenu/index.ios.tsx | 2 +-
.../ClientSideLoggingToolMenu/index.tsx | 2 +-
.../ClientSideLoggingToolMenu/types.ts | 2 -
src/components/Modal/index.tsx | 2 +-
src/components/TestToolsModal.tsx | 5 +-
src/libs/Navigation/linkingConfig/config.ts | 2 +-
src/libs/Navigation/types.ts | 4 +-
src/pages/settings/AboutPage/ConsolePage.tsx | 179 +++++++++++++++-
.../ShareLogList/BaseShareLogList.tsx | 8 +-
.../AboutPage/ShareLogList/index.native.tsx | 4 +-
.../settings/AboutPage/ShareLogList/index.tsx | 7 +-
src/pages/settings/AboutPage/ShareLogPage.tsx | 7 +-
.../Troubleshoot/TroubleshootPage.tsx | 2 +-
.../utils/generators/ModalStyleUtils.ts | 23 ---
20 files changed, 214 insertions(+), 302 deletions(-)
delete mode 100644 src/components/ClientSideLoggingToolMenu/ConsoleComponents.tsx
delete mode 100644 src/components/ClientSideLoggingToolMenu/ConsoleModal.tsx
diff --git a/src/CONST.ts b/src/CONST.ts
index 893dc008786b..2cd614b74816 100755
--- a/src/CONST.ts
+++ b/src/CONST.ts
@@ -860,7 +860,6 @@ const CONST = {
POPOVER: 'popover',
RIGHT_DOCKED: 'right_docked',
ONBOARDING: 'onboarding',
- CENTERED_SMALL_AND_UNSWIPEABLE: 'centered_small_and_unswipeable'
},
ANCHOR_ORIGIN_VERTICAL: {
TOP: 'top',
diff --git a/src/ROUTES.ts b/src/ROUTES.ts
index 71e673aea994..db9ae77fd0e8 100644
--- a/src/ROUTES.ts
+++ b/src/ROUTES.ts
@@ -172,7 +172,10 @@ const ROUTES = {
SETTINGS_STATUS_CLEAR_AFTER_DATE: 'settings/profile/status/clear-after/date',
SETTINGS_STATUS_CLEAR_AFTER_TIME: 'settings/profile/status/clear-after/time',
SETTINGS_TROUBLESHOOT: 'settings/troubleshoot',
- SETTINGS_CONSOLE: 'settings/troubleshoot/console',
+ SETTINGS_CONSOLE: {
+ route: 'settings/troubleshoot/console',
+ getRoute: (isViaTestToolsModal = false) => `settings/troubleshoot/console?isViaTestToolsModal=${isViaTestToolsModal}` as const,
+ },
SETTINGS_SHARE_LOG: {
route: 'settings/troubleshoot/console/share-log',
getRoute: (source: string, isViaTestToolsModal = false) => `settings/troubleshoot/console/share-log?source=${encodeURI(source)}&isViaTestToolsModal=${isViaTestToolsModal}` as const,
diff --git a/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx b/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
index 9b5faac55bc4..7d27caa997f7 100644
--- a/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
+++ b/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
@@ -1,4 +1,4 @@
-import React, {useState} from 'react';
+import React from 'react';
import {Alert} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
@@ -12,7 +12,8 @@ import * as Console from '@libs/actions/Console';
import {parseStringifiedMessages} from '@libs/Console';
import ONYXKEYS from '@src/ONYXKEYS';
import type {CapturedLogs, Log} from '@src/types/onyx';
-import ConsoleModal from "./ConsoleModal";
+import Navigation from "@navigation/Navigation";
+import ROUTES from "@src/ROUTES";
type BaseClientSideLoggingToolMenuOnyxProps = {
/** Logs captured on the current device */
@@ -64,7 +65,6 @@ function BaseClientSideLoggingToolMenu({shouldStoreLogs, capturedLogs, file, onS
Console.disableLoggingAndFlushLogs();
};
const styles = useThemeStyles();
- const [isConsoleModalVisible, setIsConsoleModalVisible] = useState(false);
return (
<>
@@ -75,15 +75,18 @@ function BaseClientSideLoggingToolMenu({shouldStoreLogs, capturedLogs, file, onS
onToggle={onToggle}
/>
- {!!shouldStoreLogs && isViaTestToolsModal &&
+ {!!shouldStoreLogs && isViaTestToolsModal && (
- }
+ )}
{!!file && (
<>
{`path: ${file.path}`}
@@ -96,13 +99,6 @@ function BaseClientSideLoggingToolMenu({shouldStoreLogs, capturedLogs, file, onS
>
)}
- {
- setIsConsoleModalVisible(false)
- }}
- closeTestToolsModal={closeTestToolsModal}
- />
>
);
}
diff --git a/src/components/ClientSideLoggingToolMenu/ConsoleComponents.tsx b/src/components/ClientSideLoggingToolMenu/ConsoleComponents.tsx
deleted file mode 100644
index d7e53223c3a5..000000000000
--- a/src/components/ClientSideLoggingToolMenu/ConsoleComponents.tsx
+++ /dev/null
@@ -1,193 +0,0 @@
-import React, {useCallback, useEffect, useMemo, useState} from 'react';
-import type {ListRenderItem, ListRenderItemInfo} from 'react-native';
-import {View} from 'react-native';
-import CONST from "@src/CONST";
-import useThemeStyles from "@hooks/useThemeStyles";
-import useLocalize from "@hooks/useLocalize";
-import InvertedFlatList from "@components/InvertedFlatList";
-import Text from "@components/Text";
-import type {CapturedLogs, Log} from "@src/types/onyx";
-import {format} from "date-fns";
-import {withOnyx} from "react-native-onyx";
-import type {OnyxEntry} from "react-native-onyx";
-import ONYXKEYS from "@src/ONYXKEYS";
-import {createLog, parseStringifiedMessages, sanitizeConsoleInput} from "@libs/Console";
-import {addLog} from "@userActions/Console";
-import useKeyboardShortcut from "@hooks/useKeyboardShortcut";
-import localFileDownload from "@libs/localFileDownload";
-import localFileCreate from "@libs/localFileCreate";
-import Navigation from "@navigation/Navigation";
-import ROUTES from "@src/ROUTES";
-import Button from "@components/Button";
-import * as Expensicons from "@components/Icon/Expensicons";
-import TextInput from "@components/TextInput";
-import ConfirmModal from "@components/ConfirmModal";
-
-type ConsoleComponentsOnyxProps = {
- /** Logs captured on the current device */
- capturedLogs: OnyxEntry;
-
- /** Whether or not logs should be stored */
- shouldStoreLogs: OnyxEntry;
-};
-
-type ConsoleComponentsProps = {
- /** Action to run when pressing Share button */
- onClose?: () => void;
- /** Boolean to know if console logs have been opened via test tools modal */
- isViaTestToolsModal: boolean
-} & ConsoleComponentsOnyxProps;
-
-
-function ConsoleComponents({capturedLogs, shouldStoreLogs, onClose, isViaTestToolsModal}: ConsoleComponentsProps) {
- const styles = useThemeStyles();
- const {translate} = useLocalize();
-
- const [input, setInput] = useState('');
- const [logs, setLogs] = useState(capturedLogs);
- const [isGeneratingLogsFile, setIsGeneratingLogsFile] = useState(false);
- const [isLimitModalVisible, setIsLimitModalVisible] = useState(false);
-
- const logsList = useMemo(
- () =>
- Object.entries(logs ?? {})
- .map(([key, value]) => ({key, ...value}))
- .reverse(),
- [logs],
- );
-
- useEffect(() => {
- if (!shouldStoreLogs) {
- return;
- }
-
- setLogs((prevLogs) => ({...prevLogs, ...capturedLogs}));
- }, [capturedLogs, shouldStoreLogs]);
-
- const renderItem: ListRenderItem = useCallback(
- ({item}: ListRenderItemInfo) => {
- if (!item) {
- return null;
- }
-
- return (
-
- {`${format(new Date(item.time), CONST.DATE.FNS_DB_FORMAT_STRING)} ${item.message}`}
-
- );
- },
- [styles.mb2],
- );
-
- const executeArbitraryCode = () => {
- const sanitizedInput = sanitizeConsoleInput(input);
-
- const output = createLog(sanitizedInput);
- output.forEach((log) => addLog(log));
- setInput('');
- };
-
- useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.ENTER, executeArbitraryCode);
-
- const saveLogs = () => {
- const logsWithParsedMessages = parseStringifiedMessages(logsList);
-
- localFileDownload('logs', JSON.stringify(logsWithParsedMessages, null, 2));
- };
-
- const shareLogs = () => {
- setIsGeneratingLogsFile(true);
- const logsWithParsedMessages = parseStringifiedMessages(logsList);
-
- // Generate a file with the logs and pass its path to the list of reports to share it with
- localFileCreate('logs', JSON.stringify(logsWithParsedMessages, null, 2)).then(({path, size}) => {
- setIsGeneratingLogsFile(false);
-
- // if the file size is too large to send it as an attachment, show a modal and return
- if (size > CONST.API_ATTACHMENT_VALIDATIONS.MAX_SIZE) {
- setIsLimitModalVisible(true);
-
- return;
- }
-
- if (onClose) {
- onClose()
- }
- Navigation.navigate(ROUTES.SETTINGS_SHARE_LOG.getRoute(path, isViaTestToolsModal));
- });
- };
-
- const mhModal = isViaTestToolsModal ? styles.mh2 : undefined;
-
- return (
- <>
-
-
- {translate('initialSettingsPage.debugConsole.noLogsAvailable')}}
- />
-
-
-
-
-
-
-
-
-
-
- setIsLimitModalVisible(false)}
- prompt={translate('initialSettingsPage.debugConsole.logSizeTooLarge', {
- size: CONST.API_ATTACHMENT_VALIDATIONS.MAX_SIZE / 1024 / 1024,
- })}
- shouldShowCancelButton={false}
- confirmText={translate('common.ok')}
- />
- >
- );
-}
-
-ConsoleComponents.displayName = 'ConsoleModal';
-
-
-export default withOnyx({
- capturedLogs: {
- key: ONYXKEYS.LOGS,
- },
- shouldStoreLogs: {
- key: ONYXKEYS.SHOULD_STORE_LOGS,
- },
-})(ConsoleComponents);
diff --git a/src/components/ClientSideLoggingToolMenu/ConsoleModal.tsx b/src/components/ClientSideLoggingToolMenu/ConsoleModal.tsx
deleted file mode 100644
index 4d405db69226..000000000000
--- a/src/components/ClientSideLoggingToolMenu/ConsoleModal.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-import React from 'react';
-import {View} from 'react-native';
-import CONST from "@src/CONST";
-import Modal from "@components/Modal";
-import useWindowDimensions from "@hooks/useWindowDimensions";
-import useStyleUtils from "@hooks/useStyleUtils";
-import ConsoleComponents from "./ConsoleComponents";
-
-type ConsoleModalProps = {
- /** Locally created file */
- isVisible: boolean
- /** Action to run when pressing Share button */
- onClose: () => void;
- /** Action to close the test tools modal */
- closeTestToolsModal?: () => void;
-};
-
-
-function ConsoleModal({isVisible, onClose, closeTestToolsModal}: ConsoleModalProps) {
- const {windowWidth, windowHeight} = useWindowDimensions();
- const StyleUtils = useStyleUtils();
-
- return (
-
-
-
- {
- onClose()
- if (closeTestToolsModal) {
- closeTestToolsModal()
- }
- }} isViaTestToolsModal/>
-
-
- );
-}
-
-ConsoleModal.displayName = 'ConsoleModal';
-
-export default ConsoleModal;
diff --git a/src/components/ClientSideLoggingToolMenu/index.android.tsx b/src/components/ClientSideLoggingToolMenu/index.android.tsx
index 272c563f8e91..b31a9244005d 100644
--- a/src/components/ClientSideLoggingToolMenu/index.android.tsx
+++ b/src/components/ClientSideLoggingToolMenu/index.android.tsx
@@ -4,7 +4,7 @@ import Share from 'react-native-share';
import type {Log} from '@libs/Console';
import localFileCreate from '@libs/localFileCreate';
import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu';
-import type ClientSideLoggingToolMenuProps from "./types";
+import type ClientSideLoggingToolMenuProps from './types';
function ClientSideLoggingToolMenu({isViaTestToolsModal = false, closeTestToolsModal}: ClientSideLoggingToolMenuProps) {
const [file, setFile] = useState<{path: string; newFileName: string; size: number}>();
diff --git a/src/components/ClientSideLoggingToolMenu/index.ios.tsx b/src/components/ClientSideLoggingToolMenu/index.ios.tsx
index f5de90b00140..e1ad9778830b 100644
--- a/src/components/ClientSideLoggingToolMenu/index.ios.tsx
+++ b/src/components/ClientSideLoggingToolMenu/index.ios.tsx
@@ -3,7 +3,7 @@ import Share from 'react-native-share';
import type {Log} from '@libs/Console';
import localFileCreate from '@libs/localFileCreate';
import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu';
-import type ClientSideLoggingToolMenuProps from "./types";
+import type ClientSideLoggingToolMenuProps from './types';
function ClientSideLoggingToolMenu({isViaTestToolsModal = false, closeTestToolsModal}: ClientSideLoggingToolMenuProps) {
const [file, setFile] = useState<{path: string; newFileName: string; size: number}>();
diff --git a/src/components/ClientSideLoggingToolMenu/index.tsx b/src/components/ClientSideLoggingToolMenu/index.tsx
index 9cb86b46b797..83f28c581b40 100644
--- a/src/components/ClientSideLoggingToolMenu/index.tsx
+++ b/src/components/ClientSideLoggingToolMenu/index.tsx
@@ -1,8 +1,8 @@
import React from 'react';
import type {Log} from '@libs/Console';
import localFileDownload from '@libs/localFileDownload';
-import type ClientSideLoggingToolMenuProps from "./types";
import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu';
+import type ClientSideLoggingToolMenuProps from './types';
function ClientSideLoggingToolMenu({isViaTestToolsModal, closeTestToolsModal}: ClientSideLoggingToolMenuProps) {
const downloadFile = (logs: Log[]) => {
diff --git a/src/components/ClientSideLoggingToolMenu/types.ts b/src/components/ClientSideLoggingToolMenu/types.ts
index 86ad66dfd33c..4c29a48a9003 100644
--- a/src/components/ClientSideLoggingToolMenu/types.ts
+++ b/src/components/ClientSideLoggingToolMenu/types.ts
@@ -1,8 +1,6 @@
type ClientSideLoggingToolMenuProps = {
/** Boolean to know if this was opened via test tools modal */
isViaTestToolsModal: boolean;
- /** Action to close the test tools modal */
- closeTestToolsModal?: () => void;
};
export default ClientSideLoggingToolMenuProps;
diff --git a/src/components/Modal/index.tsx b/src/components/Modal/index.tsx
index 5c31ac60d39d..76f4b251ec83 100644
--- a/src/components/Modal/index.tsx
+++ b/src/components/Modal/index.tsx
@@ -34,7 +34,7 @@ function Modal({fullscreen = true, onModalHide = () => {}, type, onModalShow = (
const showModal = () => {
const statusBarColor = StatusBar.getBackgroundColor() ?? theme.appBG;
- const isFullScreenModal = type === CONST.MODAL.MODAL_TYPE.CENTERED || type === CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE || type === CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED || type === CONST.MODAL.MODAL_TYPE.CENTERED_SMALL_AND_UNSWIPEABLE;
+ const isFullScreenModal = type === CONST.MODAL.MODAL_TYPE.CENTERED || type === CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE || type === CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED;
if (statusBarColor) {
setPreviousStatusBarColor(statusBarColor);
diff --git a/src/components/TestToolsModal.tsx b/src/components/TestToolsModal.tsx
index 2d2ec9eb599d..f9107a5a269a 100644
--- a/src/components/TestToolsModal.tsx
+++ b/src/components/TestToolsModal.tsx
@@ -45,7 +45,10 @@ function TestToolsModal({isTestToolsModalOpen = false}: TestToolsModalProps) {
{translate('initialSettingsPage.troubleshoot.releaseOptions')}
-
+
);
diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts
index b0c4da6fbdbc..0ee8a1153407 100644
--- a/src/libs/Navigation/linkingConfig/config.ts
+++ b/src/libs/Navigation/linkingConfig/config.ts
@@ -209,7 +209,7 @@ const config: LinkingOptions['config'] = {
exact: true,
},
[SCREENS.SETTINGS.CONSOLE]: {
- path: ROUTES.SETTINGS_CONSOLE,
+ path: ROUTES.SETTINGS_CONSOLE.route,
exact: true,
},
[SCREENS.SETTINGS.SHARE_LOG]: ROUTES.SETTINGS_SHARE_LOG.route,
diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts
index 492df5354613..8b0146a7f918 100644
--- a/src/libs/Navigation/types.ts
+++ b/src/libs/Navigation/types.ts
@@ -111,7 +111,9 @@ type SettingsNavigatorParamList = {
[SCREENS.SETTINGS.TROUBLESHOOT]: undefined;
[SCREENS.SETTINGS.APP_DOWNLOAD_LINKS]: undefined;
[SCREENS.SETTINGS.TROUBLESHOOT]: undefined;
- [SCREENS.SETTINGS.CONSOLE]: undefined;
+ [SCREENS.SETTINGS.CONSOLE]: {
+ isViaTestToolsModal: boolean;
+ };
[SCREENS.SETTINGS.SHARE_LOG]: {
/** URL of the generated file to share logs in a report */
source: string;
diff --git a/src/pages/settings/AboutPage/ConsolePage.tsx b/src/pages/settings/AboutPage/ConsolePage.tsx
index 48847757dac4..2bd9ad53a544 100644
--- a/src/pages/settings/AboutPage/ConsolePage.tsx
+++ b/src/pages/settings/AboutPage/ConsolePage.tsx
@@ -1,25 +1,192 @@
-import React from 'react';
+import {format} from 'date-fns';
+import React, {useCallback, useEffect, useMemo, useState} from 'react';
+import {View} from 'react-native';
+import type {ListRenderItem, ListRenderItemInfo} from 'react-native';
+import {withOnyx} from 'react-native-onyx';
+import type {OnyxEntry} from 'react-native-onyx';
+import Button from '@components/Button';
+import ConfirmModal from '@components/ConfirmModal';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
+import * as Expensicons from '@components/Icon/Expensicons';
+import InvertedFlatList from '@components/InvertedFlatList';
import ScreenWrapper from '@components/ScreenWrapper';
+import Text from '@components/Text';
+import TextInput from '@components/TextInput';
+import useKeyboardShortcut from '@hooks/useKeyboardShortcut';
import useLocalize from '@hooks/useLocalize';
+import useThemeStyles from '@hooks/useThemeStyles';
+import {addLog} from '@libs/actions/Console';
+import {createLog, parseStringifiedMessages, sanitizeConsoleInput} from '@libs/Console';
+import type {Log} from '@libs/Console';
+import localFileCreate from '@libs/localFileCreate';
+import localFileDownload from '@libs/localFileDownload';
import Navigation from '@libs/Navigation/Navigation';
+import CONST from '@src/CONST';
+import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
-import ConsoleComponents from "@components/ClientSideLoggingToolMenu/ConsoleComponents";
+import type {CapturedLogs} from '@src/types/onyx';
+import {RouteProp, useRoute} from "@react-navigation/native";
+import {SettingsNavigatorParamList} from "@navigation/types";
+import SCREENS from "@src/SCREENS";
-function ConsolePage() {
+type ConsolePageOnyxProps = {
+ /** Logs captured on the current device */
+ capturedLogs: OnyxEntry;
+
+ /** Whether or not logs should be stored */
+ shouldStoreLogs: OnyxEntry;
+};
+
+type ConsolePageProps = ConsolePageOnyxProps;
+
+function ConsolePage({capturedLogs, shouldStoreLogs}: ConsolePageProps) {
+ const [input, setInput] = useState('');
+ const [logs, setLogs] = useState(capturedLogs);
+ const [isGeneratingLogsFile, setIsGeneratingLogsFile] = useState(false);
+ const [isLimitModalVisible, setIsLimitModalVisible] = useState(false);
const {translate} = useLocalize();
+ const styles = useThemeStyles();
+
+ const route = useRoute>();
+ const isViaTestToolsModal = route.params?.isViaTestToolsModal ?? false;
+
+ const logsList = useMemo(
+ () =>
+ Object.entries(logs ?? {})
+ .map(([key, value]) => ({key, ...value}))
+ .reverse(),
+ [logs],
+ );
+
+ useEffect(() => {
+ if (!shouldStoreLogs) {
+ return;
+ }
+
+ setLogs((prevLogs) => ({...prevLogs, ...capturedLogs}));
+ }, [capturedLogs, shouldStoreLogs]);
+
+ const executeArbitraryCode = () => {
+ const sanitizedInput = sanitizeConsoleInput(input);
+
+ const output = createLog(sanitizedInput);
+ output.forEach((log) => addLog(log));
+ setInput('');
+ };
+
+ useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.ENTER, executeArbitraryCode);
+
+ const saveLogs = () => {
+ const logsWithParsedMessages = parseStringifiedMessages(logsList);
+
+ localFileDownload('logs', JSON.stringify(logsWithParsedMessages, null, 2));
+ };
+
+ const shareLogs = () => {
+ setIsGeneratingLogsFile(true);
+ const logsWithParsedMessages = parseStringifiedMessages(logsList);
+
+ // Generate a file with the logs and pass its path to the list of reports to share it with
+ localFileCreate('logs', JSON.stringify(logsWithParsedMessages, null, 2)).then(({path, size}) => {
+ setIsGeneratingLogsFile(false);
+
+ // if the file size is too large to send it as an attachment, show a modal and return
+ if (size > CONST.API_ATTACHMENT_VALIDATIONS.MAX_SIZE) {
+ setIsLimitModalVisible(true);
+
+ return;
+ }
+
+ Navigation.navigate(ROUTES.SETTINGS_SHARE_LOG.getRoute(path, isViaTestToolsModal));
+ });
+ };
+
+ const renderItem: ListRenderItem = useCallback(
+ ({item}: ListRenderItemInfo) => {
+ if (!item) {
+ return null;
+ }
+
+ return (
+
+ {`${format(new Date(item.time), CONST.DATE.FNS_DB_FORMAT_STRING)} ${item.message}`}
+
+ );
+ },
+ [styles.mb2],
+ );
return (
Navigation.goBack(ROUTES.SETTINGS_TROUBLESHOOT)}
+ onBackButtonPress={() => {
+ Navigation.goBack(isViaTestToolsModal ? undefined : ROUTES.SETTINGS_TROUBLESHOOT)
+ }}
+ />
+
+ {translate('initialSettingsPage.debugConsole.noLogsAvailable')}}
+ />
+
+
+
+
+
+
+
+
+
+ setIsLimitModalVisible(false)}
+ prompt={translate('initialSettingsPage.debugConsole.logSizeTooLarge', {
+ size: CONST.API_ATTACHMENT_VALIDATIONS.MAX_SIZE / 1024 / 1024,
+ })}
+ shouldShowCancelButton={false}
+ confirmText={translate('common.ok')}
/>
-
);
}
ConsolePage.displayName = 'ConsolePage';
-export default ConsolePage;
+export default withOnyx({
+ capturedLogs: {
+ key: ONYXKEYS.LOGS,
+ },
+ shouldStoreLogs: {
+ key: ONYXKEYS.SHOULD_STORE_LOGS,
+ },
+})(ConsolePage);
diff --git a/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx b/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx
index 58ddac79321b..3e8a9daadd3d 100644
--- a/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx
+++ b/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx
@@ -91,13 +91,7 @@ function BaseShareLogList({onAttachLogToReport, isViaTestToolsModal = false}: Ba
<>
{
- if (isViaTestToolsModal) {
- Navigation.goBack();
- return;
- }
- Navigation.goBack(ROUTES.SETTINGS_CONSOLE)
- }}
+ onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_CONSOLE.getRoute(isViaTestToolsModal))}
/>
{
if (!reportID || !logSource) {
return;
@@ -17,7 +17,7 @@ function ShareLogList({logSource, isViaTestToolsModal}: ShareLogListProps) {
Navigation.navigate(routeToNavigate);
};
- return ;
+ return ;
}
export default ShareLogList;
diff --git a/src/pages/settings/AboutPage/ShareLogList/index.tsx b/src/pages/settings/AboutPage/ShareLogList/index.tsx
index e7bf191306d7..03cd7c42f73c 100644
--- a/src/pages/settings/AboutPage/ShareLogList/index.tsx
+++ b/src/pages/settings/AboutPage/ShareLogList/index.tsx
@@ -20,7 +20,12 @@ function ShareLogList({logSource, isViaTestToolsModal}: ShareLogListProps) {
() => {},
);
};
- return ;
+ return (
+
+ );
}
export default ShareLogList;
diff --git a/src/pages/settings/AboutPage/ShareLogPage.tsx b/src/pages/settings/AboutPage/ShareLogPage.tsx
index 7123746059ea..7688ade3ccd1 100644
--- a/src/pages/settings/AboutPage/ShareLogPage.tsx
+++ b/src/pages/settings/AboutPage/ShareLogPage.tsx
@@ -7,7 +7,12 @@ import ShareLogList from './ShareLogList';
type ShareLogPageProps = StackScreenProps;
function ShareLogPage({route}: ShareLogPageProps) {
- return ;
+ return (
+
+ );
}
export default ShareLogPage;
diff --git a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx
index e14d4ac13bb3..b463ba02f4d3 100644
--- a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx
+++ b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx
@@ -55,7 +55,7 @@ function TroubleshootPage({shouldStoreLogs}: TroubleshootPageProps) {
const debugConsoleItem: BaseMenuItem = {
translationKey: 'initialSettingsPage.troubleshoot.viewConsole',
icon: Expensicons.Gear,
- action: waitForNavigate(() => Navigation.navigate(ROUTES.SETTINGS_CONSOLE)),
+ action: waitForNavigate(() => Navigation.navigate(ROUTES.SETTINGS_CONSOLE.getRoute(false))),
};
const baseMenuItems: BaseMenuItem[] = [
diff --git a/src/styles/utils/generators/ModalStyleUtils.ts b/src/styles/utils/generators/ModalStyleUtils.ts
index 94b39a400367..335ef8382941 100644
--- a/src/styles/utils/generators/ModalStyleUtils.ts
+++ b/src/styles/utils/generators/ModalStyleUtils.ts
@@ -164,29 +164,6 @@ const createModalStyleUtils: StyleUtilGenerator = ({the
shouldAddTopSafeAreaPadding = false;
shouldAddBottomSafeAreaPadding = false;
break;
- case CONST.MODAL.MODAL_TYPE.CENTERED_SMALL_AND_UNSWIPEABLE:
- // A centered modal that takes up the minimum possible screen space on all devices and is unswipeable
- modalStyle = {
- ...modalStyle,
- ...{
- alignItems: 'center',
- },
- };
- modalContainerStyle = {
- boxShadow: '0px 0px 5px 5px rgba(0, 0, 0, 0.1)',
- borderRadius: 12,
- borderWidth: 0,
- };
-
- // Allow this modal to be dismissed with a swipe down or swipe right
- swipeDirection = undefined;
- animationIn = isSmallScreenWidth ? 'slideInRight' : 'fadeIn';
- animationOut = isSmallScreenWidth ? 'slideOutRight' : 'fadeOut';
- shouldAddTopSafeAreaMargin = false;
- shouldAddBottomSafeAreaMargin = false;
- shouldAddTopSafeAreaPadding = false;
- shouldAddBottomSafeAreaPadding = false;
- break;
case CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED:
modalStyle = {
...modalStyle,
From 2cc184680d314aae2fda7efba72ff179b02db35c Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Mon, 29 Apr 2024 19:27:04 +0530
Subject: [PATCH 08/15] Update
---
.../BaseClientSideLoggingToolMenu.tsx | 4 +++-
src/components/ClientSideLoggingToolMenu/types.ts | 2 ++
src/pages/settings/AboutPage/ConsolePage.tsx | 7 ++++---
src/pages/settings/AboutPage/ShareLogList/index.native.tsx | 7 +++++--
4 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx b/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
index 7d27caa997f7..92d723dd36c6 100644
--- a/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
+++ b/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
@@ -81,7 +81,9 @@ function BaseClientSideLoggingToolMenu({shouldStoreLogs, capturedLogs, file, onS
small
text={translate('initialSettingsPage.debugConsole.viewConsole')}
onPress={() => {
- closeTestToolsModal()
+ if (closeTestToolsModal) {
+ closeTestToolsModal()
+ }
Navigation.navigate(ROUTES.SETTINGS_CONSOLE.getRoute(isViaTestToolsModal))
}}
/>
diff --git a/src/components/ClientSideLoggingToolMenu/types.ts b/src/components/ClientSideLoggingToolMenu/types.ts
index 4c29a48a9003..86ad66dfd33c 100644
--- a/src/components/ClientSideLoggingToolMenu/types.ts
+++ b/src/components/ClientSideLoggingToolMenu/types.ts
@@ -1,6 +1,8 @@
type ClientSideLoggingToolMenuProps = {
/** Boolean to know if this was opened via test tools modal */
isViaTestToolsModal: boolean;
+ /** Action to close the test tools modal */
+ closeTestToolsModal?: () => void;
};
export default ClientSideLoggingToolMenuProps;
diff --git a/src/pages/settings/AboutPage/ConsolePage.tsx b/src/pages/settings/AboutPage/ConsolePage.tsx
index 2bd9ad53a544..c4443cbfbfdf 100644
--- a/src/pages/settings/AboutPage/ConsolePage.tsx
+++ b/src/pages/settings/AboutPage/ConsolePage.tsx
@@ -25,9 +25,10 @@ import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {CapturedLogs} from '@src/types/onyx';
-import {RouteProp, useRoute} from "@react-navigation/native";
-import {SettingsNavigatorParamList} from "@navigation/types";
-import SCREENS from "@src/SCREENS";
+import type {RouteProp} from "@react-navigation/native";
+import { useRoute} from "@react-navigation/native";
+import type {SettingsNavigatorParamList} from "@navigation/types";
+import type SCREENS from "@src/SCREENS";
type ConsolePageOnyxProps = {
/** Logs captured on the current device */
diff --git a/src/pages/settings/AboutPage/ShareLogList/index.native.tsx b/src/pages/settings/AboutPage/ShareLogList/index.native.tsx
index 9150f4655f95..d9eec220618f 100644
--- a/src/pages/settings/AboutPage/ShareLogList/index.native.tsx
+++ b/src/pages/settings/AboutPage/ShareLogList/index.native.tsx
@@ -5,7 +5,7 @@ import ROUTES from '@src/ROUTES';
import BaseShareLogList from './BaseShareLogList';
import type {ShareLogListProps} from './types';
-function ShareLogList({logSource}: ShareLogListProps) {
+function ShareLogList({logSource, isViaTestToolsModal}: ShareLogListProps) {
const onAttachLogToReport = (reportID: string, filename: string) => {
if (!reportID || !logSource) {
return;
@@ -17,7 +17,10 @@ function ShareLogList({logSource}: ShareLogListProps) {
Navigation.navigate(routeToNavigate);
};
- return ;
+ return ;
}
export default ShareLogList;
From d3bfce58c5a68893596053f64c4f0d676bbbaa59 Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Mon, 29 Apr 2024 19:53:42 +0530
Subject: [PATCH 09/15] Lint fixes
---
.../BaseClientSideLoggingToolMenu.tsx | 19 ++++++++++++++-----
.../ClientSideLoggingToolMenu/index.tsx | 12 +++++++-----
src/pages/settings/AboutPage/ConsolePage.tsx | 10 +++++-----
.../AboutPage/ShareLogList/index.native.tsx | 10 ++++++----
4 files changed, 32 insertions(+), 19 deletions(-)
diff --git a/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx b/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
index 92d723dd36c6..417da5cbf337 100644
--- a/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
+++ b/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
@@ -10,10 +10,10 @@ import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as Console from '@libs/actions/Console';
import {parseStringifiedMessages} from '@libs/Console';
+import Navigation from '@navigation/Navigation';
import ONYXKEYS from '@src/ONYXKEYS';
+import ROUTES from '@src/ROUTES';
import type {CapturedLogs, Log} from '@src/types/onyx';
-import Navigation from "@navigation/Navigation";
-import ROUTES from "@src/ROUTES";
type BaseClientSideLoggingToolMenuOnyxProps = {
/** Logs captured on the current device */
@@ -38,7 +38,16 @@ type BaseClientSideLoggingToolProps = {
closeTestToolsModal?: () => void;
} & BaseClientSideLoggingToolMenuOnyxProps;
-function BaseClientSideLoggingToolMenu({shouldStoreLogs, capturedLogs, file, onShareLogs, onDisableLogging, onEnableLogging, isViaTestToolsModal, closeTestToolsModal}: BaseClientSideLoggingToolProps) {
+function BaseClientSideLoggingToolMenu({
+ shouldStoreLogs,
+ capturedLogs,
+ file,
+ onShareLogs,
+ onDisableLogging,
+ onEnableLogging,
+ isViaTestToolsModal,
+ closeTestToolsModal,
+}: BaseClientSideLoggingToolProps) {
const {translate} = useLocalize();
const onToggle = () => {
@@ -82,9 +91,9 @@ function BaseClientSideLoggingToolMenu({shouldStoreLogs, capturedLogs, file, onS
text={translate('initialSettingsPage.debugConsole.viewConsole')}
onPress={() => {
if (closeTestToolsModal) {
- closeTestToolsModal()
+ closeTestToolsModal();
}
- Navigation.navigate(ROUTES.SETTINGS_CONSOLE.getRoute(isViaTestToolsModal))
+ Navigation.navigate(ROUTES.SETTINGS_CONSOLE.getRoute(isViaTestToolsModal));
}}
/>
diff --git a/src/components/ClientSideLoggingToolMenu/index.tsx b/src/components/ClientSideLoggingToolMenu/index.tsx
index 83f28c581b40..a4f820283248 100644
--- a/src/components/ClientSideLoggingToolMenu/index.tsx
+++ b/src/components/ClientSideLoggingToolMenu/index.tsx
@@ -9,11 +9,13 @@ function ClientSideLoggingToolMenu({isViaTestToolsModal, closeTestToolsModal}: C
localFileDownload('logs', JSON.stringify(logs, null, 2));
};
- return ;
+ return (
+
+ );
}
ClientSideLoggingToolMenu.displayName = 'ClientSideLoggingToolMenu';
diff --git a/src/pages/settings/AboutPage/ConsolePage.tsx b/src/pages/settings/AboutPage/ConsolePage.tsx
index c4443cbfbfdf..12574568382c 100644
--- a/src/pages/settings/AboutPage/ConsolePage.tsx
+++ b/src/pages/settings/AboutPage/ConsolePage.tsx
@@ -1,3 +1,5 @@
+import type {RouteProp} from '@react-navigation/native';
+import {useRoute} from '@react-navigation/native';
import {format} from 'date-fns';
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import {View} from 'react-native';
@@ -21,14 +23,12 @@ import type {Log} from '@libs/Console';
import localFileCreate from '@libs/localFileCreate';
import localFileDownload from '@libs/localFileDownload';
import Navigation from '@libs/Navigation/Navigation';
+import type {SettingsNavigatorParamList} from '@navigation/types';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
+import type SCREENS from '@src/SCREENS';
import type {CapturedLogs} from '@src/types/onyx';
-import type {RouteProp} from "@react-navigation/native";
-import { useRoute} from "@react-navigation/native";
-import type {SettingsNavigatorParamList} from "@navigation/types";
-import type SCREENS from "@src/SCREENS";
type ConsolePageOnyxProps = {
/** Logs captured on the current device */
@@ -122,7 +122,7 @@ function ConsolePage({capturedLogs, shouldStoreLogs}: ConsolePageProps) {
{
- Navigation.goBack(isViaTestToolsModal ? undefined : ROUTES.SETTINGS_TROUBLESHOOT)
+ Navigation.goBack(isViaTestToolsModal ? undefined : ROUTES.SETTINGS_TROUBLESHOOT);
}}
/>
diff --git a/src/pages/settings/AboutPage/ShareLogList/index.native.tsx b/src/pages/settings/AboutPage/ShareLogList/index.native.tsx
index d9eec220618f..b1fd80586b70 100644
--- a/src/pages/settings/AboutPage/ShareLogList/index.native.tsx
+++ b/src/pages/settings/AboutPage/ShareLogList/index.native.tsx
@@ -17,10 +17,12 @@ function ShareLogList({logSource, isViaTestToolsModal}: ShareLogListProps) {
Navigation.navigate(routeToNavigate);
};
- return ;
+ return (
+
+ );
}
export default ShareLogList;
From a9176d659b9ffcf6dfa469ce2014e6c324c98c3c Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Tue, 7 May 2024 19:12:34 +0530
Subject: [PATCH 10/15] Update
---
src/ROUTES.ts | 4 ++--
.../BaseClientSideLoggingToolMenu.tsx | 12 ++++--------
.../ClientSideLoggingToolMenu/index.android.tsx | 3 +--
.../ClientSideLoggingToolMenu/index.ios.tsx | 3 +--
src/components/ClientSideLoggingToolMenu/index.tsx | 3 +--
src/components/TestToolsModal.tsx | 1 -
src/libs/Navigation/types.ts | 4 ++--
src/pages/settings/AboutPage/ConsolePage.tsx | 5 ++---
.../AboutPage/ShareLogList/BaseShareLogList.tsx | 10 ++++++++--
.../settings/AboutPage/ShareLogList/index.native.tsx | 7 ++-----
src/pages/settings/AboutPage/ShareLogList/index.tsx | 7 ++-----
src/pages/settings/AboutPage/ShareLogList/types.ts | 4 ----
src/pages/settings/AboutPage/ShareLogPage.tsx | 7 +------
src/pages/settings/Troubleshoot/TroubleshootPage.tsx | 2 +-
14 files changed, 27 insertions(+), 45 deletions(-)
diff --git a/src/ROUTES.ts b/src/ROUTES.ts
index 6a51f1fbae20..12dd16edb9ca 100644
--- a/src/ROUTES.ts
+++ b/src/ROUTES.ts
@@ -181,11 +181,11 @@ const ROUTES = {
SETTINGS_TROUBLESHOOT: 'settings/troubleshoot',
SETTINGS_CONSOLE: {
route: 'settings/troubleshoot/console',
- getRoute: (isViaTestToolsModal = false) => `settings/troubleshoot/console?isViaTestToolsModal=${isViaTestToolsModal}` as const,
+ getRoute: (backTo?: string) => getUrlWithBackToParam(`settings/troubleshoot/console`, backTo) as const,
},
SETTINGS_SHARE_LOG: {
route: 'settings/troubleshoot/console/share-log',
- getRoute: (source: string, isViaTestToolsModal = false) => `settings/troubleshoot/console/share-log?source=${encodeURI(source)}&isViaTestToolsModal=${isViaTestToolsModal}` as const,
+ getRoute: (source: string, backTo?: string) => getUrlWithBackToParam(`settings/troubleshoot/console/share-log?source=${encodeURI(source)}`, backTo) as const,
},
SETTINGS_EXIT_SURVEY_REASON: 'settings/exit-survey/reason',
diff --git a/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx b/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
index 24ceb3e760d0..99afa5185e7f 100644
--- a/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
+++ b/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
@@ -14,6 +14,7 @@ import Navigation from '@navigation/Navigation';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {CapturedLogs, Log} from '@src/types/onyx';
+import toggleTestToolsModal from "@userActions/TestTool";
type BaseClientSideLoggingToolMenuOnyxProps = {
/** Logs captured on the current device */
@@ -36,8 +37,6 @@ type BaseClientSideLoggingToolProps = {
displayPath?: string;
/** Boolean to know if this was opened via test tools modal */
isViaTestToolsModal: boolean;
- /** Action to close the test tools modal */
- closeTestToolsModal?: () => void;
} & BaseClientSideLoggingToolMenuOnyxProps;
function BaseClientSideLoggingToolMenu({
@@ -48,8 +47,7 @@ function BaseClientSideLoggingToolMenu({
onDisableLogging,
onEnableLogging,
displayPath,
- isViaTestToolsModal,
- closeTestToolsModal,
+ isViaTestToolsModal
}: BaseClientSideLoggingToolProps) {
const {translate} = useLocalize();
@@ -93,10 +91,8 @@ function BaseClientSideLoggingToolMenu({
small
text={translate('initialSettingsPage.debugConsole.viewConsole')}
onPress={() => {
- if (closeTestToolsModal) {
- closeTestToolsModal();
- }
- Navigation.navigate(ROUTES.SETTINGS_CONSOLE.getRoute(isViaTestToolsModal));
+ toggleTestToolsModal()
+ Navigation.navigate(ROUTES.SETTINGS_CONSOLE.getRoute());
}}
/>
diff --git a/src/components/ClientSideLoggingToolMenu/index.android.tsx b/src/components/ClientSideLoggingToolMenu/index.android.tsx
index 02ec8b9231ed..d9335a5c5921 100644
--- a/src/components/ClientSideLoggingToolMenu/index.android.tsx
+++ b/src/components/ClientSideLoggingToolMenu/index.android.tsx
@@ -7,7 +7,7 @@ import CONST from '@src/CONST';
import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu';
import type ClientSideLoggingToolMenuProps from './types';
-function ClientSideLoggingToolMenu({isViaTestToolsModal = false, closeTestToolsModal}: ClientSideLoggingToolMenuProps) {
+function ClientSideLoggingToolMenu({isViaTestToolsModal = false}: ClientSideLoggingToolMenuProps) {
const [file, setFile] = useState<{path: string; newFileName: string; size: number}>();
const createAndSaveFile = (logs: Log[]) => {
@@ -42,7 +42,6 @@ function ClientSideLoggingToolMenu({isViaTestToolsModal = false, closeTestToolsM
onShareLogs={shareLogs}
displayPath={`${CONST.DOWNLOADS_PATH}/${file?.newFileName ?? ''}`}
isViaTestToolsModal={isViaTestToolsModal}
- closeTestToolsModal={closeTestToolsModal}
/>
);
}
diff --git a/src/components/ClientSideLoggingToolMenu/index.ios.tsx b/src/components/ClientSideLoggingToolMenu/index.ios.tsx
index 12f04c81c419..bfdc6fbcde9b 100644
--- a/src/components/ClientSideLoggingToolMenu/index.ios.tsx
+++ b/src/components/ClientSideLoggingToolMenu/index.ios.tsx
@@ -8,7 +8,7 @@ import CONST from '@src/CONST';
import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu';
import type ClientSideLoggingToolMenuProps from './types';
-function ClientSideLoggingToolMenu({isViaTestToolsModal = false, closeTestToolsModal}: ClientSideLoggingToolMenuProps) {
+function ClientSideLoggingToolMenu({isViaTestToolsModal = false}: ClientSideLoggingToolMenuProps) {
const [file, setFile] = useState<{path: string; newFileName: string; size: number}>();
const {environment} = useEnvironment();
@@ -35,7 +35,6 @@ function ClientSideLoggingToolMenu({isViaTestToolsModal = false, closeTestToolsM
onShareLogs={shareLogs}
displayPath={`${CONST.NEW_EXPENSIFY_PATH}${getDownloadFolderPathSuffixForIOS(environment)}/${file?.newFileName ?? ''}`}
isViaTestToolsModal={isViaTestToolsModal}
- closeTestToolsModal={closeTestToolsModal}
/>
);
}
diff --git a/src/components/ClientSideLoggingToolMenu/index.tsx b/src/components/ClientSideLoggingToolMenu/index.tsx
index a4f820283248..50dfb629b565 100644
--- a/src/components/ClientSideLoggingToolMenu/index.tsx
+++ b/src/components/ClientSideLoggingToolMenu/index.tsx
@@ -4,7 +4,7 @@ import localFileDownload from '@libs/localFileDownload';
import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu';
import type ClientSideLoggingToolMenuProps from './types';
-function ClientSideLoggingToolMenu({isViaTestToolsModal, closeTestToolsModal}: ClientSideLoggingToolMenuProps) {
+function ClientSideLoggingToolMenu({isViaTestToolsModal}: ClientSideLoggingToolMenuProps) {
const downloadFile = (logs: Log[]) => {
localFileDownload('logs', JSON.stringify(logs, null, 2));
};
@@ -13,7 +13,6 @@ function ClientSideLoggingToolMenu({isViaTestToolsModal, closeTestToolsModal}: C
);
}
diff --git a/src/components/TestToolsModal.tsx b/src/components/TestToolsModal.tsx
index f9107a5a269a..e60600909b26 100644
--- a/src/components/TestToolsModal.tsx
+++ b/src/components/TestToolsModal.tsx
@@ -47,7 +47,6 @@ function TestToolsModal({isTestToolsModalOpen = false}: TestToolsModalProps) {
diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts
index 2e006e7d7643..150cef975760 100644
--- a/src/libs/Navigation/types.ts
+++ b/src/libs/Navigation/types.ts
@@ -112,12 +112,12 @@ type SettingsNavigatorParamList = {
[SCREENS.SETTINGS.APP_DOWNLOAD_LINKS]: undefined;
[SCREENS.SETTINGS.TROUBLESHOOT]: undefined;
[SCREENS.SETTINGS.CONSOLE]: {
- isViaTestToolsModal: boolean;
+ backTo: Routes;
};
[SCREENS.SETTINGS.SHARE_LOG]: {
/** URL of the generated file to share logs in a report */
source: string;
- isViaTestToolsModal: boolean;
+ backTo: Routes;
};
[SCREENS.SETTINGS.WALLET.ROOT]: undefined;
[SCREENS.SETTINGS.WALLET.CARDS_DIGITAL_DETAILS_UPDATE_ADDRESS]: undefined;
diff --git a/src/pages/settings/AboutPage/ConsolePage.tsx b/src/pages/settings/AboutPage/ConsolePage.tsx
index 12574568382c..b3dab1999e64 100644
--- a/src/pages/settings/AboutPage/ConsolePage.tsx
+++ b/src/pages/settings/AboutPage/ConsolePage.tsx
@@ -49,7 +49,6 @@ function ConsolePage({capturedLogs, shouldStoreLogs}: ConsolePageProps) {
const styles = useThemeStyles();
const route = useRoute>();
- const isViaTestToolsModal = route.params?.isViaTestToolsModal ?? false;
const logsList = useMemo(
() =>
@@ -98,7 +97,7 @@ function ConsolePage({capturedLogs, shouldStoreLogs}: ConsolePageProps) {
return;
}
- Navigation.navigate(ROUTES.SETTINGS_SHARE_LOG.getRoute(path, isViaTestToolsModal));
+ Navigation.navigate(ROUTES.SETTINGS_SHARE_LOG.getRoute(path, ROUTES.SETTINGS_CONSOLE.getRoute(route.params?.backTo)));
});
};
@@ -122,7 +121,7 @@ function ConsolePage({capturedLogs, shouldStoreLogs}: ConsolePageProps) {
{
- Navigation.goBack(isViaTestToolsModal ? undefined : ROUTES.SETTINGS_TROUBLESHOOT);
+ Navigation.goBack(route.params?.backTo);
}}
/>
diff --git a/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx b/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx
index 0c656a47ad1f..37c1b4a2ba22 100644
--- a/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx
+++ b/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx
@@ -18,8 +18,12 @@ import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {Report} from '@src/types/onyx';
import type {BaseShareLogListProps} from './types';
+import {StackScreenProps} from "@react-navigation/stack";
+import {SettingsNavigatorParamList} from "@navigation/types";
+import SCREENS from "@src/SCREENS";
+import {RouteProp, useRoute} from "@react-navigation/native";
-function BaseShareLogList({onAttachLogToReport, isViaTestToolsModal = false}: BaseShareLogListProps) {
+function BaseShareLogList({onAttachLogToReport}: BaseShareLogListProps) {
const [searchValue, debouncedSearchValue, setSearchValue] = useDebouncedState('');
const {isOffline} = useNetwork();
const {translate} = useLocalize();
@@ -27,6 +31,8 @@ function BaseShareLogList({onAttachLogToReport, isViaTestToolsModal = false}: Ba
const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false});
const {options, areOptionsInitialized} = useOptionsList();
+ const route = useRoute>();
+
const searchOptions = useMemo(() => {
if (!areOptionsInitialized) {
return {
@@ -99,7 +105,7 @@ function BaseShareLogList({onAttachLogToReport, isViaTestToolsModal = false}: Ba
<>
Navigation.goBack(ROUTES.SETTINGS_CONSOLE.getRoute(isViaTestToolsModal))}
+ onBackButtonPress={() => Navigation.goBack(route.params?.backTo)}
/>
{
if (!reportID || !logSource) {
return;
@@ -18,10 +18,7 @@ function ShareLogList({logSource, isViaTestToolsModal}: ShareLogListProps) {
};
return (
-
+
);
}
diff --git a/src/pages/settings/AboutPage/ShareLogList/index.tsx b/src/pages/settings/AboutPage/ShareLogList/index.tsx
index 03cd7c42f73c..9c6f82bbb593 100644
--- a/src/pages/settings/AboutPage/ShareLogList/index.tsx
+++ b/src/pages/settings/AboutPage/ShareLogList/index.tsx
@@ -6,7 +6,7 @@ import ROUTES from '@src/ROUTES';
import BaseShareLogList from './BaseShareLogList';
import type {ShareLogListProps} from './types';
-function ShareLogList({logSource, isViaTestToolsModal}: ShareLogListProps) {
+function ShareLogList({logSource, backTo}: ShareLogListProps) {
const onAttachLogToReport = (reportID: string, filename: string) => {
FileUtils.readFileAsync(
logSource,
@@ -21,10 +21,7 @@ function ShareLogList({logSource, isViaTestToolsModal}: ShareLogListProps) {
);
};
return (
-
+
);
}
diff --git a/src/pages/settings/AboutPage/ShareLogList/types.ts b/src/pages/settings/AboutPage/ShareLogList/types.ts
index bab48c39cc27..500641a3da42 100644
--- a/src/pages/settings/AboutPage/ShareLogList/types.ts
+++ b/src/pages/settings/AboutPage/ShareLogList/types.ts
@@ -1,14 +1,10 @@
type ShareLogListProps = {
/** The source of the log file to share */
logSource: string;
- /** Boolean to know if this was opened via test tools modal */
- isViaTestToolsModal: boolean;
};
type BaseShareLogListProps = {
onAttachLogToReport: (reportID: string, filename: string) => void;
- /** Boolean to know if this was opened via test tools modal */
- isViaTestToolsModal: boolean;
};
export type {BaseShareLogListProps, ShareLogListProps};
diff --git a/src/pages/settings/AboutPage/ShareLogPage.tsx b/src/pages/settings/AboutPage/ShareLogPage.tsx
index 7688ade3ccd1..8f0623f99d32 100644
--- a/src/pages/settings/AboutPage/ShareLogPage.tsx
+++ b/src/pages/settings/AboutPage/ShareLogPage.tsx
@@ -7,12 +7,7 @@ import ShareLogList from './ShareLogList';
type ShareLogPageProps = StackScreenProps;
function ShareLogPage({route}: ShareLogPageProps) {
- return (
-
- );
+ return ;
}
export default ShareLogPage;
diff --git a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx
index b463ba02f4d3..8d48a336b260 100644
--- a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx
+++ b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx
@@ -55,7 +55,7 @@ function TroubleshootPage({shouldStoreLogs}: TroubleshootPageProps) {
const debugConsoleItem: BaseMenuItem = {
translationKey: 'initialSettingsPage.troubleshoot.viewConsole',
icon: Expensicons.Gear,
- action: waitForNavigate(() => Navigation.navigate(ROUTES.SETTINGS_CONSOLE.getRoute(false))),
+ action: waitForNavigate(() => Navigation.navigate(ROUTES.SETTINGS_CONSOLE.getRoute(ROUTES.SETTINGS_TROUBLESHOOT))),
};
const baseMenuItems: BaseMenuItem[] = [
From 1d0142048d6f2c191117990934f3ad677190566f Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Tue, 7 May 2024 21:00:28 +0530
Subject: [PATCH 11/15] Fixes
---
src/ROUTES.ts | 4 ++--
.../settings/AboutPage/ShareLogList/BaseShareLogList.tsx | 9 ++++-----
src/pages/settings/AboutPage/ShareLogList/index.tsx | 2 +-
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/src/ROUTES.ts b/src/ROUTES.ts
index 12dd16edb9ca..8d2c0fa174f3 100644
--- a/src/ROUTES.ts
+++ b/src/ROUTES.ts
@@ -181,11 +181,11 @@ const ROUTES = {
SETTINGS_TROUBLESHOOT: 'settings/troubleshoot',
SETTINGS_CONSOLE: {
route: 'settings/troubleshoot/console',
- getRoute: (backTo?: string) => getUrlWithBackToParam(`settings/troubleshoot/console`, backTo) as const,
+ getRoute: (backTo?: string) => getUrlWithBackToParam(`settings/troubleshoot/console`, backTo),
},
SETTINGS_SHARE_LOG: {
route: 'settings/troubleshoot/console/share-log',
- getRoute: (source: string, backTo?: string) => getUrlWithBackToParam(`settings/troubleshoot/console/share-log?source=${encodeURI(source)}`, backTo) as const,
+ getRoute: (source: string, backTo?: string) => getUrlWithBackToParam(`settings/troubleshoot/console/share-log?source=${encodeURI(source)}`, backTo),
},
SETTINGS_EXIT_SURVEY_REASON: 'settings/exit-survey/reason',
diff --git a/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx b/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx
index 37c1b4a2ba22..334e4be618d3 100644
--- a/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx
+++ b/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx
@@ -15,13 +15,12 @@ import Navigation from '@libs/Navigation/Navigation';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
-import ROUTES from '@src/ROUTES';
import type {Report} from '@src/types/onyx';
+import type {SettingsNavigatorParamList} from "@navigation/types";
+import type SCREENS from "@src/SCREENS";
+import type {RouteProp} from "@react-navigation/native";
+import {useRoute} from "@react-navigation/native";
import type {BaseShareLogListProps} from './types';
-import {StackScreenProps} from "@react-navigation/stack";
-import {SettingsNavigatorParamList} from "@navigation/types";
-import SCREENS from "@src/SCREENS";
-import {RouteProp, useRoute} from "@react-navigation/native";
function BaseShareLogList({onAttachLogToReport}: BaseShareLogListProps) {
const [searchValue, debouncedSearchValue, setSearchValue] = useDebouncedState('');
diff --git a/src/pages/settings/AboutPage/ShareLogList/index.tsx b/src/pages/settings/AboutPage/ShareLogList/index.tsx
index 9c6f82bbb593..5b410c332426 100644
--- a/src/pages/settings/AboutPage/ShareLogList/index.tsx
+++ b/src/pages/settings/AboutPage/ShareLogList/index.tsx
@@ -6,7 +6,7 @@ import ROUTES from '@src/ROUTES';
import BaseShareLogList from './BaseShareLogList';
import type {ShareLogListProps} from './types';
-function ShareLogList({logSource, backTo}: ShareLogListProps) {
+function ShareLogList({logSource}: ShareLogListProps) {
const onAttachLogToReport = (reportID: string, filename: string) => {
FileUtils.readFileAsync(
logSource,
From 8f1da7f92a177a3c0051c9cb4a2b91c08084d146 Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Wed, 8 May 2024 02:12:37 +0530
Subject: [PATCH 12/15] Update
---
.../BaseClientSideLoggingToolMenu.tsx | 15 ----------
.../index.android.tsx | 4 +--
.../ClientSideLoggingToolMenu/index.ios.tsx | 4 +--
.../ClientSideLoggingToolMenu/index.tsx | 4 +--
.../ClientSideLoggingToolMenu/types.ts | 8 ------
src/components/TestToolsModal.tsx | 28 ++++++++++++++++---
6 files changed, 27 insertions(+), 36 deletions(-)
delete mode 100644 src/components/ClientSideLoggingToolMenu/types.ts
diff --git a/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx b/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
index 99afa5185e7f..157d824065ac 100644
--- a/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
+++ b/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
@@ -35,8 +35,6 @@ type BaseClientSideLoggingToolProps = {
onEnableLogging?: () => void;
/** Path used to display location of saved file */
displayPath?: string;
- /** Boolean to know if this was opened via test tools modal */
- isViaTestToolsModal: boolean;
} & BaseClientSideLoggingToolMenuOnyxProps;
function BaseClientSideLoggingToolMenu({
@@ -47,7 +45,6 @@ function BaseClientSideLoggingToolMenu({
onDisableLogging,
onEnableLogging,
displayPath,
- isViaTestToolsModal
}: BaseClientSideLoggingToolProps) {
const {translate} = useLocalize();
@@ -85,18 +82,6 @@ function BaseClientSideLoggingToolMenu({
onToggle={onToggle}
/>
- {!!shouldStoreLogs && isViaTestToolsModal && (
-
-
- )}
{!!file && (
<>
{`path: ${displayPath}`}
diff --git a/src/components/ClientSideLoggingToolMenu/index.android.tsx b/src/components/ClientSideLoggingToolMenu/index.android.tsx
index d9335a5c5921..aa1bc215b719 100644
--- a/src/components/ClientSideLoggingToolMenu/index.android.tsx
+++ b/src/components/ClientSideLoggingToolMenu/index.android.tsx
@@ -5,9 +5,8 @@ import type {Log} from '@libs/Console';
import localFileCreate from '@libs/localFileCreate';
import CONST from '@src/CONST';
import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu';
-import type ClientSideLoggingToolMenuProps from './types';
-function ClientSideLoggingToolMenu({isViaTestToolsModal = false}: ClientSideLoggingToolMenuProps) {
+function ClientSideLoggingToolMenu() {
const [file, setFile] = useState<{path: string; newFileName: string; size: number}>();
const createAndSaveFile = (logs: Log[]) => {
@@ -41,7 +40,6 @@ function ClientSideLoggingToolMenu({isViaTestToolsModal = false}: ClientSideLogg
onDisableLogging={createAndSaveFile}
onShareLogs={shareLogs}
displayPath={`${CONST.DOWNLOADS_PATH}/${file?.newFileName ?? ''}`}
- isViaTestToolsModal={isViaTestToolsModal}
/>
);
}
diff --git a/src/components/ClientSideLoggingToolMenu/index.ios.tsx b/src/components/ClientSideLoggingToolMenu/index.ios.tsx
index bfdc6fbcde9b..78ffccf612a2 100644
--- a/src/components/ClientSideLoggingToolMenu/index.ios.tsx
+++ b/src/components/ClientSideLoggingToolMenu/index.ios.tsx
@@ -6,9 +6,8 @@ import getDownloadFolderPathSuffixForIOS from '@libs/getDownloadFolderPathSuffix
import localFileCreate from '@libs/localFileCreate';
import CONST from '@src/CONST';
import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu';
-import type ClientSideLoggingToolMenuProps from './types';
-function ClientSideLoggingToolMenu({isViaTestToolsModal = false}: ClientSideLoggingToolMenuProps) {
+function ClientSideLoggingToolMenu() {
const [file, setFile] = useState<{path: string; newFileName: string; size: number}>();
const {environment} = useEnvironment();
@@ -34,7 +33,6 @@ function ClientSideLoggingToolMenu({isViaTestToolsModal = false}: ClientSideLogg
onDisableLogging={createFile}
onShareLogs={shareLogs}
displayPath={`${CONST.NEW_EXPENSIFY_PATH}${getDownloadFolderPathSuffixForIOS(environment)}/${file?.newFileName ?? ''}`}
- isViaTestToolsModal={isViaTestToolsModal}
/>
);
}
diff --git a/src/components/ClientSideLoggingToolMenu/index.tsx b/src/components/ClientSideLoggingToolMenu/index.tsx
index 50dfb629b565..7208297ade53 100644
--- a/src/components/ClientSideLoggingToolMenu/index.tsx
+++ b/src/components/ClientSideLoggingToolMenu/index.tsx
@@ -2,9 +2,8 @@ import React from 'react';
import type {Log} from '@libs/Console';
import localFileDownload from '@libs/localFileDownload';
import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu';
-import type ClientSideLoggingToolMenuProps from './types';
-function ClientSideLoggingToolMenu({isViaTestToolsModal}: ClientSideLoggingToolMenuProps) {
+function ClientSideLoggingToolMenu() {
const downloadFile = (logs: Log[]) => {
localFileDownload('logs', JSON.stringify(logs, null, 2));
};
@@ -12,7 +11,6 @@ function ClientSideLoggingToolMenu({isViaTestToolsModal}: ClientSideLoggingToolM
return (
);
}
diff --git a/src/components/ClientSideLoggingToolMenu/types.ts b/src/components/ClientSideLoggingToolMenu/types.ts
deleted file mode 100644
index 86ad66dfd33c..000000000000
--- a/src/components/ClientSideLoggingToolMenu/types.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-type ClientSideLoggingToolMenuProps = {
- /** Boolean to know if this was opened via test tools modal */
- isViaTestToolsModal: boolean;
- /** Action to close the test tools modal */
- closeTestToolsModal?: () => void;
-};
-
-export default ClientSideLoggingToolMenuProps;
diff --git a/src/components/TestToolsModal.tsx b/src/components/TestToolsModal.tsx
index e60600909b26..3d9f400d99aa 100644
--- a/src/components/TestToolsModal.tsx
+++ b/src/components/TestToolsModal.tsx
@@ -10,6 +10,10 @@ import useWindowDimensions from '@hooks/useWindowDimensions';
import toggleTestToolsModal from '@userActions/TestTool';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
+import Navigation from "@navigation/Navigation";
+import ROUTES from "@src/ROUTES";
+import Button from "./Button";
+import TestToolRow from "./TestToolRow";
import ClientSideLoggingToolMenu from './ClientSideLoggingToolMenu';
import Modal from './Modal';
import ProfilingToolMenu from './ProfilingToolMenu';
@@ -19,11 +23,14 @@ import Text from './Text';
type TestToolsModalOnyxProps = {
/** Whether the test tools modal is open */
isTestToolsModalOpen: OnyxEntry;
+
+ /** Whether or not logs should be stored */
+ shouldStoreLogs: OnyxEntry;
};
type TestToolsModalProps = TestToolsModalOnyxProps;
-function TestToolsModal({isTestToolsModalOpen = false}: TestToolsModalProps) {
+function TestToolsModal({isTestToolsModalOpen = false, shouldStoreLogs = false}: TestToolsModalProps) {
const {isDevelopment} = useEnvironment();
const {windowWidth} = useWindowDimensions();
const StyleUtils = useStyleUtils();
@@ -45,9 +52,19 @@ function TestToolsModal({isTestToolsModalOpen = false}: TestToolsModalProps) {
{translate('initialSettingsPage.troubleshoot.releaseOptions')}
-
+
+ {!!shouldStoreLogs && (
+
+
+ )}
);
@@ -59,4 +76,7 @@ export default withOnyx({
isTestToolsModalOpen: {
key: ONYXKEYS.IS_TEST_TOOLS_MODAL_OPEN,
},
+ shouldStoreLogs: {
+ key: ONYXKEYS.SHOULD_STORE_LOGS,
+ },
})(TestToolsModal);
From 064cd4deb6ee5ab039abd1f179a68ce36c41ee5e Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Wed, 8 May 2024 02:15:35 +0530
Subject: [PATCH 13/15] Update
---
src/pages/settings/AboutPage/ShareLogList/index.native.tsx | 4 +---
src/pages/settings/AboutPage/ShareLogList/index.tsx | 4 +---
src/pages/settings/Troubleshoot/TroubleshootPage.tsx | 2 +-
3 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/src/pages/settings/AboutPage/ShareLogList/index.native.tsx b/src/pages/settings/AboutPage/ShareLogList/index.native.tsx
index 4753d60379dd..9150f4655f95 100644
--- a/src/pages/settings/AboutPage/ShareLogList/index.native.tsx
+++ b/src/pages/settings/AboutPage/ShareLogList/index.native.tsx
@@ -17,9 +17,7 @@ function ShareLogList({logSource}: ShareLogListProps) {
Navigation.navigate(routeToNavigate);
};
- return (
-
- );
+ return ;
}
export default ShareLogList;
diff --git a/src/pages/settings/AboutPage/ShareLogList/index.tsx b/src/pages/settings/AboutPage/ShareLogList/index.tsx
index 5b410c332426..555e44e53747 100644
--- a/src/pages/settings/AboutPage/ShareLogList/index.tsx
+++ b/src/pages/settings/AboutPage/ShareLogList/index.tsx
@@ -20,9 +20,7 @@ function ShareLogList({logSource}: ShareLogListProps) {
() => {},
);
};
- return (
-
- );
+ return ;
}
export default ShareLogList;
diff --git a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx
index 8d48a336b260..817edb5cc9f7 100644
--- a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx
+++ b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx
@@ -119,7 +119,7 @@ function TroubleshootPage({shouldStoreLogs}: TroubleshootPageProps) {
>
-
+
Date: Wed, 8 May 2024 17:55:45 +0530
Subject: [PATCH 14/15] Update
---
src/ROUTES.ts | 2 +-
.../BaseClientSideLoggingToolMenu.tsx | 14 +-------------
src/components/ClientSideLoggingToolMenu/index.tsx | 6 +-----
src/pages/settings/AboutPage/ConsolePage.tsx | 6 ++----
.../AboutPage/ShareLogList/BaseShareLogList.tsx | 9 ++-------
5 files changed, 7 insertions(+), 30 deletions(-)
diff --git a/src/ROUTES.ts b/src/ROUTES.ts
index 8d2c0fa174f3..af4dc013fbca 100644
--- a/src/ROUTES.ts
+++ b/src/ROUTES.ts
@@ -185,7 +185,7 @@ const ROUTES = {
},
SETTINGS_SHARE_LOG: {
route: 'settings/troubleshoot/console/share-log',
- getRoute: (source: string, backTo?: string) => getUrlWithBackToParam(`settings/troubleshoot/console/share-log?source=${encodeURI(source)}`, backTo),
+ getRoute: (source: string) => `settings/troubleshoot/console/share-log?source=${encodeURI(source)}` as const,
},
SETTINGS_EXIT_SURVEY_REASON: 'settings/exit-survey/reason',
diff --git a/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx b/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
index 157d824065ac..7c4c669e2154 100644
--- a/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
+++ b/src/components/ClientSideLoggingToolMenu/BaseClientSideLoggingToolMenu.tsx
@@ -10,11 +10,8 @@ import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as Console from '@libs/actions/Console';
import {parseStringifiedMessages} from '@libs/Console';
-import Navigation from '@navigation/Navigation';
import ONYXKEYS from '@src/ONYXKEYS';
-import ROUTES from '@src/ROUTES';
import type {CapturedLogs, Log} from '@src/types/onyx';
-import toggleTestToolsModal from "@userActions/TestTool";
type BaseClientSideLoggingToolMenuOnyxProps = {
/** Logs captured on the current device */
@@ -37,15 +34,7 @@ type BaseClientSideLoggingToolProps = {
displayPath?: string;
} & BaseClientSideLoggingToolMenuOnyxProps;
-function BaseClientSideLoggingToolMenu({
- shouldStoreLogs,
- capturedLogs,
- file,
- onShareLogs,
- onDisableLogging,
- onEnableLogging,
- displayPath,
-}: BaseClientSideLoggingToolProps) {
+function BaseClientSideLoggingToolMenu({shouldStoreLogs, capturedLogs, file, onShareLogs, onDisableLogging, onEnableLogging, displayPath}: BaseClientSideLoggingToolProps) {
const {translate} = useLocalize();
const onToggle = () => {
@@ -72,7 +61,6 @@ function BaseClientSideLoggingToolMenu({
Console.disableLoggingAndFlushLogs();
};
const styles = useThemeStyles();
-
return (
<>
diff --git a/src/components/ClientSideLoggingToolMenu/index.tsx b/src/components/ClientSideLoggingToolMenu/index.tsx
index 7208297ade53..182c3bf99b74 100644
--- a/src/components/ClientSideLoggingToolMenu/index.tsx
+++ b/src/components/ClientSideLoggingToolMenu/index.tsx
@@ -8,11 +8,7 @@ function ClientSideLoggingToolMenu() {
localFileDownload('logs', JSON.stringify(logs, null, 2));
};
- return (
-
- );
+ return ;
}
ClientSideLoggingToolMenu.displayName = 'ClientSideLoggingToolMenu';
diff --git a/src/pages/settings/AboutPage/ConsolePage.tsx b/src/pages/settings/AboutPage/ConsolePage.tsx
index b3dab1999e64..63f23df057dc 100644
--- a/src/pages/settings/AboutPage/ConsolePage.tsx
+++ b/src/pages/settings/AboutPage/ConsolePage.tsx
@@ -97,7 +97,7 @@ function ConsolePage({capturedLogs, shouldStoreLogs}: ConsolePageProps) {
return;
}
- Navigation.navigate(ROUTES.SETTINGS_SHARE_LOG.getRoute(path, ROUTES.SETTINGS_CONSOLE.getRoute(route.params?.backTo)));
+ Navigation.navigate(ROUTES.SETTINGS_SHARE_LOG.getRoute(path));
});
};
@@ -120,9 +120,7 @@ function ConsolePage({capturedLogs, shouldStoreLogs}: ConsolePageProps) {
{
- Navigation.goBack(route.params?.backTo);
- }}
+ onBackButtonPress={() => Navigation.goBack(route.params?.backTo)}
/>
>();
-
const searchOptions = useMemo(() => {
if (!areOptionsInitialized) {
return {
@@ -104,7 +99,7 @@ function BaseShareLogList({onAttachLogToReport}: BaseShareLogListProps) {
<>
Navigation.goBack(route.params?.backTo)}
+ onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_CONSOLE)}
/>
Date: Wed, 8 May 2024 18:12:53 +0530
Subject: [PATCH 15/15] Fixes
---
src/components/TestToolsModal.tsx | 8 ++++----
.../settings/AboutPage/ShareLogList/BaseShareLogList.tsx | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/components/TestToolsModal.tsx b/src/components/TestToolsModal.tsx
index 3d9f400d99aa..ad1c65e76a4b 100644
--- a/src/components/TestToolsModal.tsx
+++ b/src/components/TestToolsModal.tsx
@@ -7,17 +7,17 @@ import useLocalize from '@hooks/useLocalize';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
+import Navigation from '@navigation/Navigation';
import toggleTestToolsModal from '@userActions/TestTool';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
-import Navigation from "@navigation/Navigation";
-import ROUTES from "@src/ROUTES";
-import Button from "./Button";
-import TestToolRow from "./TestToolRow";
+import ROUTES from '@src/ROUTES';
+import Button from './Button';
import ClientSideLoggingToolMenu from './ClientSideLoggingToolMenu';
import Modal from './Modal';
import ProfilingToolMenu from './ProfilingToolMenu';
import TestToolMenu from './TestToolMenu';
+import TestToolRow from './TestToolRow';
import Text from './Text';
type TestToolsModalOnyxProps = {
diff --git a/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx b/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx
index 58c3be7df6b1..943bff5459ce 100644
--- a/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx
+++ b/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx
@@ -99,7 +99,7 @@ function BaseShareLogList({onAttachLogToReport}: BaseShareLogListProps) {
<>
Navigation.goBack(ROUTES.SETTINGS_CONSOLE)}
+ onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_CONSOLE.getRoute())}
/>