Skip to content
Closed
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
32 changes: 4 additions & 28 deletions src/components/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,6 @@ type MenuItemBaseProps = {
/** Whether the secondary right avatar should show as a subscript */
shouldShowSubscriptRightAvatar?: boolean;

/** Whether the secondary avatar should show as a subscript */
shouldShowSubscriptAvatar?: boolean;

/** Affects avatar size */
viewMode?: ValueOf<typeof CONST.OPTION_MODE>;

Expand Down Expand Up @@ -348,15 +345,6 @@ type MenuItemBaseProps = {
};

type MenuItemProps = (IconProps | AvatarProps | NoIcon) & MenuItemBaseProps;

const getSubscriptpAvatarBackgroundColor = (isHovered: boolean, isPressed: boolean, hoveredBackgroundColor: string, pressedBackgroundColor: string) => {
if (isPressed) {
return pressedBackgroundColor;
}
if (isHovered) {
return hoveredBackgroundColor;
}
};
function MenuItem(
{
interactive = true,
Expand Down Expand Up @@ -419,7 +407,6 @@ function MenuItem(
floatRightAvatars = [],
floatRightAvatarSize,
shouldShowSubscriptRightAvatar = false,
shouldShowSubscriptAvatar: shouldShowSubscriptAvatarProp = false,
avatarSize = CONST.AVATAR_SIZE.DEFAULT,
isSmallAvatarSubscriptMenu = false,
brickRoadIndicator,
Expand Down Expand Up @@ -470,7 +457,7 @@ function MenuItem(
const isDeleted = style && Array.isArray(style) ? style.includes(styles.offlineFeedback.deleted) : false;
const descriptionVerticalMargin = shouldShowDescriptionOnTop ? styles.mb1 : styles.mt1;
const fallbackAvatarSize = viewMode === CONST.OPTION_MODE.COMPACT ? CONST.AVATAR_SIZE.SMALL : CONST.AVATAR_SIZE.DEFAULT;
const firstRightIcon = floatRightAvatars.at(0);
const firstIcon = floatRightAvatars.at(0);
const combinedTitleTextStyle = StyleUtils.combineStyles(
[
styles.flexShrink1,
Expand All @@ -485,9 +472,6 @@ function MenuItem(
],
titleStyle ?? {},
);
const shouldShowAvatar = !!icon && Array.isArray(icon);
const firstIcon = Array.isArray(icon) && !!icon.length ? icon.at(0) : undefined;
const shouldShowSubscriptAvatar = shouldShowSubscriptAvatarProp && !!firstIcon;
const descriptionTextStyles = StyleUtils.combineStyles<TextStyle>([
styles.textLabelSupporting,
icon && !Array.isArray(icon) ? styles.ml3 : {},
Expand Down Expand Up @@ -637,7 +621,7 @@ function MenuItem(
</View>
)}
<View style={[styles.flexRow, styles.pointerEventsAuto, disabled && !shouldUseDefaultCursorWhenDisabled && styles.cursorDisabled]}>
{shouldShowAvatar && !shouldShowSubscriptAvatar && (
{!!icon && Array.isArray(icon) && (
<MultipleAvatars
isHovered={isHovered}
isPressed={pressed}
Expand All @@ -650,14 +634,6 @@ function MenuItem(
]}
/>
)}
{shouldShowAvatar && shouldShowSubscriptAvatar && (
<SubscriptAvatar
backgroundColor={getSubscriptpAvatarBackgroundColor(isHovered, pressed, theme.hoverComponentBG, theme.buttonHoveredBG)}
mainAvatar={firstIcon as IconType}
secondaryAvatar={(icon as IconType[]).at(1)}
size={avatarSize}
/>
)}
{!icon && shouldPutLeftPaddingWhenNoIcon && (
<View
style={[
Expand Down Expand Up @@ -826,12 +802,12 @@ function MenuItem(
<Text style={[styles.textLabelSupporting, ...(combinedStyle as TextStyle[])]}>{subtitle}</Text>
</View>
)}
{floatRightAvatars?.length > 0 && !!firstRightIcon && (
{floatRightAvatars?.length > 0 && !!firstIcon && (
<View style={[styles.alignItemsCenter, styles.justifyContentCenter, brickRoadIndicator ? styles.mr2 : styles.mrn2]}>
{shouldShowSubscriptRightAvatar ? (
<SubscriptAvatar
backgroundColor={isHovered ? theme.activeComponentBG : theme.componentBG}
mainAvatar={firstRightIcon}
mainAvatar={firstIcon}
secondaryAvatar={floatRightAvatars.at(1)}
size={floatRightAvatarSize ?? fallbackAvatarSize}
/>
Expand Down
1 change: 0 additions & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2539,7 +2539,6 @@ const translations = {
return 'Member';
}
},
submitExpense: 'Submit expenses using your workspace chat below:',
defaultCategory: 'Default category',
},
perDiem: {
Expand Down
1 change: 0 additions & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2563,7 +2563,6 @@ const translations = {
return 'Miembro';
}
},
submitExpense: 'Envíe los gastos utilizando el chat de su espacio de trabajo:',
defaultCategory: 'Categoría predeterminada',
},
perDiem: {
Expand Down
26 changes: 3 additions & 23 deletions src/pages/workspace/WorkspaceInitialPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import ConfirmModal from '@components/ConfirmModal';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import HighlightableMenuItem from '@components/HighlightableMenuItem';
import * as Expensicons from '@components/Icon/Expensicons';
import MenuItem from '@components/MenuItem';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import ScreenWrapper from '@components/ScreenWrapper';
import ScrollView from '@components/ScrollView';
import Text from '@components/Text';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
Expand All @@ -27,7 +25,7 @@ import getTopmostRouteName from '@libs/Navigation/getTopmostRouteName';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import * as PolicyUtils from '@libs/PolicyUtils';
import {getDefaultWorkspaceAvatar, getIcons, getPolicyExpenseChat, getReportName, getReportOfflinePendingActionAndErrors} from '@libs/ReportUtils';
import {getDefaultWorkspaceAvatar} from '@libs/ReportUtils';
import type {FullScreenNavigatorParamList} from '@navigation/types';
import * as App from '@userActions/App';
import * as Policy from '@userActions/Policy/Policy';
Expand Down Expand Up @@ -95,18 +93,13 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac
const [connectionSyncProgress] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policy?.id}`);
const [currentUserLogin] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.email});
const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${route.params?.policyID ?? '-1'}`);
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);
const {login, accountID} = useCurrentUserPersonalDetails();
const hasSyncError = PolicyUtils.shouldShowSyncError(policy, isConnectionInProgress(connectionSyncProgress, policy));
const waitForNavigate = useWaitForNavigation();
const {singleExecution, isExecuting} = useSingleExecution();
const activeRoute = useNavigationState(getTopmostRouteName);
const {translate} = useLocalize();
const {isOffline} = useNetwork();
const wasRendered = useRef(false);
const currentUserPolicyExpenseChatReportID = getPolicyExpenseChat(accountID, policy?.id ?? '-1')?.reportID ?? '-1';
const [currentUserPolicyExpenseChat] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${currentUserPolicyExpenseChatReportID}`);
const {reportPendingAction} = getReportOfflinePendingActionAndErrors(currentUserPolicyExpenseChat);

const prevPendingFields = usePrevious(policy?.pendingFields);
const policyFeatureStates = useMemo(
Expand Down Expand Up @@ -166,6 +159,7 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac
!isEmptyObject(policy?.errorFields?.avatarURL ?? {}) ||
!isEmptyObject(policy?.errorFields?.ouputCurrency ?? {}) ||
!isEmptyObject(policy?.errorFields?.address ?? {});
const {login} = useCurrentUserPersonalDetails();
const shouldShowProtectedItems = PolicyUtils.isPolicyAdmin(policy, login);
const isPaidGroupPolicy = PolicyUtils.isPaidGroupPolicy(policy);
const [featureStates, setFeatureStates] = useState(policyFeatureStates);
Expand Down Expand Up @@ -414,7 +408,7 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac
style={styles.headerBarDesktopHeight}
/>

<ScrollView contentContainerStyle={[styles.flexColumn]}>
<ScrollView contentContainerStyle={[styles.flexGrow1, styles.flexColumn, styles.justifyContentBetween]}>
<OfflineWithFeedback
pendingAction={policy?.pendingAction}
onClose={() => dismissError(policyID, policy?.pendingAction)}
Expand Down Expand Up @@ -446,20 +440,6 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac
))}
</View>
</OfflineWithFeedback>
<View style={[styles.pb4, styles.mh3, styles.mt3]}>
<Text style={[styles.textSupporting, styles.fontSizeLabel, styles.ph2]}>{translate('workspace.common.submitExpense')}</Text>
<OfflineWithFeedback pendingAction={reportPendingAction}>
<MenuItem
title={getReportName(currentUserPolicyExpenseChat)}
description={translate('workspace.common.workspace')}
icon={getIcons(currentUserPolicyExpenseChat, personalDetails)}
onPress={() => Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(currentUserPolicyExpenseChat?.reportID ?? '-1'))}
shouldShowRightIcon
wrapperStyle={[styles.br2, styles.pl2, styles.pr0, styles.pv3, styles.mt1, styles.alignItemsCenter]}
shouldShowSubscriptAvatar
/>
</OfflineWithFeedback>
</View>
</ScrollView>
<ConfirmModal
title={translate('workspace.bankAccount.workspaceCurrency')}
Expand Down