Skip to content

Commit d53e7ea

Browse files
authored
Revert "Add dropdown button to empty report"
1 parent 3be83c4 commit d53e7ea

20 files changed

Lines changed: 46 additions & 103 deletions

src/CONST/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,7 @@ const CONST = {
10651065
REMOVE_HOLD: 'removeHold',
10661066
REVIEW_DUPLICATES: 'reviewDuplicates',
10671067
MARK_AS_CASH: 'markAsCash',
1068+
ADD_EXPENSE: 'addExpense',
10681069
},
10691070
TRANSACTION_PRIMARY_ACTIONS: {
10701071
REMOVE_HOLD: 'removeHold',

src/components/EmptyStateComponent/index.tsx

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import isEmpty from 'lodash/isEmpty';
33
import React, {useMemo, useState} from 'react';
44
import {View} from 'react-native';
55
import Button from '@components/Button';
6-
import ButtonWithDropdownMenu from '@components/ButtonWithDropdownMenu';
76
import ImageSVG from '@components/ImageSVG';
87
import Lottie from '@components/Lottie';
98
import Text from '@components/Text';
@@ -104,30 +103,19 @@ function EmptyStateComponent({
104103
{subtitleText ?? <Text style={[styles.textAlignCenter, styles.textSupporting, styles.textNormal]}>{subtitle}</Text>}
105104
{children}
106105
{!isEmpty(buttons) && (
107-
<View style={[styles.gap2, styles.mt5, !shouldUseNarrowLayout ? styles.flexRow : styles.flexColumn, styles.justifyContentCenter]}>
108-
{buttons?.map(({buttonText, buttonAction, success, icon, isDisabled, style, dropDownOptions}) =>
109-
dropDownOptions ? (
110-
<ButtonWithDropdownMenu
111-
onPress={() => {}}
112-
shouldAlwaysShowDropdownMenu
113-
customText={buttonText}
114-
options={dropDownOptions}
115-
isSplitButton={false}
116-
style={[styles.flex1, style]}
117-
/>
118-
) : (
119-
<Button
120-
key={buttonText}
121-
success={success}
122-
onPress={buttonAction}
123-
text={buttonText}
124-
icon={icon}
125-
large
126-
isDisabled={isDisabled}
127-
style={[styles.flex1, style]}
128-
/>
129-
),
130-
)}
106+
<View style={[styles.gap2, styles.mt5, !shouldUseNarrowLayout ? styles.flexRow : styles.flexColumn]}>
107+
{buttons?.map(({buttonText, buttonAction, success, icon, isDisabled, style}) => (
108+
<Button
109+
key={buttonText}
110+
success={success}
111+
onPress={buttonAction}
112+
text={buttonText}
113+
icon={icon}
114+
large
115+
isDisabled={isDisabled}
116+
style={[styles.flex1, style]}
117+
/>
118+
))}
131119
</View>
132120
)}
133121
</View>

src/components/EmptyStateComponent/types.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type {ImageStyle} from 'expo-image';
22
import type {StyleProp, TextStyle, ViewStyle} from 'react-native';
33
import type {ValueOf} from 'type-fest';
4-
import type {DropdownOption} from '@components/ButtonWithDropdownMenu/types';
54
import type DotLottieAnimation from '@components/LottieAnimations/types';
65
import type SearchRowSkeleton from '@components/Skeletons/SearchRowSkeleton';
76
import type TableRowSkeleton from '@components/Skeletons/TableRowSkeleton';
@@ -10,15 +9,7 @@ import type IconAsset from '@src/types/utils/IconAsset';
109

1110
type ValidSkeletons = typeof SearchRowSkeleton | typeof TableRowSkeleton;
1211
type MediaTypes = ValueOf<typeof CONST.EMPTY_STATE_MEDIA>;
13-
type EmptyStateButton = {
14-
buttonText?: string;
15-
buttonAction?: () => void;
16-
success?: boolean;
17-
icon?: IconAsset;
18-
isDisabled?: boolean;
19-
style?: StyleProp<ViewStyle>;
20-
dropDownOptions?: Array<DropdownOption<ValueOf<{readonly CREATE_NEW_EXPENSE: 'createNewExpense'; readonly ADD_UNREPORTED_EXPENSE: 'addUnreportedExpense'}>>>;
21-
};
12+
type EmptyStateButton = {buttonText?: string; buttonAction?: () => void; success?: boolean; icon?: IconAsset; isDisabled?: boolean; style?: StyleProp<ViewStyle>};
2213

2314
type SharedProps<T> = {
2415
SkeletonComponent?: ValidSkeletons;

src/components/MoneyReportHeader.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,15 @@ function MoneyReportHeader({
620620
}}
621621
/>
622622
),
623+
[CONST.REPORT.PRIMARY_ACTIONS.ADD_EXPENSE]: (
624+
<ButtonWithDropdownMenu
625+
onPress={() => {}}
626+
shouldAlwaysShowDropdownMenu
627+
customText={translate('iou.addExpense')}
628+
options={addExpenseDropdownOptions}
629+
isSplitButton={false}
630+
/>
631+
),
623632
};
624633

625634
const [offlineModalVisible, setOfflineModalVisible] = useState(false);

src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import DecisionModal from '@components/DecisionModal';
1313
import FlatList from '@components/FlatList';
1414
import {AUTOSCROLL_TO_TOP_THRESHOLD} from '@components/InvertedFlatList/BaseInvertedFlatList';
1515
import {PressableWithFeedback} from '@components/Pressable';
16-
import ScrollView from '@components/ScrollView';
1716
import {useSearchContext} from '@components/Search/SearchContext';
1817
import Text from '@components/Text';
1918
import useLoadReportActions from '@hooks/useLoadReportActions';
@@ -617,16 +616,13 @@ function MoneyRequestReportActionsList({
617616
onClick={scrollToBottomAndMarkReportAsRead}
618617
/>
619618
{isEmpty(visibleReportActions) && isEmpty(transactions) && !showReportActionsLoadingState ? (
620-
<ScrollView>
619+
<>
621620
<MoneyRequestViewReportFields
622621
report={report}
623622
policy={policy}
624623
/>
625-
<SearchMoneyRequestReportEmptyState
626-
reportId={report.reportID}
627-
policy={policy}
628-
/>
629-
</ScrollView>
624+
<SearchMoneyRequestReportEmptyState />
625+
</>
630626
) : (
631627
<FlatList
632628
initialNumToRender={INITIAL_NUM_TO_RENDER}
@@ -655,7 +651,6 @@ function MoneyRequestReportActionsList({
655651
hasComments={reportHasComments}
656652
isLoadingInitialReportActions={showReportActionsLoadingState}
657653
scrollToNewTransaction={scrollToNewTransaction}
658-
policy={policy}
659654
/>
660655
</>
661656
}

src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ import SearchMoneyRequestReportEmptyState from './SearchMoneyRequestReportEmptyS
4646
type MoneyRequestReportTransactionListProps = {
4747
report: OnyxTypes.Report;
4848

49-
policy?: OnyxTypes.Policy;
50-
5149
/** List of transactions belonging to one report */
5250
transactions: OnyxTypes.Transaction[];
5351

@@ -113,7 +111,6 @@ function MoneyRequestReportTransactionList({
113111
hasComments,
114112
isLoadingInitialReportActions: isLoadingReportActions,
115113
scrollToNewTransaction,
116-
policy,
117114
}: MoneyRequestReportTransactionListProps) {
118115
useCopySelectionHelper();
119116
const styles = useThemeStyles();
@@ -368,10 +365,7 @@ function MoneyRequestReportTransactionList({
368365
</Modal>
369366
</>
370367
) : (
371-
<SearchMoneyRequestReportEmptyState
372-
reportId={report.reportID}
373-
policy={policy}
374-
/>
368+
<SearchMoneyRequestReportEmptyState />
375369
)}
376370
<View style={[styles.dFlex, styles.flexRow, listHorizontalPadding, styles.justifyContentBetween, styles.mb2]}>
377371
<Animated.Text

src/components/MoneyRequestReportView/SearchMoneyRequestReportEmptyState.tsx

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,17 @@
11
import React from 'react';
22
import {View} from 'react-native';
33
import EmptyStateComponent from '@components/EmptyStateComponent';
4-
import * as Expensicons from '@components/Icon/Expensicons';
54
import LottieAnimations from '@components/LottieAnimations';
65
import useLocalize from '@hooks/useLocalize';
76
import useThemeStyles from '@hooks/useThemeStyles';
8-
import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils';
9-
import Navigation from '@navigation/Navigation';
10-
import {startMoneyRequest} from '@userActions/IOU';
11-
import {openUnreportedExpense} from '@userActions/Report';
127
import CONST from '@src/CONST';
13-
import ROUTES from '@src/ROUTES';
14-
import type {Policy} from '@src/types/onyx';
158

169
const minModalHeight = 380;
1710

18-
function SearchMoneyRequestReportEmptyState({reportId, policy}: {reportId?: string; policy?: Policy}) {
11+
function SearchMoneyRequestReportEmptyState() {
1912
const {translate} = useLocalize();
2013
const styles = useThemeStyles();
2114

22-
const addExpenseDropdownOptions = [
23-
{
24-
value: CONST.REPORT.ADD_EXPENSE_OPTIONS.CREATE_NEW_EXPENSE,
25-
text: translate('iou.createNewExpense'),
26-
icon: Expensicons.Plus,
27-
onSelected: () => {
28-
if (!reportId) {
29-
return;
30-
}
31-
if (policy && shouldRestrictUserBillableActions(policy.id)) {
32-
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
33-
return;
34-
}
35-
startMoneyRequest(CONST.IOU.TYPE.SUBMIT, reportId);
36-
},
37-
},
38-
{
39-
value: CONST.REPORT.ADD_EXPENSE_OPTIONS.ADD_UNREPORTED_EXPENSE,
40-
text: translate('iou.addUnreportedExpense'),
41-
icon: Expensicons.ReceiptPlus,
42-
onSelected: () => {
43-
if (policy && shouldRestrictUserBillableActions(policy.id)) {
44-
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
45-
return;
46-
}
47-
openUnreportedExpense(reportId);
48-
},
49-
},
50-
];
51-
5215
return (
5316
<View style={styles.flex1}>
5417
<EmptyStateComponent
@@ -62,7 +25,6 @@ function SearchMoneyRequestReportEmptyState({reportId, policy}: {reportId?: stri
6225
lottieWebViewStyles={styles.emptyStateFolderWebStyles}
6326
headerContentStyles={styles.emptyStateFolderWebStyles}
6427
minModalHeight={minModalHeight}
65-
buttons={[{buttonText: translate('iou.addExpense'), buttonAction: () => {}, success: true, isDisabled: false, dropDownOptions: addExpenseDropdownOptions}]}
6628
/>
6729
</View>
6830
);

src/languages/de.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5983,8 +5983,7 @@ const translations = {
59835983
groupBy: 'Gruppe nach',
59845984
moneyRequestReport: {
59855985
emptyStateTitle: 'Dieser Bericht enthält keine Ausgaben.',
5986-
emptyStateSubtitle:
5987-
'Sie können diesem Bericht Ausgaben hinzufügen,\n indem Sie auf die Schaltfläche unten klicken oder die Option „Ausgabe hinzufügen“ im Menü „Mehr“ oben verwenden.',
5986+
emptyStateSubtitle: 'Sie können Ausgaben zu diesem Bericht hinzufügen, indem Sie die Schaltfläche oben verwenden.',
59885987
},
59895988
noCategory: 'Keine Kategorie',
59905989
noTag: 'Kein Tag',

src/languages/en.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5954,7 +5954,7 @@ const translations = {
59545954
groupBy: 'Group by',
59555955
moneyRequestReport: {
59565956
emptyStateTitle: 'This report has no expenses.',
5957-
emptyStateSubtitle: 'You can add expenses to this report \n using the button below or the "Add expense" option in the More menu above.',
5957+
emptyStateSubtitle: 'You can add expenses to this report \n using the button above.',
59585958
},
59595959
noCategory: 'No category',
59605960
noTag: 'No tag',

src/languages/es.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5976,7 +5976,7 @@ const translations = {
59765976
groupBy: 'Agrupar por',
59775977
moneyRequestReport: {
59785978
emptyStateTitle: 'Este informe no tiene gastos.',
5979-
emptyStateSubtitle: 'Puedes agregar gastos a este informe\n usando el botón de abajo o la opción "Agregar gasto" en el menú Más de arriba.',
5979+
emptyStateSubtitle: 'Puedes añadir gastos a este informe usando el botón de arriba.',
59805980
},
59815981
noCategory: 'Sin categoría',
59825982
noTag: 'Sin etiqueta',

0 commit comments

Comments
 (0)