Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Section/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function Section({
/>
)}
<View style={[styles.flexShrink1, styles.w100]}>
{renderTitle ? renderTitle() : <Text style={[styles.textHeadline, styles.cardSectionTitle, titleStyles]}>{title}</Text>}
{renderTitle ? renderTitle() : !!title && <Text style={[styles.textHeadline, styles.cardSectionTitle, titleStyles]}>{title}</Text>}
</View>
{cardLayout === CARD_LAYOUT.ICON_ON_RIGHT && (
<IconSection
Expand Down
82 changes: 38 additions & 44 deletions src/pages/workspace/WorkspaceOverviewPage.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {useFocusEffect, useIsFocused} from '@react-navigation/native';
import {accountIDSelector} from '@selectors/Session';
import React, {useCallback, useContext, useEffect, useRef, useState} from 'react';
import type {ImageStyle, StyleProp} from 'react-native';
import {Image, StyleSheet, View} from 'react-native';
import {View} from 'react-native';
import type {ValueOf} from 'type-fest';
import Avatar from '@components/Avatar';
import AvatarWithImagePicker from '@components/AvatarWithImagePicker';
import Button from '@components/Button';
import ButtonWithDropdownMenu from '@components/ButtonWithDropdownMenu';
import type {DropdownOption} from '@components/ButtonWithDropdownMenu/types';
import ConfirmModal from '@components/ConfirmModal';
import * as Expensicons from '@components/Icon/Expensicons';

Check warning on line 12 in src/pages/workspace/WorkspaceOverviewPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'@components/Icon/Expensicons' import is restricted from being used by a pattern. Direct imports from Icon/Expensicons are deprecated. Please use lazy loading hooks instead. Use `useMemoizedLazyExpensifyIcons` from @hooks/useLazyAsset. See docs/LAZY_ICONS_AND_ILLUSTRATIONS.md for details

Check warning on line 12 in src/pages/workspace/WorkspaceOverviewPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'@components/Icon/Expensicons' import is restricted from being used. Direct imports from @components/Icon/Expensicons are deprecated. Please use lazy loading hooks instead. Use `useMemoizedLazyExpensifyIcons` from @hooks/useLazyAsset. See docs/LAZY_ICONS_AND_ILLUSTRATIONS.md for details
import {LockedAccountContext} from '@components/LockedAccountModalProvider';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
Expand All @@ -26,7 +26,6 @@
import usePermissions from '@hooks/usePermissions';
import usePrevious from '@hooks/usePrevious';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeIllustrations from '@hooks/useThemeIllustrations';
import useThemeStyles from '@hooks/useThemeStyles';
import useTransactionViolationOfWorkspace from '@hooks/useTransactionViolationOfWorkspace';
import {close} from '@libs/actions/Modal';
Expand Down Expand Up @@ -72,7 +71,6 @@
const {translate} = useLocalize();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const illustrations = useThemeIllustrations();
const illustrationIcons = useMemoizedLazyIllustrations(['Building'] as const);
const expensifyIcons = useMemoizedLazyExpensifyIcons(['FallbackWorkspaceAvatar', 'ImageCropSquareMask', 'QrCode', 'Transfer', 'Trashcan', 'UserPlus'] as const);

Expand Down Expand Up @@ -160,7 +158,6 @@
const readOnly = !isPolicyAdminPolicyUtils(policy);
const currencyReadOnly = readOnly || isBankAccountVerified;
const isOwner = isPolicyOwner(policy, currentUserAccountID);
const imageStyle: StyleProp<ImageStyle> = shouldUseNarrowLayout ? [styles.mhv12, styles.mhn5, styles.mbn5] : [styles.mhv8, styles.mhn8, styles.mbn5];
const shouldShowAddress = !readOnly || !!formattedAddress;
const {isAccountLocked, showLockedAccountModal} = useContext(LockedAccountContext);
const [lastPaymentMethod] = useOnyx(ONYXKEYS.NVP_LAST_PAYMENT_METHOD, {canBeMissing: true});
Expand Down Expand Up @@ -381,20 +378,27 @@
};

const renderDropdownMenu = (options: Array<DropdownOption<string>>) => (
<View style={[!shouldUseNarrowLayout && styles.flexRow, !shouldUseNarrowLayout && styles.gap2]}>
<ButtonWithDropdownMenu
ref={dropdownMenuRef}
success={false}
onPress={() => {}}
shouldAlwaysShowDropdownMenu
customText={translate('common.more')}
options={options}
isSplitButton={false}
wrapperStyle={styles.flexGrow1}
/>
</View>
<ButtonWithDropdownMenu
ref={dropdownMenuRef}
success={false}
onPress={() => {}}
shouldAlwaysShowDropdownMenu
customText={translate('common.more')}
options={options}
isSplitButton={false}
wrapperStyle={isPolicyAdmin ? styles.flexGrow0 : styles.flexGrow1}
/>
);

const handleInvitePress = useCallback(() => {
if (isAccountLocked) {
showLockedAccountModal();
return;
}
clearInviteDraft(route.params.policyID);
Navigation.navigate(ROUTES.WORKSPACE_INVITE.getRoute(route.params.policyID, Navigation.getActiveRouteWithoutParams()));
}, [isAccountLocked, showLockedAccountModal, route.params.policyID]);

const getHeaderButtons = () => {
const secondaryActions: Array<DropdownOption<string>> = [];
const canLeave = !isOwner;
Expand All @@ -412,21 +416,6 @@
return null;
}

if (isPolicyAdmin) {
secondaryActions.push({
value: 'invite',
text: translate('common.invite'),
icon: expensifyIcons.UserPlus,
onSelected: () => {
if (isAccountLocked) {
showLockedAccountModal();
return;
}
clearInviteDraft(route.params.policyID);
Navigation.navigate(ROUTES.WORKSPACE_INVITE.getRoute(route.params.policyID, Navigation.getActiveRouteWithoutParams()));
},
});
}
secondaryActions.push({
value: 'share',
text: translate('common.share'),
Expand Down Expand Up @@ -463,7 +452,22 @@
});
}

return renderDropdownMenu(secondaryActions);
return (
<View style={[styles.flexRow, styles.gap2]}>
{isPolicyAdmin && (
<Button
success
text={translate('common.invite')}
icon={expensifyIcons.UserPlus}
onPress={handleInvitePress}
medium
innerStyles={[shouldUseNarrowLayout && styles.alignItemsCenter]}
style={[shouldUseNarrowLayout && styles.flexGrow1, shouldUseNarrowLayout && styles.mb3]}
/>
)}
{renderDropdownMenu(secondaryActions)}
</View>
);
};

return (
Expand Down Expand Up @@ -492,11 +496,6 @@
isCentralPane
title=""
>
<Image
style={StyleSheet.flatten([styles.wAuto, styles.h68, imageStyle])}
source={illustrations.WorkspaceProfile}
resizeMode="cover"
/>
<AvatarWithImagePicker
onViewPhotoPress={() => {
if (!policy?.id) {
Expand All @@ -513,12 +512,7 @@
DefaultAvatar={DefaultAvatar}
type={CONST.ICON_TYPE_WORKSPACE}
fallbackIcon={expensifyIcons.FallbackWorkspaceAvatar}
style={[
(policy?.errorFields?.avatarURL ?? shouldUseNarrowLayout) ? styles.mb1 : styles.mb3,
shouldUseNarrowLayout ? styles.mtn17 : styles.mtn20,
styles.alignItemsStart,
styles.sectionMenuItemTopDescription,
]}
style={[(policy?.errorFields?.avatarURL ?? shouldUseNarrowLayout) ? styles.mb1 : styles.mb3, styles.alignItemsStart, styles.sectionMenuItemTopDescription]}
editIconStyle={styles.smallEditIconWorkspace}
isUsingDefaultAvatar={!policy?.avatarURL}
onImageSelected={(file) => {
Expand Down
Loading