From 7344aec15e211d188ae6ef618659f2249d3085e9 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Tue, 13 Feb 2024 13:00:07 +0100 Subject: [PATCH 01/11] fix three pane not found view --- src/Expensify.js | 2 +- src/ROUTES.ts | 2 ++ src/libs/Navigation/linkTo.ts | 4 +++- src/libs/actions/Report.ts | 6 +++++- src/pages/workspace/WorkspaceInitialPage.tsx | 9 +++++++++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/Expensify.js b/src/Expensify.js index dfb59a0f8848..0283bf3e4c5c 100644 --- a/src/Expensify.js +++ b/src/Expensify.js @@ -194,7 +194,7 @@ function Expensify(props) { // If the app is opened from a deep link, get the reportID (if exists) from the deep link and navigate to the chat report Linking.getInitialURL().then((url) => { setInitialUrl(url); - Report.openReportFromDeepLink(url, isAuthenticated); + Report.openReportFromDeepLink(url, isAuthenticated, true); }); // Open chat report from a deep link (only mobile native) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 082cea49d771..76d2a496db8c 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -15,6 +15,8 @@ const ROUTES = { // If the user opens this route, we'll redirect them to the path saved in the last visited path or to the home page if the last visited path is empty. ROOT: '', + NOT_FOUND: 'not-found', + // This route renders the list of reports. HOME: 'home', diff --git a/src/libs/Navigation/linkTo.ts b/src/libs/Navigation/linkTo.ts index 5a765d9a7d37..0a3e7e8b591c 100644 --- a/src/libs/Navigation/linkTo.ts +++ b/src/libs/Navigation/linkTo.ts @@ -162,7 +162,7 @@ export default function linkTo(navigation: NavigationContainerRef { + if (!shouldShowNotFoundPage) { + return; + } + Navigation.dismissModal(); + Navigation.navigateWithSwitchPolicyID({route: ROUTES.HOME}); + Navigation.navigate(ROUTES.NOT_FOUND, CONST.NAVIGATION.TYPE.FORCED_UP); + }, [shouldShowNotFoundPage]); + return ( Date: Mon, 19 Feb 2024 10:04:04 +0100 Subject: [PATCH 02/11] cleanup --- src/libs/Navigation/linkTo.ts | 2 -- src/pages/workspace/WorkspacePageWithSections.tsx | 1 - 2 files changed, 3 deletions(-) diff --git a/src/libs/Navigation/linkTo.ts b/src/libs/Navigation/linkTo.ts index 0a3e7e8b591c..3a4abe225120 100644 --- a/src/libs/Navigation/linkTo.ts +++ b/src/libs/Navigation/linkTo.ts @@ -253,8 +253,6 @@ export default function linkTo(navigation: NavigationContainerRef Date: Mon, 19 Feb 2024 10:16:02 +0100 Subject: [PATCH 03/11] fix not authorized screen --- src/pages/workspace/WorkspaceInitialPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/WorkspaceInitialPage.tsx b/src/pages/workspace/WorkspaceInitialPage.tsx index 33a6fdc0625a..279ad105d55f 100644 --- a/src/pages/workspace/WorkspaceInitialPage.tsx +++ b/src/pages/workspace/WorkspaceInitialPage.tsx @@ -168,13 +168,13 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r (PolicyUtils.isPendingDeletePolicy(policy) && PolicyUtils.isPendingDeletePolicy(prevPolicy)); useEffect(() => { - if (!shouldShowNotFoundPage) { + if (!shouldShowNotFoundPage || !isEmptyObject(policy)) { return; } Navigation.dismissModal(); Navigation.navigateWithSwitchPolicyID({route: ROUTES.HOME}); Navigation.navigate(ROUTES.NOT_FOUND, CONST.NAVIGATION.TYPE.FORCED_UP); - }, [shouldShowNotFoundPage]); + }, [policy, shouldShowNotFoundPage]); return ( Date: Mon, 19 Feb 2024 12:28:04 +0100 Subject: [PATCH 04/11] fix not found views - new approach --- src/Expensify.js | 2 +- src/ROUTES.ts | 2 - src/libs/actions/Report.ts | 6 +- src/pages/workspace/WorkspaceInitialPage.tsx | 5 +- src/pages/workspace/WorkspaceMembersPage.js | 123 ++++++++---------- .../workspace/WorkspacePageWithSections.tsx | 15 ++- 6 files changed, 71 insertions(+), 82 deletions(-) diff --git a/src/Expensify.js b/src/Expensify.js index 0283bf3e4c5c..dfb59a0f8848 100644 --- a/src/Expensify.js +++ b/src/Expensify.js @@ -194,7 +194,7 @@ function Expensify(props) { // If the app is opened from a deep link, get the reportID (if exists) from the deep link and navigate to the chat report Linking.getInitialURL().then((url) => { setInitialUrl(url); - Report.openReportFromDeepLink(url, isAuthenticated, true); + Report.openReportFromDeepLink(url, isAuthenticated); }); // Open chat report from a deep link (only mobile native) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 1f67e72b5737..559c49ff3e2e 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -15,8 +15,6 @@ const ROUTES = { // If the user opens this route, we'll redirect them to the path saved in the last visited path or to the home page if the last visited path is empty. ROOT: '', - NOT_FOUND: 'not-found', - // This route renders the list of reports. HOME: 'home', diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index da798a725915..4a791dd41b31 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -2157,7 +2157,7 @@ function toggleEmojiReaction( addEmojiReaction(originalReportID, reportAction.reportActionID, emoji, skinTone); } -function openReportFromDeepLink(url: string, isAuthenticated: boolean, blockNavigate: boolean) { +function openReportFromDeepLink(url: string, isAuthenticated: boolean) { const reportID = ReportUtils.getReportIDFromLink(url); if (reportID && !isAuthenticated) { @@ -2198,10 +2198,6 @@ function openReportFromDeepLink(url: string, isAuthenticated: boolean, blockNavi return; } - if (blockNavigate) { - return; - } - Navigation.navigate(route as Route, CONST.NAVIGATION.ACTION_TYPE.PUSH); }); }); diff --git a/src/pages/workspace/WorkspaceInitialPage.tsx b/src/pages/workspace/WorkspaceInitialPage.tsx index 279ad105d55f..b376ea6b0007 100644 --- a/src/pages/workspace/WorkspaceInitialPage.tsx +++ b/src/pages/workspace/WorkspaceInitialPage.tsx @@ -168,12 +168,11 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r (PolicyUtils.isPendingDeletePolicy(policy) && PolicyUtils.isPendingDeletePolicy(prevPolicy)); useEffect(() => { - if (!shouldShowNotFoundPage || !isEmptyObject(policy)) { + if (!shouldShowNotFoundPage) { return; } + // We are dismissing any modals that are open when the NotFound view is shown Navigation.dismissModal(); - Navigation.navigateWithSwitchPolicyID({route: ROUTES.HOME}); - Navigation.navigate(ROUTES.NOT_FOUND, CONST.NAVIGATION.TYPE.FORCED_UP); }, [policy, shouldShowNotFoundPage]); return ( diff --git a/src/pages/workspace/WorkspaceMembersPage.js b/src/pages/workspace/WorkspaceMembersPage.js index c88b3d56cb20..d1217e15803c 100644 --- a/src/pages/workspace/WorkspaceMembersPage.js +++ b/src/pages/workspace/WorkspaceMembersPage.js @@ -5,16 +5,13 @@ import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'; import {InteractionManager, View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; -import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import Button from '@components/Button'; import ConfirmModal from '@components/ConfirmModal'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; import * as Expensicons from '@components/Icon/Expensicons'; import * as Illustrations from '@components/Icon/Illustrations'; import MessagesRow from '@components/MessagesRow'; import networkPropTypes from '@components/networkPropTypes'; import {withNetwork} from '@components/OnyxProvider'; -import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; import Text from '@components/Text'; import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from '@components/withCurrentUserPersonalDetails'; @@ -39,6 +36,7 @@ import ROUTES from '@src/ROUTES'; import SearchInputManager from './SearchInputManager'; import {policyDefaultProps, policyPropTypes} from './withPolicy'; import withPolicyAndFullscreenLoading from './withPolicyAndFullscreenLoading'; +import WorkspacePageWithSections from './WorkspacePageWithSections'; const propTypes = { /** All personal details asssociated with user */ @@ -442,72 +440,62 @@ function WorkspaceMembersPage(props) { ); return ( - - Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} - > - { - setSearchValue(''); - Navigation.goBack(); - }} - shouldShowBackButton={isSmallScreenWidth} - guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_MEMBERS} - > - {!isSmallScreenWidth && getHeaderButtons()} - - {isSmallScreenWidth && {getHeaderButtons()}} - setRemoveMembersConfirmModalVisible(false)} - prompt={props.translate('workspace.people.removeMembersPrompt')} - confirmText={props.translate('common.remove')} - cancelText={props.translate('common.cancel')} - onModalHide={() => - InteractionManager.runAfterInteractions(() => { - if (!textInputRef.current) { - return; - } - textInputRef.current.focus(); - }) - } - /> - - { - SearchInputManager.searchInput = value; - setSearchValue(value); - }} - disableKeyboardShortcuts={removeMembersConfirmModalVisible} - headerMessage={getHeaderMessage()} - headerContent={getHeaderContent()} - onSelectRow={(item) => toggleUser(item.accountID)} - onSelectAll={() => toggleAllUsers(data)} - onDismissError={dismissError} - showLoadingPlaceholder={!isOfflineAndNoMemberDataAvailable && (!OptionsListUtils.isPersonalDetailsReady(props.personalDetails) || _.isEmpty(props.policyMembers))} - showScrollIndicator - shouldPreventDefaultFocusOnSelectRow={!DeviceCapabilities.canUseTouchScreen()} - inputRef={textInputRef} + {() => ( + <> + {isSmallScreenWidth && {getHeaderButtons()}} + setRemoveMembersConfirmModalVisible(false)} + prompt={props.translate('workspace.people.removeMembersPrompt')} + confirmText={props.translate('common.remove')} + cancelText={props.translate('common.cancel')} + onModalHide={() => + InteractionManager.runAfterInteractions(() => { + if (!textInputRef.current) { + return; + } + textInputRef.current.focus(); + }) + } /> - - - + + { + SearchInputManager.searchInput = value; + setSearchValue(value); + }} + disableKeyboardShortcuts={removeMembersConfirmModalVisible} + headerMessage={getHeaderMessage()} + headerContent={getHeaderContent()} + onSelectRow={(item) => toggleUser(item.accountID)} + onSelectAll={() => toggleAllUsers(data)} + onDismissError={dismissError} + showLoadingPlaceholder={!isOfflineAndNoMemberDataAvailable && (!OptionsListUtils.isPersonalDetailsReady(props.personalDetails) || _.isEmpty(props.policyMembers))} + showScrollIndicator + shouldPreventDefaultFocusOnSelectRow={!DeviceCapabilities.canUseTouchScreen()} + inputRef={textInputRef} + /> + + + )} + ); } @@ -527,9 +515,6 @@ export default compose( session: { key: ONYXKEYS.SESSION, }, - isLoadingReportData: { - key: ONYXKEYS.IS_LOADING_REPORT_DATA, - }, }), withCurrentUserPersonalDetails, )(WorkspaceMembersPage); diff --git a/src/pages/workspace/WorkspacePageWithSections.tsx b/src/pages/workspace/WorkspacePageWithSections.tsx index 46aca3bf58d8..dc1cbc15e0be 100644 --- a/src/pages/workspace/WorkspacePageWithSections.tsx +++ b/src/pages/workspace/WorkspacePageWithSections.tsx @@ -77,6 +77,12 @@ type WorkspacePageWithSectionsProps = WithPolicyAndFullscreenLoadingProps & * taller header on desktop and different font of the title. * */ icon?: IconAsset; + + /** Content to be added to the header */ + headerContent?: ReactNode; + + /** TestID of the component */ + testID?: string; }; function fetchData(skipVBBACal?: boolean) { @@ -105,6 +111,8 @@ function WorkspacePageWithSections({ shouldShowOfflineIndicatorInWideScreen = false, shouldShowNonAdmin = false, icon, + headerContent, + testID, }: WorkspacePageWithSectionsProps) { const styles = useThemeStyles(); useNetwork({onReconnect: () => fetchData(shouldSkipVBBACall)}); @@ -149,7 +157,7 @@ function WorkspacePageWithSections({ includeSafeAreaPaddingBottom={false} shouldEnablePickerAvoiding={false} shouldEnableMaxHeight - testID={WorkspacePageWithSections.displayName} + testID={testID ?? WorkspacePageWithSections.displayName} shouldShowOfflineIndicatorInWideScreen={shouldShowOfflineIndicatorInWideScreen && !shouldShow} > Navigation.goBack(backButtonRoute ?? ROUTES.WORKSPACE_INITIAL.getRoute(policyID))} icon={icon} - /> + > + {headerContent} + {(isLoading || firstRender.current) && shouldShowLoading ? ( ) : ( From 54f989d006e3c2928d58b8a3f5409595ca8dbb86 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Mon, 19 Feb 2024 12:35:33 +0100 Subject: [PATCH 05/11] cleanup --- src/pages/workspace/WorkspaceMembersPage.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceMembersPage.js b/src/pages/workspace/WorkspaceMembersPage.js index d1217e15803c..e4b46a138b85 100644 --- a/src/pages/workspace/WorkspaceMembersPage.js +++ b/src/pages/workspace/WorkspaceMembersPage.js @@ -57,7 +57,6 @@ const propTypes = { accountID: PropTypes.number, }), - isLoadingReportData: PropTypes.bool, ...policyPropTypes, ...withLocalizePropTypes, ...windowDimensionsPropTypes, From 5c69724492dfc95fef58c888a9bcea432a5b8cc9 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Mon, 19 Feb 2024 12:42:24 +0100 Subject: [PATCH 06/11] fix going back from settings list --- src/pages/workspace/WorkspacesListPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspacesListPage.tsx b/src/pages/workspace/WorkspacesListPage.tsx index 88ea1bf1ec54..a6fce458477c 100755 --- a/src/pages/workspace/WorkspacesListPage.tsx +++ b/src/pages/workspace/WorkspacesListPage.tsx @@ -362,7 +362,7 @@ function WorkspacesListPage({policies, allPolicyMembers, reimbursementAccount, r Navigation.goBack()} + onBackButtonPress={() => Navigation.goBack(ROUTES.ALL_SETTINGS)} >