Skip to content

Commit 362ff55

Browse files
mountinyOSBotify
authored andcommitted
Merge pull request #61903 from software-mansion-labs/feature/kuba-nowakowski/transaction-component-in-search
[CP Staging] Fix action buttons in search row (cherry picked from commit dd867c3) (cherry-picked to staging by francoisl)
1 parent fc6f1d0 commit 362ff55

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

src/components/SelectionList/Search/ActionCell.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function ActionCell({
7474
);
7575
}
7676

77-
if (action === CONST.SEARCH.ACTION_TYPES.VIEW || action === CONST.SEARCH.ACTION_TYPES.REVIEW || shouldUseViewAction || (action === CONST.SEARCH.ACTION_TYPES.DONE && isChildListItem)) {
77+
if (action === CONST.SEARCH.ACTION_TYPES.VIEW || action === CONST.SEARCH.ACTION_TYPES.REVIEW || shouldUseViewAction || isChildListItem) {
7878
const buttonInnerStyles = isSelected ? styles.buttonDefaultSelected : {};
7979

8080
return isLargeScreenWidth ? (

src/components/SelectionList/Search/ReportListItemHeader.tsx

+29-2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ type FirstRowReportHeaderProps<TItem extends ListItem> = {
5858

5959
/** Whether selecting multiple transactions at once is allowed */
6060
canSelectMultiple: boolean | undefined;
61+
62+
/** Callback passed as goToItem in actionCell, triggered by clicking actionButton */
63+
handleOnButtonPress?: () => void;
64+
65+
/** Whether the action button should be displayed */
66+
shouldShowAction?: boolean;
6167
};
6268

6369
type ReportCellProps = {
@@ -84,7 +90,16 @@ function TotalCell({showTooltip, isLargeScreenWidth, reportItem}: ReportCellProp
8490
);
8591
}
8692

87-
function FirstHeaderRow<TItem extends ListItem>({policy, report: moneyRequestReport, item, onCheckboxPress, isDisabled, canSelectMultiple}: FirstRowReportHeaderProps<TItem>) {
93+
function FirstHeaderRow<TItem extends ListItem>({
94+
policy,
95+
report: moneyRequestReport,
96+
item,
97+
onCheckboxPress,
98+
isDisabled,
99+
canSelectMultiple,
100+
handleOnButtonPress = () => {},
101+
shouldShowAction = false,
102+
}: FirstRowReportHeaderProps<TItem>) {
88103
const styles = useThemeStyles();
89104
const StyleUtils = useStyleUtils();
90105
const reportItem = item as unknown as ReportListItemType;
@@ -112,13 +127,23 @@ function FirstHeaderRow<TItem extends ListItem>({policy, report: moneyRequestRep
112127
/>
113128
</View>
114129
</View>
115-
<View style={[styles.justifyContentEnd, styles.flexShrink0]}>
130+
<View style={[styles.flexShrink0, styles.mr3]}>
116131
<TotalCell
117132
showTooltip
118133
isLargeScreenWidth={false}
119134
reportItem={reportItem}
120135
/>
121136
</View>
137+
{shouldShowAction && (
138+
<View style={[StyleUtils.getReportTableColumnStyles(CONST.SEARCH.TABLE_COLUMNS.ACTION)]}>
139+
<ActionCell
140+
action={reportItem.action}
141+
goToItem={handleOnButtonPress}
142+
isSelected={item.isSelected}
143+
isLoading={reportItem.isActionLoading}
144+
/>
145+
</View>
146+
)}
122147
</View>
123148
);
124149
}
@@ -185,6 +210,8 @@ function ReportListItemHeader<TItem extends ListItem>({
185210
onCheckboxPress={onCheckboxPress}
186211
isDisabled={isDisabled}
187212
canSelectMultiple={canSelectMultiple}
213+
shouldShowAction
214+
handleOnButtonPress={handleOnButtonPress}
188215
/>
189216
<View style={[styles.mr3, styles.ml3, styles.pv2]}>
190217
<View style={[styles.borderBottom]} />

0 commit comments

Comments
 (0)