Skip to content

Commit

Permalink
hide All Teams search behind FF
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienTant committed Dec 16, 2024
1 parent 199f9a9 commit 7507ceb
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 9 deletions.
9 changes: 6 additions & 3 deletions app/screens/home/search/bottom_sheet_team_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ type Props = {
teamId: string;
setTeamId: (teamId: string) => void;
title: string;
crossTeamSearchEnabled: boolean;
}

export default function BottomSheetTeamList({teams, title, setTeamId, teamId}: Props) {
export default function BottomSheetTeamList({teams, title, setTeamId, teamId, crossTeamSearchEnabled}: Props) {
const intl = useIntl();
const isTablet = useIsTablet();
const showTitle = !isTablet && Boolean(teams.length);
Expand All @@ -32,7 +33,9 @@ export default function BottomSheetTeamList({teams, title, setTeamId, teamId}: P

// teamList is a copy of teams to avoid modifying the original array
const teamList = [...teams];
teamList.unshift({id: ALL_TEAMS_ID, displayName: intl.formatMessage({id: 'mobile.search.team.all_teams', defaultMessage: 'All teams'})} as TeamModel);
if (crossTeamSearchEnabled) {
teamList.unshift({id: ALL_TEAMS_ID, displayName: intl.formatMessage({id: 'mobile.search.team.all_teams', defaultMessage: 'All teams'})} as TeamModel);
}

return (
<BottomSheetContent
Expand All @@ -48,7 +51,7 @@ export default function BottomSheetTeamList({teams, title, setTeamId, teamId}: P
testID='search.select_team_slide_up.team_list'
type={isTablet ? 'FlatList' : 'BottomSheetFlatList'}
hideIcon={true}
separatorAfterFirstItem={true}
separatorAfterFirstItem={crossTeamSearchEnabled}
/>
</BottomSheetContent>
);
Expand Down
3 changes: 2 additions & 1 deletion app/screens/home/search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import {withDatabase, withObservables} from '@nozbe/watermelondb/react';
import compose from 'lodash/fp/compose';

import {observeCurrentTeamId} from '@queries/servers/system';
import {observeConfigBooleanValue, observeCurrentTeamId} from '@queries/servers/system';
import {queryJoinedTeams} from '@queries/servers/team';

import SearchScreen from './search';
Expand All @@ -16,6 +16,7 @@ const enhance = withObservables([], ({database}: WithDatabaseArgs) => {
return {
teamId: currentTeamId,
teams: queryJoinedTeams(database).observe(),
crossTeamSearchEnabled: observeConfigBooleanValue(database, 'FeatureFlagExperimentalCrossTeamSearch'),
};
});

Expand Down
2 changes: 2 additions & 0 deletions app/screens/home/search/initial/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import compose from 'lodash/fp/compose';
import {of as of$} from 'rxjs';
import {switchMap, distinctUntilChanged} from 'rxjs/operators';

import {observeConfigBooleanValue} from '@queries/servers/system';
import {observeTeam, queryTeamSearchHistoryByTeamId} from '@queries/servers/team';

import Initial from './initial';
Expand All @@ -22,6 +23,7 @@ const enhance = withObservables(['teamId'], ({database, teamId}: EnhanceProps) =
switchMap((t) => of$(t?.displayName || '')),
distinctUntilChanged(),
),
crossTeamSearchEnabled: observeConfigBooleanValue(database, 'FeatureFlagExperimentalCrossTeamSearch'),
};
});

Expand Down
9 changes: 7 additions & 2 deletions app/screens/home/search/initial/initial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import React, {type Dispatch, type RefObject, type SetStateAction} from 'react';

import {ALL_TEAMS_ID} from '..';

import Modifiers from './modifiers';
import RecentSearches from './recent_searches';

Expand All @@ -22,9 +24,11 @@ type Props = {
teamId: string;
teamName: string;
teams: TeamModel[];
crossTeamSearchEnabled: boolean;
}

const Initial = ({recentSearches, scrollEnabled, searchValue, setRecentValue, searchRef, teamId, teamName, teams, setTeamId, setSearchValue}: Props) => {
const Initial = ({recentSearches, scrollEnabled, searchValue, setRecentValue, searchRef, teamId, teamName, teams, setTeamId, setSearchValue, crossTeamSearchEnabled}: Props) => {
const showRecentSearches = Boolean(recentSearches.length) && teamId !== ALL_TEAMS_ID;
return (
<>
<Modifiers
Expand All @@ -35,8 +39,9 @@ const Initial = ({recentSearches, scrollEnabled, searchValue, setRecentValue, se
teamId={teamId}
teams={teams}
scrollEnabled={scrollEnabled}
crossTeamSearchEnabled={crossTeamSearchEnabled}
/>
{Boolean(recentSearches.length) &&
{showRecentSearches &&
<RecentSearches
recentSearches={recentSearches}
setRecentValue={setRecentValue}
Expand Down
1 change: 1 addition & 0 deletions app/screens/home/search/initial/modifiers/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('Modifiers', () => {
teams={teams}
scrollEnabled={scrollEnabled}
searchRef={searchRef}
crossTeamSearchEnabled={true}
/>,
);
};
Expand Down
4 changes: 3 additions & 1 deletion app/screens/home/search/initial/modifiers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ type Props = {
setTeamId: (id: string) => void;
teamId: string;
teams: TeamModel[];
crossTeamSearchEnabled: boolean;
}
const Modifiers = ({scrollEnabled, searchValue, setSearchValue, searchRef, setTeamId, teamId, teams}: Props) => {
const Modifiers = ({scrollEnabled, searchValue, setSearchValue, searchRef, setTeamId, teamId, teams, crossTeamSearchEnabled}: Props) => {
const theme = useTheme();
const intl = useIntl();

Expand Down Expand Up @@ -157,6 +158,7 @@ const Modifiers = ({scrollEnabled, searchValue, setSearchValue, searchRef, setTe
setTeamId={setTeamId}
teamId={teamId}
teams={teams}
crossTeamSearchEnabled={crossTeamSearchEnabled}
/>
</View>
}
Expand Down
5 changes: 5 additions & 0 deletions app/screens/home/search/results/header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('Header', () => {
selectedTab={TabTypes.MESSAGES}
selectedFilter={FileFilters.ALL}
teams={teams}
crossTeamSearchEnabled={false}
/>,
);

Expand All @@ -51,6 +52,7 @@ describe('Header', () => {
selectedTab={TabTypes.MESSAGES}
selectedFilter={FileFilters.ALL}
teams={teams}
crossTeamSearchEnabled={false}
/>,
);

Expand All @@ -68,6 +70,7 @@ describe('Header', () => {
selectedTab={TabTypes.MESSAGES}
selectedFilter={FileFilters.ALL}
teams={teams}
crossTeamSearchEnabled={false}
/>,
);

Expand All @@ -85,6 +88,7 @@ describe('Header', () => {
selectedTab={TabTypes.MESSAGES}
selectedFilter={FileFilters.ALL}
teams={teams}
crossTeamSearchEnabled={false}
/>,
);

Expand All @@ -101,6 +105,7 @@ describe('Header', () => {
selectedTab={TabTypes.FILES}
selectedFilter={FileFilters.ALL}
teams={teams}
crossTeamSearchEnabled={false}
/>,
);

Expand Down
3 changes: 3 additions & 0 deletions app/screens/home/search/results/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Props = {
setTeamId: (id: string) => void;
teamId: string;
teams: TeamModel[];
crossTeamSearchEnabled: boolean;
}

const getStyleFromTheme = makeStyleSheetFromTheme((theme: Theme) => {
Expand Down Expand Up @@ -75,6 +76,7 @@ const Header = ({
selectedTab,
selectedFilter,
teams,
crossTeamSearchEnabled,
}: Props) => {
const theme = useTheme();
const styles = getStyleFromTheme(theme);
Expand Down Expand Up @@ -166,6 +168,7 @@ const Header = ({
setTeamId={setTeamId}
teamId={teamId}
teams={teams}
crossTeamSearchEnabled={crossTeamSearchEnabled}
/>
)}
</View>
Expand Down
4 changes: 3 additions & 1 deletion app/screens/home/search/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const AutocompletePaddingTop = 4;
type Props = {
teamId: string;
teams: TeamModel[];
crossTeamSearchEnabled: boolean;
}

const styles = StyleSheet.create({
Expand Down Expand Up @@ -77,7 +78,7 @@ const getSearchParams = (terms: string, filterValue?: FileFilter) => {

const searchScreenIndex = 1;

const SearchScreen = ({teamId, teams}: Props) => {
const SearchScreen = ({teamId, teams, crossTeamSearchEnabled}: Props) => {
const nav = useNavigation();
const isFocused = useIsFocused();
const intl = useIntl();
Expand Down Expand Up @@ -384,6 +385,7 @@ const SearchScreen = ({teamId, teams}: Props) => {
selectedTab={selectedTab}
selectedFilter={filter}
teams={teams}
crossTeamSearchEnabled={crossTeamSearchEnabled}
/>
}
</Animated.View>
Expand Down
3 changes: 3 additions & 0 deletions app/screens/home/search/team_picker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('TeamPicker', () => {
setTeamId={jest.fn()}
teams={teams}
teamId={'team1'}
crossTeamSearchEnabled={true}
/>,
);
expect(getByText('Team 1')).toBeTruthy();
Expand All @@ -42,6 +43,7 @@ describe('TeamPicker', () => {
setTeamId={jest.fn()}
teams={teams}
teamId={ALL_TEAMS_ID}
crossTeamSearchEnabled={true}
/>,
);
expect(getByText('All teams')).toBeTruthy();
Expand All @@ -53,6 +55,7 @@ describe('TeamPicker', () => {
setTeamId={jest.fn()}
teams={teams}
teamId={'team1'}
crossTeamSearchEnabled={true}
/>,
);
fireEvent.press(getByTestId('team_picker.button'));
Expand Down
4 changes: 3 additions & 1 deletion app/screens/home/search/team_picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ type Props = {
teams: TeamModel[];
setTeamId: (id: string) => void;
teamId: string;
crossTeamSearchEnabled: boolean;
}
const TeamPicker = ({setTeamId, teams, teamId}: Props) => {
const TeamPicker = ({setTeamId, teams, teamId, crossTeamSearchEnabled}: Props) => {
const intl = useIntl();
const theme = useTheme();
const styles = getStyleFromTheme(theme);
Expand All @@ -65,6 +66,7 @@ const TeamPicker = ({setTeamId, teams, teamId}: Props) => {
teams={teams}
teamId={teamId}
title={title}
crossTeamSearchEnabled={crossTeamSearchEnabled}
/>
);
};
Expand Down
1 change: 1 addition & 0 deletions types/api/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ interface ClientConfig {
FeatureFlagCollapsedThreads?: string;
FeatureFlagPostPriority?: string;
FeatureFlagChannelBookmarks?: string;
FeatureFlagExperimentalCrossTeamSearch?: string;
ForgotPasswordLink?: string;
GfycatApiKey: string;
GfycatApiSecret: string;
Expand Down

0 comments on commit 7507ceb

Please sign in to comment.