Skip to content

Commit

Permalink
move search router permission to Permissions.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Kicu committed Sep 10, 2024
1 parent c19c62d commit f8803d3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/components/Search/SearchRouter/SearchButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import * as Expensicons from '@components/Icon/Expensicons';
import {PressableWithoutFeedback} from '@components/Pressable';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import * as SearchUtils from '@libs/SearchUtils';
import Permissions from '@libs/Permissions';
import {useSearchRouterContext} from './SearchRouterContext';

function SearchButton() {
const styles = useThemeStyles();
const theme = useTheme();
const {toggleSearchRouter} = useSearchRouterContext();

if (!SearchUtils.shouldDisplayNewSearchRouter()) {
if (!Permissions.canUseNewSearchRouter()) {
return;
}

Expand Down
13 changes: 13 additions & 0 deletions src/libs/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {OnyxEntry} from 'react-native-onyx';
import CONST from '@src/CONST';
import type {IOUType} from '@src/CONST';
import type Beta from '@src/types/onyx/Beta';
import * as Environment from './Environment/Environment';

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

/**
* New Search Router is under construction and for now should be displayed only in dev to allow developers to work on it.
* We are not using BETA for this feature, as betas are heavier to cleanup,
* and the development of new router is expected to take 2-3 weeks at most
*
* After everything is implemented this function can be removed, as we will always use SearchRouter in the App.
*/
function canUseNewSearchRouter() {
return Environment.isDevelopment();
}

/**
* Link previews are temporarily disabled.
*/
Expand All @@ -68,4 +80,5 @@ export default {
canUseNewDotCopilot,
canUseWorkspaceRules,
canUseCombinedTrackSubmit,
canUseNewSearchRouter,
};
11 changes: 0 additions & 11 deletions src/libs/SearchUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import ChatListItem from '@components/SelectionList/ChatListItem';
import ReportListItem from '@components/SelectionList/Search/ReportListItem';
import TransactionListItem from '@components/SelectionList/Search/TransactionListItem';
import type {ListItem, ReportActionListItemType, ReportListItemType, TransactionListItemType} from '@components/SelectionList/types';
import * as Environment from '@libs/Environment/Environment';
import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -693,15 +692,6 @@ function isCannedSearchQuery(queryJSON: SearchQueryJSON) {
return !queryJSON.filters;
}

/**
* New Search Router is under construction and for now should be displayed only in dev.
*
* After everything is implemented this function can be removed, as we will start to always use SearchRouter.
*/
function shouldDisplayNewSearchRouter() {
return Environment.isDevelopment();
}

export {
buildQueryStringFromFilters,
buildSearchQueryJSON,
Expand All @@ -725,5 +715,4 @@ export {
getExpenseTypeTranslationKey,
getChatFiltersTranslationKey,
getChatStatusTranslationKey,
shouldDisplayNewSearchRouter,
};

0 comments on commit f8803d3

Please sign in to comment.