* Add new team picker for search * try fix result header * fix style * add test for team picker * add some tests * add tests on team list and team list item * hide All Teams search behind FF * use style variable for separator * ALL TEAMS does not have a search history * Update app/components/team_list/index.test.tsx Co-authored-by: Elias Nahum <nahumhbl@gmail.com> * move ALL_TEAMS_ID to a constant file * memoize the construction of team list to prevent useless allocation * combine pushes * move style to stylesheet * revert changes to Package.resolved * improve team list index tests * add test to ensure team picker does not show for just one team * add test to ensure the file icon filter only shows when i'm on the file tab * improve jsx readability by making the if test positive * add test to make sure team picket does not show if there's only one team * test: remove snapshot and add expect that separator exists in index 0 but index 1 (#8474) * Trigger Build --------- Co-authored-by: Elias Nahum <nahumhbl@gmail.com> Co-authored-by: Mattermost Build <build@mattermost.com> Co-authored-by: Rahim Rahman <rahim.rahman@mattermost.com>
55 lines
1.9 KiB
TypeScript
55 lines
1.9 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React, {type Dispatch, type RefObject, type SetStateAction} from 'react';
|
|
|
|
import {ALL_TEAMS_ID} from '@constants/team';
|
|
|
|
import Modifiers from './modifiers';
|
|
import RecentSearches from './recent_searches';
|
|
|
|
import type {SearchRef} from '@components/search';
|
|
import type TeamModel from '@typings/database/models/servers/team';
|
|
import type TeamSearchHistoryModel from '@typings/database/models/servers/team_search_history';
|
|
import type Animated from 'react-native-reanimated';
|
|
|
|
type Props = {
|
|
recentSearches: TeamSearchHistoryModel[];
|
|
scrollEnabled: Animated.SharedValue<boolean>;
|
|
searchValue?: string;
|
|
setRecentValue: Dispatch<SetStateAction<string>>;
|
|
searchRef: RefObject<SearchRef>;
|
|
setSearchValue: Dispatch<SetStateAction<string>>;
|
|
setTeamId: (value: string) => void;
|
|
teamId: string;
|
|
teamName: string;
|
|
teams: TeamModel[];
|
|
crossTeamSearchEnabled: boolean;
|
|
}
|
|
|
|
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
|
|
searchValue={searchValue}
|
|
searchRef={searchRef}
|
|
setSearchValue={setSearchValue}
|
|
setTeamId={setTeamId}
|
|
teamId={teamId}
|
|
teams={teams}
|
|
scrollEnabled={scrollEnabled}
|
|
crossTeamSearchEnabled={crossTeamSearchEnabled}
|
|
/>
|
|
{showRecentSearches &&
|
|
<RecentSearches
|
|
recentSearches={recentSearches}
|
|
setRecentValue={setRecentValue}
|
|
teamName={teamName}
|
|
/>
|
|
}
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default Initial;
|