Skip to content

Commit b8f6308

Browse files
authored
Merge pull request #59575 from software-mansion-labs/improve-desktop-nav/remove-workspace-from-headers
[Desktop Navigation] Drop the <Workspace> from the LHN headers
2 parents d0c12b6 + 0ce11a9 commit b8f6308

File tree

13 files changed

+81
-143
lines changed

13 files changed

+81
-143
lines changed

src/components/HeaderWithBackButton/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import HelpButton from '@components/SidePanel/HelpComponents/HelpButton';
1212
import ThreeDotsMenu from '@components/ThreeDotsMenu';
1313
import Tooltip from '@components/Tooltip';
1414
import useLocalize from '@hooks/useLocalize';
15+
import usePermissions from '@hooks/usePermissions';
1516
import useStyleUtils from '@hooks/useStyleUtils';
1617
import useTheme from '@hooks/useTheme';
1718
import useThemeStyles from '@hooks/useThemeStyles';
@@ -78,6 +79,7 @@ function HeaderWithBackButton({
7879
const StyleUtils = useStyleUtils();
7980
const [isDownloadButtonActive, temporarilyDisableDownloadButton] = useThrottledButtonState();
8081
const {translate} = useLocalize();
82+
const {canUseLeftHandBar} = usePermissions();
8183

8284
const middleContent = useMemo(() => {
8385
if (progressBarPercentage) {
@@ -143,7 +145,7 @@ function HeaderWithBackButton({
143145
dataSet={{dragArea: false}}
144146
style={[
145147
styles.headerBar,
146-
shouldUseHeadlineHeader && styles.headerBarDesktopHeight,
148+
shouldUseHeadlineHeader && styles.headerBarDesktopHeight(canUseLeftHandBar),
147149
shouldShowBorderBottom && styles.borderBottom,
148150
// progressBarPercentage can be 0 which would
149151
// be falsey, hence using !== undefined explicitly

src/components/Navigation/TopBar.tsx

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import HelpButton from '@components/SidePanel/HelpComponents/HelpButton';
99
import Text from '@components/Text';
1010
import WorkspaceSwitcherButton from '@components/WorkspaceSwitcherButton';
1111
import useLocalize from '@hooks/useLocalize';
12+
import usePermissions from '@hooks/usePermissions';
1213
import usePolicy from '@hooks/usePolicy';
1314
import useThemeStyles from '@hooks/useThemeStyles';
1415
import SignInButton from '@pages/home/sidebar/SignInButton';
@@ -31,6 +32,7 @@ function TopBar({breadcrumbLabel, activeWorkspaceID, shouldDisplaySearch = true,
3132
const [session] = useOnyx(ONYXKEYS.SESSION, {selector: (sessionValue) => sessionValue && {authTokenType: sessionValue.authTokenType}});
3233
const [isLoadingReportData] = useOnyx(ONYXKEYS.IS_LOADING_REPORT_DATA);
3334
const isAnonymousUser = isAnonymousUserUtil(session);
35+
const {canUseLeftHandBar} = usePermissions();
3436

3537
const headerBreadcrumb = policy?.name
3638
? {type: CONST.BREADCRUMB_TYPE.STRONG, text: policy.name}
@@ -44,28 +46,47 @@ function TopBar({breadcrumbLabel, activeWorkspaceID, shouldDisplaySearch = true,
4446
return (
4547
<View style={[styles.w100, styles.zIndex10]}>
4648
<View
47-
style={[styles.flexRow, styles.ml5, styles.mr3, styles.mv5, styles.alignItemsCenter, styles.justifyContentBetween]}
49+
style={[
50+
styles.flexRow,
51+
styles.alignItemsCenter,
52+
styles.justifyContentBetween,
53+
styles.ml5,
54+
styles.mr3,
55+
canUseLeftHandBar ? [styles.headerBarDesktopHeight(true)] : [styles.mv5],
56+
]}
4857
dataSet={{dragArea: true}}
4958
>
5059
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter, styles.pr2]}>
51-
<WorkspaceSwitcherButton policy={policy} />
52-
53-
<View style={[styles.ml3, styles.flex1]}>
54-
<Breadcrumbs
55-
breadcrumbs={[
56-
headerBreadcrumb,
57-
{
58-
text: breadcrumbLabel,
59-
},
60-
]}
61-
/>
62-
</View>
60+
{canUseLeftHandBar ? (
61+
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter]}>
62+
<Text
63+
numberOfLines={1}
64+
style={[styles.flexShrink1, styles.topBarLabel]}
65+
>
66+
{breadcrumbLabel}
67+
</Text>
68+
</View>
69+
) : (
70+
<>
71+
<WorkspaceSwitcherButton policy={policy} />
72+
<View style={[styles.ml3, styles.flex1]}>
73+
<Breadcrumbs
74+
breadcrumbs={[
75+
headerBreadcrumb,
76+
{
77+
text: breadcrumbLabel,
78+
},
79+
]}
80+
/>
81+
</View>
82+
</>
83+
)}
6384
</View>
6485
{displaySignIn && <SignInButton />}
6586
{!!cancelSearch && (
6687
<PressableWithoutFeedback
6788
accessibilityLabel={translate('common.cancel')}
68-
style={[styles.textBlue, styles.ph2]}
89+
style={[styles.textBlue, !canUseLeftHandBar && styles.ph2]}
6990
onPress={() => {
7091
cancelSearch();
7192
}}

src/components/ReportHeaderSkeletonView.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import {View} from 'react-native';
33
import {Circle, Rect} from 'react-native-svg';
44
import useLocalize from '@hooks/useLocalize';
5+
import usePermissions from '@hooks/usePermissions';
56
import useResponsiveLayout from '@hooks/useResponsiveLayout';
67
import useTheme from '@hooks/useTheme';
78
import useThemeStyles from '@hooks/useThemeStyles';
@@ -20,9 +21,10 @@ function ReportHeaderSkeletonView({shouldAnimate = true, onBackButtonPress = ()
2021
const theme = useTheme();
2122
const styles = useThemeStyles();
2223
const {translate} = useLocalize();
24+
const {canUseLeftHandBar} = usePermissions();
2325
const {shouldUseNarrowLayout} = useResponsiveLayout();
2426
const smallScreenHeight = styles.appContentHeader.height;
25-
const height = !shouldUseNarrowLayout ? styles.headerBarDesktopHeight.height : smallScreenHeight;
27+
const height = !shouldUseNarrowLayout ? styles.headerBarDesktopHeight(canUseLeftHandBar).height : smallScreenHeight;
2628
const radius = 20;
2729
const circleY = height / 2;
2830
const circleTopY = circleY - radius;

src/components/Search/SearchRouter/SearchButton.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ import {useSearchRouterContext} from './SearchRouterContext';
1515

1616
type SearchButtonProps = {
1717
style?: StyleProp<ViewStyle>;
18+
shouldUseAutoHitSlop?: boolean;
1819
};
1920

20-
function SearchButton({style}: SearchButtonProps) {
21+
function SearchButton({style, shouldUseAutoHitSlop = false}: SearchButtonProps) {
2122
const styles = useThemeStyles();
2223
const theme = useTheme();
2324
const {translate} = useLocalize();
@@ -31,6 +32,7 @@ function SearchButton({style}: SearchButtonProps) {
3132
testID="searchButton"
3233
accessibilityLabel={translate('common.search')}
3334
style={[styles.flexRow, styles.touchableButtonImage, style]}
35+
shouldUseAutoHitSlop={shouldUseAutoHitSlop}
3436
// eslint-disable-next-line react-compiler/react-compiler
3537
onPress={callFunctionIfActionIsAllowed(() => {
3638
pressableRef?.current?.blur();

src/components/SidePanel/HelpComponents/HelpContent.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import HeaderWithBackButton from '@components/HeaderWithBackButton';
99
import getHelpContent from '@components/SidePanel/getHelpContent';
1010
import useEnvironment from '@hooks/useEnvironment';
1111
import useLocalize from '@hooks/useLocalize';
12+
import usePermissions from '@hooks/usePermissions';
1213
import useResponsiveLayout from '@hooks/useResponsiveLayout';
1314
import useRootNavigationState from '@hooks/useRootNavigationState';
1415
import useThemeStyles from '@hooks/useThemeStyles';
@@ -31,6 +32,7 @@ function HelpContent({closeSidePanel}: HelpContentProps) {
3132
const {isProduction} = useEnvironment();
3233
const {isExtraLargeScreenWidth} = useResponsiveLayout();
3334
const [expandedIndex, setExpandedIndex] = useState(0);
35+
const {canUseLeftHandBar} = usePermissions();
3436

3537
const {params, routeName} = useRootNavigationState(() => {
3638
const focusedRoute = findFocusedRoute(navigationRef.getRootState());
@@ -84,7 +86,7 @@ function HelpContent({closeSidePanel}: HelpContentProps) {
8486
<HeaderGap />
8587
<HeaderWithBackButton
8688
title={translate('common.help')}
87-
style={styles.headerBarDesktopHeight}
89+
style={styles.headerBarDesktopHeight(canUseLeftHandBar)}
8890
onBackButtonPress={() => closeSidePanel(false)}
8991
onCloseButtonPress={() => closeSidePanel(false)}
9092
shouldShowBackButton={!isExtraLargeScreenWidth}

src/pages/ConciergePage.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import {useOnyx} from 'react-native-onyx';
55
import ReportActionsSkeletonView from '@components/ReportActionsSkeletonView';
66
import ReportHeaderSkeletonView from '@components/ReportHeaderSkeletonView';
77
import ScreenWrapper from '@components/ScreenWrapper';
8+
import usePermissions from '@hooks/usePermissions';
89
import useResponsiveLayout from '@hooks/useResponsiveLayout';
910
import useThemeStyles from '@hooks/useThemeStyles';
11+
import {confirmReadyToOpenApp} from '@libs/actions/App';
12+
import {navigateToConciergeChat} from '@libs/actions/Report';
13+
import {completeTask} from '@libs/actions/Task';
1014
import Navigation from '@libs/Navigation/Navigation';
11-
import * as App from '@userActions/App';
12-
import * as Report from '@userActions/Report';
13-
import * as Task from '@userActions/Task';
1415
import CONST from '@src/CONST';
1516
import ONYXKEYS from '@src/ONYXKEYS';
1617
import ROUTES from '@src/ROUTES';
@@ -27,6 +28,7 @@ function ConciergePage() {
2728
const [session] = useOnyx(ONYXKEYS.SESSION);
2829
const [isLoadingReportData] = useOnyx(ONYXKEYS.IS_LOADING_REPORT_DATA, {initialValue: true});
2930
const route = useRoute();
31+
const {canUseLeftHandBar} = usePermissions();
3032

3133
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
3234
const viewTourTaskReportID = introSelected?.viewTour;
@@ -35,7 +37,7 @@ function ConciergePage() {
3537
useFocusEffect(
3638
useCallback(() => {
3739
if (session && 'authToken' in session) {
38-
App.confirmReadyToOpenApp();
40+
confirmReadyToOpenApp();
3941
Navigation.isNavigationReady().then(() => {
4042
if (isUnmounted.current || isLoadingReportData === undefined || !!isLoadingReportData) {
4143
return;
@@ -46,11 +48,11 @@ function ConciergePage() {
4648
if (navattic === CONST.NAVATTIC.COMPLETED) {
4749
if (viewTourTaskReport) {
4850
if (viewTourTaskReport.stateNum !== CONST.REPORT.STATE_NUM.APPROVED || viewTourTaskReport.statusNum !== CONST.REPORT.STATUS_NUM.APPROVED) {
49-
Task.completeTask(viewTourTaskReport);
51+
completeTask(viewTourTaskReport);
5052
}
5153
}
5254
}
53-
Report.navigateToConciergeChat(true, () => !isUnmounted.current);
55+
navigateToConciergeChat(true, () => !isUnmounted.current);
5456
});
5557
} else {
5658
Navigation.navigate(ROUTES.HOME);
@@ -67,7 +69,7 @@ function ConciergePage() {
6769

6870
return (
6971
<ScreenWrapper testID={ConciergePage.displayName}>
70-
<View style={[styles.borderBottom, styles.appContentHeader, !shouldUseNarrowLayout && styles.headerBarDesktopHeight]}>
72+
<View style={[styles.borderBottom, styles.appContentHeader, !shouldUseNarrowLayout && styles.headerBarDesktopHeight(canUseLeftHandBar)]}>
7173
<ReportHeaderSkeletonView onBackButtonPress={Navigation.goBack} />
7274
</View>
7375
<ReportActionsSkeletonView />

src/pages/home/HeaderView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked,
121121
const styles = useThemeStyles();
122122
const isSelfDM = isSelfDMReportUtils(report);
123123
const isGroupChat = isGroupChatReportUtils(report) || isDeprecatedGroupDM(report);
124-
const {canUseTalkToAISales} = usePermissions();
124+
const {canUseTalkToAISales, canUseLeftHandBar} = usePermissions();
125125
const shouldShowTalkToSales = !!canUseTalkToAISales && isAdminRoom(report);
126126

127127
const allParticipants = getParticipantsAccountIDsForDisplay(report, false, true);
@@ -239,7 +239,7 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked,
239239
style={[styles.borderBottom]}
240240
dataSet={{dragArea: true}}
241241
>
242-
<View style={[styles.appContentHeader, styles.pr3, !shouldUseNarrowLayout && styles.headerBarDesktopHeight]}>
242+
<View style={[styles.appContentHeader, styles.pr3, !shouldUseNarrowLayout && styles.headerBarDesktopHeight(canUseLeftHandBar)]}>
243243
{isLoading ? (
244244
<ReportHeaderSkeletonView onBackButtonPress={onNavigationMenuButtonClicked} />
245245
) : (

src/pages/settings/InitialSettingsPage.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentU
2525
import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails';
2626
import useLocalize from '@hooks/useLocalize';
2727
import useNetwork from '@hooks/useNetwork';
28+
import usePermissions from '@hooks/usePermissions';
2829
import useSingleExecution from '@hooks/useSingleExecution';
2930
import useSubscriptionPlan from '@hooks/useSubscriptionPlan';
3031
import useTheme from '@hooks/useTheme';
@@ -101,6 +102,7 @@ function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPagePr
101102
const emojiCode = currentUserPersonalDetails?.status?.emojiCode ?? '';
102103
const [allConnectionSyncProgresses] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}`);
103104
const {setRootStatusBarEnabled} = useContext(CustomStatusBarAndBackgroundContext);
105+
const {canUseLeftHandBar} = usePermissions();
104106

105107
const [privateSubscription] = useOnyx(ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION);
106108
const subscriptionPlan = useSubscriptionPlan();
@@ -376,11 +378,11 @@ function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPagePr
376378
const workspaceMenuItems = useMemo(() => getMenuItemsSection(workspaceMenuItemsData), [workspaceMenuItemsData, getMenuItemsSection]);
377379

378380
const headerContent = (
379-
<View style={[styles.ph5, styles.pv5]}>
381+
<View style={[styles.ph5, !canUseLeftHandBar && styles.pv5]}>
380382
{isEmptyObject(currentUserPersonalDetails) || currentUserPersonalDetails.displayName === undefined ? (
381383
<AccountSwitcherSkeletonView avatarSize={CONST.AVATAR_SIZE.DEFAULT} />
382384
) : (
383-
<View style={[styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter, styles.gap3]}>
385+
<View style={[styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter, styles.gap3, canUseLeftHandBar ? [styles.headerBarDesktopHeight(true)] : []]}>
384386
<AccountSwitcher />
385387
<Tooltip text={translate('statusPage.status')}>
386388
<PressableWithFeedback

src/pages/workspace/WorkspaceInitialPage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import Text from '@components/Text';
3434
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
3535
import useLocalize from '@hooks/useLocalize';
3636
import useNetwork from '@hooks/useNetwork';
37+
import usePermissions from '@hooks/usePermissions';
3738
import usePrevious from '@hooks/usePrevious';
3839
import useResponsiveLayout from '@hooks/useResponsiveLayout';
3940
import useSingleExecution from '@hooks/useSingleExecution';
@@ -125,6 +126,7 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac
125126
const {reportPendingAction} = getReportOfflinePendingActionAndErrors(currentUserPolicyExpenseChat);
126127
const isPolicyExpenseChatEnabled = !!policy?.isPolicyExpenseChatEnabled;
127128
const prevPendingFields = usePrevious(policy?.pendingFields);
129+
const {canUseLeftHandBar} = usePermissions();
128130
const policyFeatureStates = useMemo(
129131
() => ({
130132
[CONST.POLICY.MORE_FEATURES.ARE_DISTANCE_RATES_ENABLED]: policy?.areDistanceRatesEnabled,
@@ -445,7 +447,7 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac
445447
title={policyName}
446448
onBackButtonPress={() => Navigation.goBack(route.params?.backTo ?? ROUTES.SETTINGS_WORKSPACES.route)}
447449
policyAvatar={policyAvatar}
448-
style={styles.headerBarDesktopHeight}
450+
style={styles.headerBarDesktopHeight(canUseLeftHandBar)}
449451
shouldDisplayHelpButton={shouldUseNarrowLayout}
450452
/>
451453

src/pages/workspace/WorkspacePageWithSections.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type HeaderWithBackButtonProps from '@components/HeaderWithBackButton/typ
1111
import ScreenWrapper from '@components/ScreenWrapper';
1212
import ScrollViewWithContext from '@components/ScrollViewWithContext';
1313
import useNetwork from '@hooks/useNetwork';
14+
import usePermissions from '@hooks/usePermissions';
1415
import usePrevious from '@hooks/usePrevious';
1516
import useResponsiveLayout from '@hooks/useResponsiveLayout';
1617
import useThemeStyles from '@hooks/useThemeStyles';
@@ -122,6 +123,7 @@ function WorkspacePageWithSections({
122123
const styles = useThemeStyles();
123124
const policyID = route.params?.policyID;
124125
const {isOffline} = useNetwork({onReconnect: () => fetchData(policyID, shouldSkipVBBACall)});
126+
const {canUseLeftHandBar} = usePermissions();
125127

126128
const [user] = useOnyx(ONYXKEYS.USER);
127129
const [reimbursementAccount = CONST.REIMBURSEMENT_ACCOUNT.DEFAULT_DATA] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT);
@@ -137,6 +139,7 @@ function WorkspacePageWithSections({
137139
const firstRender = useRef(showLoadingAsFirstRender);
138140
const isFocused = useIsFocused();
139141
const prevPolicy = usePrevious(policy);
142+
140143
useEffect(() => {
141144
// Because isLoading is false before merging in Onyx, we need firstRender ref to display loading page as well before isLoading is change to true
142145
firstRender.current = false;
@@ -182,7 +185,7 @@ function WorkspacePageWithSections({
182185
onBackButtonPress={() => (onBackButtonPress ? onBackButtonPress() : Navigation.goBack(backButtonRoute))}
183186
shouldShowBackButton={shouldUseNarrowLayout || shouldShowBackButton}
184187
icon={icon ?? undefined}
185-
style={styles.headerBarDesktopHeight}
188+
style={styles.headerBarDesktopHeight(canUseLeftHandBar)}
186189
shouldShowThreeDotsButton={shouldShowThreeDotsButton}
187190
threeDotsMenuItems={threeDotsMenuItems}
188191
threeDotsAnchorPosition={threeDotsAnchorPosition}

src/pages/workspace/categories/WorkspaceCategoriesPage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import useEnvironment from '@hooks/useEnvironment';
2828
import useLocalize from '@hooks/useLocalize';
2929
import useMobileSelectionMode from '@hooks/useMobileSelectionMode';
3030
import useNetwork from '@hooks/useNetwork';
31+
import usePermissions from '@hooks/usePermissions';
3132
import usePolicy from '@hooks/usePolicy';
3233
import useResponsiveLayout from '@hooks/useResponsiveLayout';
3334
import useSearchBackPress from '@hooks/useSearchBackPress';
@@ -84,6 +85,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) {
8485
const isConnectedToAccounting = Object.keys(policy?.connections ?? {}).length > 0;
8586
const currentConnectionName = getCurrentConnectionName(policy);
8687
const isQuickSettingsFlow = !!backTo;
88+
const {canUseLeftHandBar} = usePermissions();
8789

8890
const canSelectMultiple = isSmallScreenWidth ? selectionMode?.isEnabled : true;
8991

@@ -420,7 +422,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) {
420422
Navigation.goBack(backTo);
421423
}}
422424
shouldShowThreeDotsButton
423-
style={styles.headerBarDesktopHeight}
425+
style={styles.headerBarDesktopHeight(canUseLeftHandBar)}
424426
threeDotsMenuItems={threeDotsMenuItems}
425427
threeDotsAnchorPosition={threeDotsAnchorPosition}
426428
>

0 commit comments

Comments
 (0)