Skip to content
Open
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
3 changes: 0 additions & 3 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9294,11 +9294,8 @@ const CONST = {
FILTER_POPUP_APPLY_MULTI_SELECT: 'Search-FilterPopupApplyMultiSelect',
FILTER_POPUP_RESET_TEXT_INPUT: 'Search-FilterPopupResetTextInput',
FILTER_POPUP_APPLY_TEXT_INPUT: 'Search-FilterPopupApplyTextInput',
FILTER_POPUP_RESET_AMOUNT: 'Search-FilterPopupResetAmount',
FILTER_POPUP_APPLY_AMOUNT: 'Search-FilterPopupApplyAmount',
FILTER_POPUP_RESET_DATE: 'Search-FilterPopupResetDate',
FILTER_POPUP_APPLY_DATE: 'Search-FilterPopupApplyDate',
FILTER_POPUP_RESET_REPORT_FIELD: 'Search-FilterPopupResetReportField',
FILTER_POPUP_APPLY_REPORT_FIELD: 'Search-FilterPopupApplyReportField',
TRANSACTION_LIST_ITEM_CHECKBOX: 'Search-TransactionListItemCheckbox',
EXPANDED_TRANSACTION_ROW: 'Search-ExpandedTransactionRow',
Expand Down
34 changes: 1 addition & 33 deletions src/components/Search/FilterComponents/ReportField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {ReportFieldDateKey, ReportFieldTextKey} from '@components/Search/ty
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useThemeStyles from '@hooks/useThemeStyles';
import {getDateModifierTitle, isSearchDatePreset} from '@libs/SearchQueryUtils';
import {getDateModifierTitle} from '@libs/SearchQueryUtils';
import {getDateDisplayValue, getDatePresets} from '@libs/SearchUIUtils';
import type {SearchDateModifier} from '@libs/SearchUIUtils';
import CONST from '@src/CONST';
Expand All @@ -28,7 +28,6 @@ type ReportFieldHandle = {
getEmptyValue: () => ReportFieldValues;
isDateModifierSelected: () => boolean;
applySelectedFieldAndGoBack: () => ReportFieldValues | void;
resetSelectedFieldAndGoBack: () => void;
};

type ReportFieldBaseProps = {
Expand Down Expand Up @@ -81,7 +80,6 @@ function SelectedReportField({ref, field, value: initialValue}: SelectedReportFi
},
isDateModifierSelected: () => false,
applySelectedFieldAndGoBack: () => {},
resetSelectedFieldAndGoBack: () => {},
}));

return (
Expand Down Expand Up @@ -131,22 +129,6 @@ function SelectedDateReportField({ref, field, value: initialValue, selectedDateM
dateFilterRef.current?.save();
onDateModifierSelected(null);
},
resetSelectedFieldAndGoBack: () => {
if (selectedDateModifier === CONST.SEARCH.DATE_MODIFIERS.RANGE) {
setValue((prevValue) => ({...prevValue, [CONST.SEARCH.DATE_MODIFIERS.RANGE]: undefined}));
} else {
const onValue = value[CONST.SEARCH.DATE_MODIFIERS.ON];
const isPreset = isSearchDatePreset(onValue);
setValue((prevValue) => ({
...prevValue,
[CONST.SEARCH.DATE_MODIFIERS.ON]: isPreset ? onValue : undefined,
[CONST.SEARCH.DATE_MODIFIERS.BEFORE]: undefined,
[CONST.SEARCH.DATE_MODIFIERS.AFTER]: undefined,
}));
}

onDateModifierSelected(null);
},
}));

return (
Expand Down Expand Up @@ -238,20 +220,6 @@ function ReportFieldBase({ref, values: initialValues = {}, selectedField, onFiel
onFieldSelected(null);
return selectedValue;
},
resetSelectedFieldAndGoBack: () => {
if (!selectedFieldRef.current || !selectedField) {
return;
}

if (selectedFieldRef.current.isDateModifierSelected()) {
selectedFieldRef.current.resetSelectedFieldAndGoBack();
return;
}

const selectedEmptyValue = selectedFieldRef.current.getEmptyValue();
setValues((prevValues) => ({...prevValues, ...selectedEmptyValue}));
onFieldSelected(null);
},
isDateModifierSelected: () => !!selectedFieldRef.current?.isDateModifierSelected(),
}));

Expand Down
18 changes: 10 additions & 8 deletions src/components/Search/FilterDropdowns/ActionButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type ActionButtonsProps = {
containerStyle: React.ComponentProps<typeof View>['style'];
resetSentryLabel?: string;
applySentryLabel?: string;
onReset: () => void;
onReset?: () => void;
onApply: () => void;
};

Expand All @@ -18,13 +18,15 @@ function ActionButtons({containerStyle, resetSentryLabel, applySentryLabel, onRe

return (
<View style={containerStyle}>
<Button
medium
style={[styles.flex1]}
text={translate('common.reset')}
onPress={onReset}
sentryLabel={resetSentryLabel}
/>
{!!onReset && (
<Button
medium
style={[styles.flex1]}
text={translate('common.reset')}
onPress={onReset}
sentryLabel={resetSentryLabel}
/>
)}
<Button
success
medium
Expand Down
12 changes: 0 additions & 12 deletions src/components/Search/FilterDropdowns/AmountPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ function AmountInput({title, value, name, onSave, onBackButtonPress}: AmountInpu
return (
<BasePopup
label={title}
onReset={() => onSave('')}
onApply={() => onSave(amount)}
resetSentryLabel={CONST.SENTRY_LABEL.SEARCH.FILTER_POPUP_RESET_AMOUNT}
applySentryLabel={CONST.SENTRY_LABEL.SEARCH.FILTER_POPUP_APPLY_AMOUNT}
onBackButtonPress={onBackButtonPress}
>
Expand Down Expand Up @@ -120,20 +118,10 @@ function AmountPopup({filterKey, label, value, closeOverlay, updateFilterForm}:

const applyChanges = () => onChange(amountValues);

const resetChanges = () => {
onChange({
[CONST.SEARCH.AMOUNT_MODIFIERS.EQUAL_TO]: undefined,
[CONST.SEARCH.AMOUNT_MODIFIERS.GREATER_THAN]: undefined,
[CONST.SEARCH.AMOUNT_MODIFIERS.LESS_THAN]: undefined,
});
};

return (
<BasePopup
label={label}
onReset={resetChanges}
onApply={applyChanges}
resetSentryLabel={CONST.SENTRY_LABEL.SEARCH.FILTER_POPUP_RESET_AMOUNT}
applySentryLabel={CONST.SENTRY_LABEL.SEARCH.FILTER_POPUP_APPLY_AMOUNT}
>
{modifierConfig.map((modifier) => (
Expand Down
4 changes: 2 additions & 2 deletions src/components/Search/FilterDropdowns/BasePopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import ActionButtons from './ActionButtons';
type BasePopupProps = React.PropsWithChildren & {
label?: string;
applySentryLabel: string;
resetSentryLabel: string;
resetSentryLabel?: string;
style?: StyleProp<ViewStyle>;
onApply: () => void;
onReset: () => void;
onReset?: () => void;
onBackButtonPress?: () => void;
};

Expand Down
7 changes: 0 additions & 7 deletions src/components/Search/FilterDropdowns/CommonPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,11 @@ function CommonPopup({filterKey, value: initialValue, label, policyIDQuery, upda
closeOverlay();
};

const resetChanges = () => {
updateFilterForm({[filterKey]: undefined});
closeOverlay();
};

return (
<BasePopup
label={label}
onApply={applyChanges}
onReset={resetChanges}
applySentryLabel={`Search-FilterPopupApply-${filterKey}`}
resetSentryLabel={`Search-FilterPopupReset-${filterKey}`}
>
<FilterComponents
filterKey={filterKey}
Expand Down
24 changes: 0 additions & 24 deletions src/components/Search/FilterDropdowns/DateSelectPopup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,27 +109,6 @@ function DateSelectPopup({label, value, presets, style, closeOverlay, onChange,
closeOverlay();
}, [closeOverlay, onChange, selectedDateModifier]);

const resetChanges = useCallback(() => {
if (!searchDatePresetFilterBaseRef.current) {
return;
}

if (selectedDateModifier) {
searchDatePresetFilterBaseRef.current.clearDateValueOfSelectedDateModifier();
const dateValues = searchDatePresetFilterBaseRef.current.getDateValues();
clearSelection();
onChange(dateValues);
closeOverlay();
return;
}

searchDatePresetFilterBaseRef.current.clearDateValues();
setRangeText('');
setShouldShowRangeError(false);
onChange(searchDatePresetFilterBaseRef.current.getDateValues());
closeOverlay();
}, [clearSelection, closeOverlay, onChange, selectedDateModifier]);

const maxPopupHeight = Math.round(windowHeight * 0.875);

// For non-Range modes, use original simple styles. For Range, use custom layout
Expand Down Expand Up @@ -177,7 +156,6 @@ function DateSelectPopup({label, value, presets, style, closeOverlay, onChange,
<View style={[styles.flex1, useRangeLayout && styles.ml2]}>
<ActionButtons
containerStyle={[styles.flexRow, styles.gap2]}
onReset={resetChanges}
onApply={applyChanges}
/>
</View>
Expand Down Expand Up @@ -232,9 +210,7 @@ function DateSelectPopup({label, value, presets, style, closeOverlay, onChange,
)}
<ActionButtons
containerStyle={mobileButtonRowStyle}
resetSentryLabel={CONST.SENTRY_LABEL.SEARCH.FILTER_POPUP_RESET_DATE}
applySentryLabel={CONST.SENTRY_LABEL.SEARCH.FILTER_POPUP_APPLY_DATE}
onReset={resetChanges}
onApply={applyChanges}
/>
</View>
Expand Down
16 changes: 0 additions & 16 deletions src/components/Search/FilterDropdowns/ReportFieldPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,10 @@ function ReportFieldPopup({values, closeOverlay, updateFilterForm}: ReportFieldP
closeOverlay();
};

const resetChanges = () => {
if (!reportFieldRef.current) {
return;
}

if (selectedField) {
reportFieldRef.current.resetSelectedFieldAndGoBack();
return;
}

updateFilterForm(reportFieldRef.current.getEmptyValue());
closeOverlay();
};

return (
<BasePopup
label={selectedField ? undefined : translate('workspace.common.reportField')}
onReset={resetChanges}
onApply={applyChanges}
resetSentryLabel={CONST.SENTRY_LABEL.SEARCH.FILTER_POPUP_RESET_REPORT_FIELD}
applySentryLabel={CONST.SENTRY_LABEL.SEARCH.FILTER_POPUP_APPLY_REPORT_FIELD}
style={[styles.getPopoverMaxHeight(windowHeight, isInLandscapeMode)]}
>
Expand Down
Loading