-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[Preparing the UI] [No QA] Revamp search page actions bar #85508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bernhardoj
wants to merge
49
commits into
Expensify:main
Choose a base branch
from
bernhardoj:feat/81558-revamp-search-actions-bar
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,264
−105
Open
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
55b608d
revamp search page actions bar
bernhardoj 8ffd9da
add other translations
bernhardoj 58e2fed
lint
bernhardoj 1154d89
lint
bernhardoj 65d7690
fix wrong hooks being used
bernhardoj 3e2eefd
fix extra spaces and label
bernhardoj 3f42ae1
fix search name is saved as empty string
bernhardoj 83f189d
don't include unfound card
bernhardoj a7aa479
make it optional
bernhardoj afca3f7
fix test
bernhardoj 3b92af9
remove IIFE pattern
bernhardoj ef3265d
create a map lookup to optimize
bernhardoj 44e8d17
prettier
bernhardoj 2b80b34
drying
bernhardoj 51784c7
remove unnecessary props
bernhardoj c729b9d
remove unused var
bernhardoj b379b42
simplify
bernhardoj 1805dc0
Merge branch 'main' into feat/81558-revamp-search-actions-bar
bernhardoj b3f658a
replace for indexed with for..of
bernhardoj 48ed825
return as string
bernhardoj e23fa58
prettier
bernhardoj 0460060
move sortbypopup to a separate file
bernhardoj b57ce18
lint
bernhardoj fb26bfe
Merge branch 'main' into feat/81558-revamp-search-actions-bar
bernhardoj 4ce7b25
fixed popover position
bernhardoj 9ed7bab
Merge branch 'main' into feat/81558-revamp-search-actions-bar
bernhardoj 8daac00
remove log
bernhardoj 89125e0
remove unused var
bernhardoj 359db31
only render the revamped search actions bar if it's on staging/dev
bernhardoj f332aa3
don't show the new component yet
bernhardoj d55abd9
remove unused import
bernhardoj 0d3b6ae
fix test
bernhardoj 0e07500
fix missing style
bernhardoj a3dc7db
update test
bernhardoj 7aaf5eb
remove unused prop
bernhardoj 5700da2
remove unused prop
bernhardoj 060b191
fix wrong name
bernhardoj abaec93
make the name consistent
bernhardoj 754b10b
add sentry label
bernhardoj a91a01a
refactor to use formprovider and make it autofocus
bernhardoj bedfb8a
show groupby for trip too
bernhardoj e85edf4
extract same login into hook
bernhardoj ee777a6
readd the extra padding
bernhardoj 7d3d018
remove search save page for now
bernhardoj 92b3baa
don't dismiss modal on narrow layout
bernhardoj 3dba7ce
Merge branch 'main' into feat/81558-revamp-search-actions-bar
bernhardoj 1efadbf
fix onyxkeys typing
bernhardoj 3c07540
lint
bernhardoj dcbb745
fix error after merging main
bernhardoj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,205 @@ | ||
| import React, {useState} from 'react'; | ||
| import {View} from 'react-native'; | ||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
| import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
| import MenuItem from '@components/MenuItem'; | ||
| import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; | ||
| import type {SearchQueryJSON} from '@components/Search/types'; | ||
| import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import {close} from '@libs/actions/Modal'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
| import {buildFilterQueryWithSortDefaults} from '@libs/SearchQueryUtils'; | ||
| import {getGroupBySections, getSearchColumnTranslationKey, getViewOptions} from '@libs/SearchUIUtils'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import ROUTES from '@src/ROUTES'; | ||
| import type {SearchAdvancedFiltersForm} from '@src/types/form'; | ||
| import type {SearchResults} from '@src/types/onyx'; | ||
| import {getEmptyObject} from '@src/types/utils/EmptyObject'; | ||
| import GroupByPopup from './GroupByPopup'; | ||
| import SingleSelectPopup from './SingleSelectPopup'; | ||
| import SortByPopup from './SortByPopup'; | ||
| import TextInputPopup from './TextInputPopup'; | ||
|
|
||
| type DisplayPopupProps = { | ||
| queryJSON: SearchQueryJSON; | ||
| searchResults: OnyxEntry<SearchResults>; | ||
| closeOverlay: () => void; | ||
| onSort: () => void; | ||
| }; | ||
|
|
||
| function DisplayPopup({queryJSON, searchResults, closeOverlay, onSort}: DisplayPopupProps) { | ||
| const {translate} = useLocalize(); | ||
| const styles = useThemeStyles(); | ||
| const {shouldUseNarrowLayout, isLargeScreenWidth} = useResponsiveLayout(); | ||
| const expensifyIcons = useMemoizedLazyExpensifyIcons(['Columns']); | ||
| const [searchAdvancedFilters = getEmptyObject<SearchAdvancedFiltersForm>()] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM); | ||
| const [selectedDisplayFilter, setSelectedDisplayFilter] = useState< | ||
| | typeof CONST.SEARCH.SYNTAX_ROOT_KEYS.LIMIT | ||
| | typeof CONST.SEARCH.SYNTAX_ROOT_KEYS.GROUP_BY | ||
| | typeof CONST.SEARCH.SYNTAX_ROOT_KEYS.VIEW | ||
| | typeof CONST.SEARCH.SYNTAX_ROOT_KEYS.SORT_BY | ||
| | null | ||
| >(null); | ||
|
|
||
| const groupBySections = getGroupBySections(translate); | ||
| const groupBy = groupBySections.flatMap((section) => section.options).find((option) => option.value === queryJSON.groupBy) ?? null; | ||
| const viewOptions = getViewOptions(translate); | ||
| const view = viewOptions.find((option) => option.value === queryJSON.view) ?? viewOptions.at(0) ?? null; | ||
| const shouldShowColumnsButton = isLargeScreenWidth && (queryJSON.type === CONST.SEARCH.DATA_TYPES.EXPENSE || queryJSON.type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT); | ||
|
|
||
| const sortByValue = queryJSON.sortBy; | ||
| const groupByValue = searchAdvancedFilters[CONST.SEARCH.SYNTAX_ROOT_KEYS.GROUP_BY]; | ||
| const viewValue = searchAdvancedFilters[CONST.SEARCH.SYNTAX_ROOT_KEYS.VIEW]; | ||
| const limitValue = searchAdvancedFilters[CONST.SEARCH.SYNTAX_ROOT_KEYS.LIMIT]; | ||
|
|
||
| if (!selectedDisplayFilter) { | ||
| const openSearchColumns = () => { | ||
| Navigation.navigate(ROUTES.SEARCH_COLUMNS); | ||
| }; | ||
|
|
||
| const isExpenseType = queryJSON.type === CONST.SEARCH.DATA_TYPES.EXPENSE; | ||
| const isTripType = queryJSON.type === CONST.SEARCH.DATA_TYPES.TRIP; | ||
| return ( | ||
| <View style={[!shouldUseNarrowLayout && styles.pv4]}> | ||
| <MenuItemWithTopDescription | ||
| shouldShowRightIcon | ||
| description={translate('search.display.sortBy')} | ||
| title={translate(getSearchColumnTranslationKey(sortByValue))} | ||
| onPress={() => setSelectedDisplayFilter(CONST.SEARCH.SYNTAX_ROOT_KEYS.SORT_BY)} | ||
| /> | ||
| {(isExpenseType || isTripType) && ( | ||
| <MenuItemWithTopDescription | ||
| shouldShowRightIcon | ||
| description={translate('search.display.groupBy')} | ||
| title={groupByValue ? translate(`search.filters.groupBy.${groupByValue}`) : undefined} | ||
| onPress={() => setSelectedDisplayFilter(CONST.SEARCH.SYNTAX_ROOT_KEYS.GROUP_BY)} | ||
| /> | ||
| )} | ||
| {isExpenseType && !!groupByValue && ( | ||
| <MenuItemWithTopDescription | ||
| shouldShowRightIcon | ||
| description={translate('search.view.label')} | ||
| title={viewValue ? translate(`search.view.${viewValue}`) : undefined} | ||
| onPress={() => setSelectedDisplayFilter(CONST.SEARCH.SYNTAX_ROOT_KEYS.VIEW)} | ||
| /> | ||
| )} | ||
| {isExpenseType && ( | ||
| <MenuItemWithTopDescription | ||
| shouldShowRightIcon | ||
| description={translate('search.display.limitResults')} | ||
| title={limitValue} | ||
| onPress={() => setSelectedDisplayFilter(CONST.SEARCH.SYNTAX_ROOT_KEYS.LIMIT)} | ||
| /> | ||
| )} | ||
| {shouldShowColumnsButton && ( | ||
| <MenuItem | ||
| icon={expensifyIcons.Columns} | ||
| title={translate('search.editColumns')} | ||
| onPress={() => { | ||
| closeOverlay(); | ||
| openSearchColumns(); | ||
| }} | ||
| sentryLabel={CONST.SENTRY_LABEL.SEARCH.COLUMNS_BUTTON} | ||
| /> | ||
| )} | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| const updateFilterForm = (values: Partial<SearchAdvancedFiltersForm>) => { | ||
| const updatedFilterFormValues: Partial<SearchAdvancedFiltersForm> = { | ||
| ...searchAdvancedFilters, | ||
| ...values, | ||
| }; | ||
|
|
||
| if (updatedFilterFormValues.groupBy !== searchAdvancedFilters.groupBy) { | ||
| updatedFilterFormValues.columns = []; | ||
| } | ||
|
|
||
| const queryString = | ||
| buildFilterQueryWithSortDefaults( | ||
| updatedFilterFormValues, | ||
| {view: searchAdvancedFilters.view, groupBy: searchAdvancedFilters.groupBy}, | ||
| {sortBy: queryJSON.sortBy, sortOrder: queryJSON.sortOrder, limit: queryJSON.limit}, | ||
| ) ?? ''; | ||
| if (!queryString) { | ||
| return; | ||
| } | ||
|
|
||
| close(() => Navigation.setParams({q: queryString, rawQuery: undefined})); | ||
| }; | ||
|
|
||
| const subtitle = { | ||
| [CONST.SEARCH.SYNTAX_ROOT_KEYS.SORT_BY]: translate('search.display.sortBy'), | ||
| [CONST.SEARCH.SYNTAX_ROOT_KEYS.GROUP_BY]: translate('search.display.groupBy'), | ||
| [CONST.SEARCH.SYNTAX_ROOT_KEYS.VIEW]: translate('search.view.label'), | ||
| [CONST.SEARCH.SYNTAX_ROOT_KEYS.LIMIT]: translate('search.display.limitResults'), | ||
| }; | ||
|
|
||
| const subPopup = { | ||
| [CONST.SEARCH.SYNTAX_ROOT_KEYS.SORT_BY]: ( | ||
| <SortByPopup | ||
| searchResults={searchResults} | ||
| queryJSON={queryJSON} | ||
| groupBy={groupBy} | ||
| onSort={onSort} | ||
| closeOverlay={() => setSelectedDisplayFilter(null)} | ||
| /> | ||
| ), | ||
| [CONST.SEARCH.SYNTAX_ROOT_KEYS.GROUP_BY]: ( | ||
| <GroupByPopup | ||
| style={styles.p0} | ||
| label={shouldUseNarrowLayout ? undefined : translate('search.display.groupBy')} | ||
| sections={groupBySections} | ||
| value={groupBy} | ||
| closeOverlay={() => setSelectedDisplayFilter(null)} | ||
| onChange={(item) => { | ||
| const newValue = item?.value; | ||
| if (!newValue) { | ||
| updateFilterForm({groupBy: undefined, groupCurrency: undefined}); | ||
| } else { | ||
| updateFilterForm({groupBy: newValue}); | ||
| } | ||
| }} | ||
| /> | ||
| ), | ||
| [CONST.SEARCH.SYNTAX_ROOT_KEYS.VIEW]: ( | ||
| <SingleSelectPopup | ||
| style={styles.p0} | ||
| label={shouldUseNarrowLayout ? undefined : translate('search.view.label')} | ||
| items={viewOptions} | ||
| value={view} | ||
| closeOverlay={() => setSelectedDisplayFilter(null)} | ||
| onChange={(item) => updateFilterForm({view: item?.value ?? CONST.SEARCH.VIEW.TABLE})} | ||
| /> | ||
| ), | ||
| [CONST.SEARCH.SYNTAX_ROOT_KEYS.LIMIT]: ( | ||
| <TextInputPopup | ||
| style={styles.pv0} | ||
| placeholder={translate('search.filters.limit')} | ||
| defaultValue={limitValue} | ||
| closeOverlay={() => setSelectedDisplayFilter(null)} | ||
| onChange={(value) => updateFilterForm({limit: value})} | ||
| /> | ||
| ), | ||
| }; | ||
|
|
||
| return ( | ||
| <View style={[!shouldUseNarrowLayout && styles.pv4]}> | ||
| <HeaderWithBackButton | ||
| shouldDisplayHelpButton={false} | ||
| style={[styles.h10]} | ||
| subtitle={subtitle[selectedDisplayFilter]} | ||
| onBackButtonPress={() => setSelectedDisplayFilter(null)} | ||
| /> | ||
| {subPopup[selectedDisplayFilter]} | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| export default DisplayPopup; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.