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
1 change: 0 additions & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2080,7 +2080,6 @@ const ROUTES = {
getRoute: (id: string) => `search/saved-search/rename/${id}` as const,
},
SEARCH_COLUMNS: 'search/columns',
SEARCH_ADVANCED_FILTERS_DESCRIBE: 'search/filters/describe',
SEARCH_ADVANCED_FILTERS: 'search/filters',
SEARCH_ADVANCED_FILTERS_CONTENT: {
route: 'search/filters/:filterKey',
Expand Down
1 change: 0 additions & 1 deletion src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const SCREENS = {
COLUMNS_RHP: 'Search_Columns_RHP',
ADVANCED_FILTERS_RHP: 'Search_Advanced_Filters_RHP',
ADVANCED_FILTERS_CONTENT_RHP: 'Search_Advanced_Filters_Content_RHP',
ADVANCED_FILTERS_DESCRIBE_RHP: 'Search_Advanced_Filters_Describe_RHP',
SAVED_SEARCH_RENAME_RHP: 'Search_Saved_Search_Rename_RHP',
TRANSACTION_HOLD_REASON_RHP: 'Search_Transaction_Hold_Reason_RHP',
TRANSACTION_HOLD_REASON_SEARCH: 'Search_Transaction_Hold_Reason_Search',
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,34 +1,21 @@
import Icon from '@components/Icon';
import {PressableWithFeedback} from '@components/Pressable';
import SafeTriangle from '@components/SafeTriangle';
import FilterList from '@components/Search/FilterComponents/AdvancedFilters/FilterList';
import SearchAdvancedFiltersContent from '@components/Search/FilterComponents/AdvancedFilters/SearchAdvancedFiltersContent';
import SearchNLFilterContent from '@components/Search/FilterComponents/AdvancedFilters/SearchNLFilterContent';
import useUpdateFilterQuery from '@components/Search/hooks/useUpdateFilterQuery';
import type {SearchQueryJSON} from '@components/Search/types';
import SpacerView from '@components/SpacerView';
import Text from '@components/Text';

import {useDebounceWithControls} from '@hooks/useDebounce';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import usePointerMovement from '@hooks/usePointerMovement';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';

import getButtonState from '@libs/getButtonState';
import Navigation from '@libs/Navigation/Navigation';
import {hasFilterContentValuesChanged} from '@libs/SearchUIUtils';
import type {SearchFilter} from '@libs/SearchUIUtils';

import variables from '@styles/variables';

import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Route} from '@src/ROUTES';
import type {SearchAdvancedFiltersForm} from '@src/types/form';

import type {ComponentRef} from 'react';
Expand All @@ -43,11 +30,7 @@ import ReportFieldFilterContentPopupWrapper from './ReportFieldFilterContentPopu
import TextInputFilterContentPopupWrapper from './TextInputFilterContentPopupWrapper';

type SearchAdvancedFiltersPopupProps = {
/** Query JSON to build the current filter state */
queryJSON: SearchQueryJSON;

/** Closes the filters popover overlay */
closeOverlay: () => void;
};

/** Which filter contents are mounted and what each was given. */
Expand Down Expand Up @@ -123,13 +106,10 @@ function MountedFilterContent({filterKey, values, ready, onChange}: MountedFilte
);
}

function SearchAdvancedFiltersPopup({queryJSON, closeOverlay}: SearchAdvancedFiltersPopupProps) {
function SearchAdvancedFiltersPopup({queryJSON}: SearchAdvancedFiltersPopupProps) {
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const theme = useTheme();
const {translate} = useLocalize();
const {windowHeight} = useWindowDimensions();
const [isDescribeMode, setIsDescribeMode] = useState(false);
const [searchAdvancedFiltersForm] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM);
const filterContentRef = useRef<ComponentRef<typeof View>>(null);
const [mountedFilterState, setMountedFilterState] = useState<MountedFilterState>(() => ({
Expand All @@ -142,7 +122,6 @@ function SearchAdvancedFiltersPopup({queryJSON, closeOverlay}: SearchAdvancedFil
}));
const {activeFilter, mountedFilters, formWhileHidden, contentVersions, readyFilters} = mountedFilterState;
const {updateFilterQueryParams} = useUpdateFilterQuery(queryJSON);
const icons = useMemoizedLazyExpensifyIcons(['Sparkles', 'ArrowRight']);

// Shows a filter's content. A visited one stays mounted, so a return reveals it rather than building it again.
const showFilter = (filterKey: SearchFilter['key']) => {
Expand Down Expand Up @@ -185,7 +164,6 @@ function SearchAdvancedFiltersPopup({queryJSON, closeOverlay}: SearchAdvancedFil
const {invoke: debouncedMarkShownFilterReady, cancel: cancelReadyWait} = useDebounceWithControls(markShownFilterReady, CONST.TIMING.SEARCH_FILTER_HOVER_INTENT_DELAY);

const hoverFilter = (filterKey: SearchFilter['key']) => {
setIsDescribeMode(false);
showFilter(filterKey);
debouncedMarkShownFilterReady();
};
Expand All @@ -207,97 +185,44 @@ function SearchAdvancedFiltersPopup({queryJSON, closeOverlay}: SearchAdvancedFil

// Moving the focus is deliberate and never passes over rows on the way, so nothing is withheld from it.
const focusFilter = (filterKey: SearchFilter['key']) => {
setIsDescribeMode(false);
cancelReadyWait();
showFilter(filterKey);
markShownFilterReady();
};

const mayDeriveContent = (filterKey: SearchFilter['key']) => !DEFERRED_CONTENT_FILTERS.has(filterKey) || readyFilters.includes(filterKey);

const getDescribeButtonBackground = (pressed: boolean) => {
if (pressed) {
return styles.buttonHoveredBG;
}
if (isDescribeMode) {
return styles.hoveredComponentBG;
}
return undefined;
};

const handleNLSuccess = (route: Route) => {
closeOverlay();
Navigation.navigate(route);
};

return (
<SafeTriangle submenuRef={filterContentRef}>
<View style={[styles.flexRow, StyleUtils.getHeight(Math.min(windowHeight, CONST.ADVANCED_FILTERS_POPOVER_HEIGHT))]}>
<View style={[styles.typeFiltersPopupContainer]}>
<PressableWithFeedback
style={({pressed}) => [styles.typeFilterMenu, getDescribeButtonBackground(pressed)]}
accessible
accessibilityLabel={translate('search.filters.describeSearch.title')}
role={CONST.ROLE.BUTTON}
sentryLabel="SearchAdvancedFiltersPopup-DescribeSearch"
onHoverIn={() => setIsDescribeMode(true)}
onFocus={() => setIsDescribeMode(true)}
onPress={() => setIsDescribeMode(true)}
>
{({pressed}) => (
<>
<Icon
src={icons.Sparkles}
fill={theme.icon}
width={variables.iconSizeSmall}
height={variables.iconSizeSmall}
/>
<Text style={[styles.flex1]}>{translate('search.filters.describeSearch.title')}</Text>
<Icon
src={icons.ArrowRight}
fill={StyleUtils.getIconFillColor({buttonState: getButtonState({isActive: isDescribeMode, isPressed: pressed})})}
width={variables.iconSizeNormal}
height={variables.iconSizeNormal}
/>
</>
)}
</PressableWithFeedback>
<SpacerView
shouldShow
style={[styles.reportHorizontalRule]}
/>
<FilterList
type={searchAdvancedFiltersForm?.type}
selectedFilter={isDescribeMode ? undefined : activeFilter}
onHoverIn={hoverFilter}
onPointerMove={trackPointerMovement}
onPointerLeave={stopTrackingPointer}
onFocus={focusFilter}
/>
</View>
<FilterList
style={[styles.typeFiltersPopupContainer]}
type={searchAdvancedFiltersForm?.type}
selectedFilter={activeFilter}
onHoverIn={hoverFilter}
onPointerMove={trackPointerMovement}
onPointerLeave={stopTrackingPointer}
onFocus={focusFilter}
/>
<View
ref={filterContentRef}
style={[styles.filterContentContainer]}
>
{isDescribeMode ? (
<SearchNLFilterContent onSuccess={handleNLSuccess} />
) : (
mountedFilters.map((filterKey) => (
// `Activity` keeps a hidden content mounted while taking it out of layout and unmounting its
// effects, so it holds no Onyx subscriptions until it is shown again.
<Activity
key={`${filterKey}-${contentVersions[filterKey] ?? 0}`}
mode={filterKey === activeFilter ? 'visible' : 'hidden'}
>
<MountedFilterContent
filterKey={filterKey}
values={filterKey === activeFilter ? searchAdvancedFiltersForm : formWhileHidden[filterKey]}
ready={mayDeriveContent(filterKey)}
onChange={updateFilterQueryParams}
/>
</Activity>
))
)}
{mountedFilters.map((filterKey) => (
// `Activity` keeps a hidden content mounted while taking it out of layout and unmounting its
// effects, so it holds no Onyx subscriptions until it is shown again.
<Activity
key={`${filterKey}-${contentVersions[filterKey] ?? 0}`}
mode={filterKey === activeFilter ? 'visible' : 'hidden'}
>
<MountedFilterContent
filterKey={filterKey}
values={filterKey === activeFilter ? searchAdvancedFiltersForm : formWhileHidden[filterKey]}
ready={mayDeriveContent(filterKey)}
onChange={updateFilterQueryParams}
/>
</Activity>
))}
</View>
</View>
</SafeTriangle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,7 @@ function SearchAdvancedFiltersButton({queryJSON}: SearchAdvancedFiltersButtonPro
</Button>
);

const filtersPopup = ({closeOverlay}: {closeOverlay: () => void}) => (
<SearchAdvancedFiltersPopup
queryJSON={queryJSON}
closeOverlay={closeOverlay}
/>
);
const filtersPopup = () => <SearchAdvancedFiltersPopup queryJSON={queryJSON} />;

return (
<FilterPopupButton
Expand Down
6 changes: 0 additions & 6 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9805,12 +9805,6 @@ Fügen Sie weitere Ausgabelimits hinzu, um den Cashflow Ihres Unternehmens zu sc
[CONST.SEARCH.ACTION_FILTERS.PAY]: 'Bezahlen',
[CONST.SEARCH.ACTION_FILTERS.EXPORT]: 'Export',
},
describeSearch: {
title: 'Beschreiben Sie Ihre Suche',
inputLabel: 'Ihre Suche',
description: 'Beschreiben Sie auf einfachem Englisch, wonach Sie suchen, zum Beispiel „meals over $50 last month”.',
buttonText: 'Anwenden',
},
filterType: {label: 'Filtertyp', has: {positive: 'hat', negative: 'hat nicht'}, is: {positive: 'ist', negative: 'ist nicht'}},
created: 'Erstellt',
createdDate: 'Erstellungsdatum',
Expand Down
6 changes: 0 additions & 6 deletions src/languages/el.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10009,12 +10009,6 @@ ${reportName}`,
[CONST.SEARCH.ACTION_FILTERS.EXPORT]: 'Εξαγωγή',
},
has: {submittedViolation: 'Υποβληθείσα παράβαση', approvedViolation: 'Εγκεκριμένη παράβαση'},
describeSearch: {
title: 'Περιγράψτε την αναζήτησή σας',
inputLabel: 'Η αναζήτησή σας',
description: 'Περιγράψτε με απλά αγγλικά τι αναζητάτε, όπως «γεύματα άνω των $50 τον περασμένο μήνα».',
buttonText: 'Εφαρμογή',
},
filterType: {
label: 'Τύπος φίλτρου',
has: {positive: 'έχει', negative: 'δεν έχει'},
Expand Down
6 changes: 0 additions & 6 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10003,12 +10003,6 @@ const translations = {
[CONST.SEARCH.ACTION_FILTERS.PAY]: 'Pay',
[CONST.SEARCH.ACTION_FILTERS.EXPORT]: 'Export',
},
describeSearch: {
title: 'Describe your search',
inputLabel: 'Your search',
description: 'Use plain English to describe what you\'re looking for, like "meals over $50 last month."',
buttonText: 'Apply',
},
filterType: {
label: 'Filter type',
has: {
Expand Down
Loading
Loading