Skip to content

Commit f8803d3

Browse files
committed
move search router permission to Permissions.ts
1 parent c19c62d commit f8803d3

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

src/components/Search/SearchRouter/SearchButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import * as Expensicons from '@components/Icon/Expensicons';
44
import {PressableWithoutFeedback} from '@components/Pressable';
55
import useTheme from '@hooks/useTheme';
66
import useThemeStyles from '@hooks/useThemeStyles';
7-
import * as SearchUtils from '@libs/SearchUtils';
7+
import Permissions from '@libs/Permissions';
88
import {useSearchRouterContext} from './SearchRouterContext';
99

1010
function SearchButton() {
1111
const styles = useThemeStyles();
1212
const theme = useTheme();
1313
const {toggleSearchRouter} = useSearchRouterContext();
1414

15-
if (!SearchUtils.shouldDisplayNewSearchRouter()) {
15+
if (!Permissions.canUseNewSearchRouter()) {
1616
return;
1717
}
1818

src/libs/Permissions.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type {OnyxEntry} from 'react-native-onyx';
22
import CONST from '@src/CONST';
33
import type {IOUType} from '@src/CONST';
44
import type Beta from '@src/types/onyx/Beta';
5+
import * as Environment from './Environment/Environment';
56

67
function canUseAllBetas(betas: OnyxEntry<Beta[]>): boolean {
78
return !!betas?.includes(CONST.BETAS.ALL);
@@ -49,6 +50,17 @@ function canUseCombinedTrackSubmit(betas: OnyxEntry<Beta[]>): boolean {
4950
return !!betas?.includes(CONST.BETAS.COMBINED_TRACK_SUBMIT);
5051
}
5152

53+
/**
54+
* New Search Router is under construction and for now should be displayed only in dev to allow developers to work on it.
55+
* We are not using BETA for this feature, as betas are heavier to cleanup,
56+
* and the development of new router is expected to take 2-3 weeks at most
57+
*
58+
* After everything is implemented this function can be removed, as we will always use SearchRouter in the App.
59+
*/
60+
function canUseNewSearchRouter() {
61+
return Environment.isDevelopment();
62+
}
63+
5264
/**
5365
* Link previews are temporarily disabled.
5466
*/
@@ -68,4 +80,5 @@ export default {
6880
canUseNewDotCopilot,
6981
canUseWorkspaceRules,
7082
canUseCombinedTrackSubmit,
83+
canUseNewSearchRouter,
7184
};

src/libs/SearchUtils.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import ChatListItem from '@components/SelectionList/ChatListItem';
44
import ReportListItem from '@components/SelectionList/Search/ReportListItem';
55
import TransactionListItem from '@components/SelectionList/Search/TransactionListItem';
66
import type {ListItem, ReportActionListItemType, ReportListItemType, TransactionListItemType} from '@components/SelectionList/types';
7-
import * as Environment from '@libs/Environment/Environment';
87
import CONST from '@src/CONST';
98
import type {TranslationPaths} from '@src/languages/types';
109
import ONYXKEYS from '@src/ONYXKEYS';
@@ -693,15 +692,6 @@ function isCannedSearchQuery(queryJSON: SearchQueryJSON) {
693692
return !queryJSON.filters;
694693
}
695694

696-
/**
697-
* New Search Router is under construction and for now should be displayed only in dev.
698-
*
699-
* After everything is implemented this function can be removed, as we will start to always use SearchRouter.
700-
*/
701-
function shouldDisplayNewSearchRouter() {
702-
return Environment.isDevelopment();
703-
}
704-
705695
export {
706696
buildQueryStringFromFilters,
707697
buildSearchQueryJSON,
@@ -725,5 +715,4 @@ export {
725715
getExpenseTypeTranslationKey,
726716
getChatFiltersTranslationKey,
727717
getChatStatusTranslationKey,
728-
shouldDisplayNewSearchRouter,
729718
};

0 commit comments

Comments
 (0)