[Gekidou - MM-48279] Remove the team picker when a member of only one team (#6751)
This commit is contained in:
parent
57f3a408b9
commit
41b594f5a9
8 changed files with 32 additions and 32 deletions
|
|
@ -6,6 +6,7 @@ import withObservables from '@nozbe/with-observables';
|
|||
import compose from 'lodash/fp/compose';
|
||||
|
||||
import {observeCurrentTeamId} from '@queries/servers/system';
|
||||
import {queryJoinedTeams} from '@queries/servers/team';
|
||||
|
||||
import SearchScreen from './search';
|
||||
|
||||
|
|
@ -15,6 +16,7 @@ const enhance = withObservables([], ({database}: WithDatabaseArgs) => {
|
|||
const currentTeamId = observeCurrentTeamId(database);
|
||||
return {
|
||||
teamId: currentTeamId,
|
||||
teams: queryJoinedTeams(database).observe(),
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
import React from 'react';
|
||||
import Animated from 'react-native-reanimated';
|
||||
|
||||
import {TeamModel} from '@database/models/server';
|
||||
|
||||
import Modifiers from './modifiers';
|
||||
import RecentSearches from './recent_searches';
|
||||
|
||||
|
|
@ -18,9 +20,10 @@ type Props = {
|
|||
setTeamId: (value: string) => void;
|
||||
teamId: string;
|
||||
teamName: string;
|
||||
teams: TeamModel[];
|
||||
}
|
||||
|
||||
const Initial = ({recentSearches, scrollEnabled, searchValue, setRecentValue, teamId, teamName, setTeamId, setSearchValue}: Props) => {
|
||||
const Initial = ({recentSearches, scrollEnabled, searchValue, setRecentValue, teamId, teamName, teams, setTeamId, setSearchValue}: Props) => {
|
||||
return (
|
||||
<>
|
||||
<Modifiers
|
||||
|
|
@ -28,6 +31,7 @@ const Initial = ({recentSearches, scrollEnabled, searchValue, setRecentValue, te
|
|||
setSearchValue={setSearchValue}
|
||||
setTeamId={setTeamId}
|
||||
teamId={teamId}
|
||||
teams={teams}
|
||||
scrollEnabled={scrollEnabled}
|
||||
/>
|
||||
{Boolean(recentSearches.length) &&
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import Animated, {useSharedValue, useAnimatedStyle, withTiming} from 'react-nati
|
|||
|
||||
import FormattedText from '@components/formatted_text';
|
||||
import {useTheme} from '@context/theme';
|
||||
import {TeamModel} from '@database/models/server';
|
||||
import TeamPickerIcon from '@screens/home/search/team_picker_icon';
|
||||
import {makeStyleSheetFromTheme} from '@utils/theme';
|
||||
import {typography} from '@utils/typography';
|
||||
|
|
@ -83,8 +84,9 @@ type Props = {
|
|||
searchValue?: string;
|
||||
setTeamId: (id: string) => void;
|
||||
teamId: string;
|
||||
teams: TeamModel[];
|
||||
}
|
||||
const Modifiers = ({scrollEnabled, searchValue, setSearchValue, setTeamId, teamId}: Props) => {
|
||||
const Modifiers = ({scrollEnabled, searchValue, setSearchValue, setTeamId, teamId, teams}: Props) => {
|
||||
const theme = useTheme();
|
||||
const intl = useIntl();
|
||||
|
||||
|
|
@ -142,11 +144,14 @@ const Modifiers = ({scrollEnabled, searchValue, setSearchValue, setTeamId, teamI
|
|||
id={'screen.search.modifier.header'}
|
||||
defaultMessage='Search options'
|
||||
/>
|
||||
{teams.length > 1 &&
|
||||
<TeamPickerIcon
|
||||
size={TEAM_PICKER_ICON_SIZE}
|
||||
setTeamId={setTeamId}
|
||||
teamId={teamId}
|
||||
teams={teams}
|
||||
/>
|
||||
}
|
||||
</View>
|
||||
<Animated.View style={animatedStyle}>
|
||||
{data.map((item) => renderModifier(item))}
|
||||
|
|
|
|||
|
|
@ -8,16 +8,16 @@ import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
|||
import Badge from '@components/badge';
|
||||
import CompassIcon from '@components/compass_icon';
|
||||
import {useTheme} from '@context/theme';
|
||||
import {TeamModel} from '@database/models/server';
|
||||
import {useIsTablet} from '@hooks/device';
|
||||
import {TITLE_SEPARATOR_MARGIN, TITLE_SEPARATOR_MARGIN_TABLET, TITLE_HEIGHT} from '@screens/bottom_sheet/content';
|
||||
import TeamPickerIcon from '@screens/home/search/team_picker_icon';
|
||||
import {bottomSheet} from '@screens/navigation';
|
||||
import {FileFilter, FileFilters} from '@utils/file';
|
||||
import {bottomSheetSnapPoint} from '@utils/helpers';
|
||||
import {TabTypes, TabType} from '@utils/search';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme';
|
||||
|
||||
import TeamPickerIcon from '../team_picker_icon';
|
||||
|
||||
import Filter, {DIVIDERS_HEIGHT, FILTER_ITEM_HEIGHT, NUMBER_FILTER_ITEMS} from './filter';
|
||||
import SelectButton from './header_button';
|
||||
|
||||
|
|
@ -30,6 +30,7 @@ type Props = {
|
|||
numberFiles: number;
|
||||
setTeamId: (id: string) => void;
|
||||
teamId: string;
|
||||
teams: TeamModel[];
|
||||
}
|
||||
|
||||
const getStyleFromTheme = makeStyleSheetFromTheme((theme: Theme) => {
|
||||
|
|
@ -50,7 +51,7 @@ const getStyleFromTheme = makeStyleSheetFromTheme((theme: Theme) => {
|
|||
paddingHorizontal: 12,
|
||||
flexDirection: 'row',
|
||||
},
|
||||
filter: {
|
||||
iconsContainer: {
|
||||
alignItems: 'center',
|
||||
flexDirection: 'row',
|
||||
marginLeft: 'auto',
|
||||
|
|
@ -67,6 +68,7 @@ const Header = ({
|
|||
numberFiles,
|
||||
selectedTab,
|
||||
selectedFilter,
|
||||
teams,
|
||||
}: Props) => {
|
||||
const theme = useTheme();
|
||||
const styles = getStyleFromTheme(theme);
|
||||
|
|
@ -118,6 +120,8 @@ const Header = ({
|
|||
});
|
||||
}, [selectedFilter]);
|
||||
|
||||
const filterStyle = useMemo(() => ({marginRight: teams.length > 1 ? 0 : 10}), [teams.length > 1]);
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<View style={styles.buttonsContainer}>
|
||||
|
|
@ -131,11 +135,9 @@ const Header = ({
|
|||
onPress={handleFilesPress}
|
||||
text={`${filesText} (${numberFiles})`}
|
||||
/>
|
||||
<View
|
||||
style={styles.filter}
|
||||
>
|
||||
<View style={styles.iconsContainer}>
|
||||
{showFilterIcon &&
|
||||
<>
|
||||
<View style={filterStyle}>
|
||||
<CompassIcon
|
||||
name={'filter-variant'}
|
||||
size={24}
|
||||
|
|
@ -148,14 +150,17 @@ const Header = ({
|
|||
testID={'search.filters.badge'}
|
||||
value={-1}
|
||||
/>
|
||||
</>
|
||||
</View>
|
||||
}
|
||||
{teams.length > 1 &&
|
||||
<TeamPickerIcon
|
||||
size={32}
|
||||
divider={true}
|
||||
setTeamId={setTeamId}
|
||||
teamId={teamId}
|
||||
teams={teams}
|
||||
/>
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import {SearchRef} from '@components/search';
|
|||
import {BOTTOM_TAB_HEIGHT} from '@constants/view';
|
||||
import {useServerUrl} from '@context/server';
|
||||
import {useTheme} from '@context/theme';
|
||||
import {TeamModel} from '@database/models/server';
|
||||
import {useKeyboardHeight} from '@hooks/device';
|
||||
import useDidUpdate from '@hooks/did_update';
|
||||
import {useCollapsibleHeader} from '@hooks/header';
|
||||
|
|
@ -45,6 +46,7 @@ const AutocompletePaddingTop = 4;
|
|||
|
||||
type Props = {
|
||||
teamId: string;
|
||||
teams: TeamModel[];
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
|
|
@ -71,7 +73,7 @@ const getSearchParams = (terms: string, filterValue?: FileFilter) => {
|
|||
|
||||
const searchScreenIndex = 1;
|
||||
|
||||
const SearchScreen = ({teamId}: Props) => {
|
||||
const SearchScreen = ({teamId, teams}: Props) => {
|
||||
const nav = useNavigation();
|
||||
const isFocused = useIsFocused();
|
||||
const intl = useIntl();
|
||||
|
|
@ -229,6 +231,7 @@ const SearchScreen = ({teamId}: Props) => {
|
|||
setSearchValue={handleModifierTextChange}
|
||||
setTeamId={setSearchTeamId}
|
||||
teamId={searchTeamId}
|
||||
teams={teams}
|
||||
/>
|
||||
);
|
||||
}, [handleRecentSearch, handleTextChange, loading,
|
||||
|
|
@ -346,6 +349,7 @@ const SearchScreen = ({teamId}: Props) => {
|
|||
selectedTab={selectedTab}
|
||||
numberFiles={fileInfos.length}
|
||||
selectedFilter={filter}
|
||||
teams={teams}
|
||||
/>
|
||||
}
|
||||
</Animated.View>
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import {preventDoubleTap} from '@utils/tap';
|
|||
import {getTeamsSnapHeight} from '@utils/team_list';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme';
|
||||
|
||||
import SelectTeamSlideUp from './search_team_slideup';
|
||||
import SelectTeamSlideUp from './select_team_slideup';
|
||||
|
||||
import type TeamModel from '@typings/database/models/servers/team';
|
||||
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {withDatabase} from '@nozbe/watermelondb/DatabaseProvider';
|
||||
import withObservables from '@nozbe/with-observables';
|
||||
|
||||
import {queryJoinedTeams} from '@queries/servers/team';
|
||||
|
||||
import TeamPickerIcon from './team_picker_icon';
|
||||
|
||||
import type {WithDatabaseArgs} from '@typings/database/database';
|
||||
|
||||
const enhanced = withObservables([], ({database}: WithDatabaseArgs) => {
|
||||
const teams = queryJoinedTeams(database).observe();
|
||||
return {
|
||||
teams,
|
||||
};
|
||||
});
|
||||
|
||||
export default withDatabase(enhanced(TeamPickerIcon));
|
||||
Loading…
Reference in a new issue