Skip to content

Commit bbfa56b

Browse files
authored
Merge pull request #53102 from Krishna2323/krishna2323/issue/52654
2 parents 5bb5c18 + c09e277 commit bbfa56b

File tree

5 files changed

+20
-51
lines changed

5 files changed

+20
-51
lines changed

src/components/SelectionList/BaseSelectionList.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ function BaseSelectionList<TItem extends ListItem>(
6767
showScrollIndicator = true,
6868
showLoadingPlaceholder = false,
6969
showConfirmButton = false,
70+
shouldUseDefaultTheme = false,
7071
shouldPreventDefaultFocusOnSelectRow = false,
7172
containerStyle,
7273
sectionListStyle,
@@ -832,7 +833,7 @@ function BaseSelectionList<TItem extends ListItem>(
832833
{showConfirmButton && (
833834
<FixedFooter style={[styles.mtAuto]}>
834835
<Button
835-
success
836+
success={!shouldUseDefaultTheme}
836837
large
837838
style={[styles.w100]}
838839
text={confirmButtonText || translate('common.confirm')}

src/components/SelectionList/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,9 @@ type BaseSelectionListProps<TItem extends ListItem> = Partial<ChildrenProps> & {
476476
/** Whether to show the default confirm button */
477477
showConfirmButton?: boolean;
478478

479+
/** Whether to use the default theme for the confirm button */
480+
shouldUseDefaultTheme?: boolean;
481+
479482
/** Whether tooltips should be shown */
480483
shouldShowTooltips?: boolean;
481484

src/languages/en.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2481,6 +2481,7 @@ const translations = {
24812481
notAuthorized: `You don't have access to this page. If you're trying to join this workspace, just ask the workspace owner to add you as a member. Something else? Reach out to ${CONST.EMAIL.CONCIERGE}.`,
24822482
goToRoom: ({roomName}: GoToRoomParams) => `Go to ${roomName} room`,
24832483
goToWorkspace: 'Go to workspace',
2484+
clearFilter: 'Clear filter',
24842485
workspaceName: 'Workspace name',
24852486
workspaceOwner: 'Owner',
24862487
workspaceType: 'Workspace type',
@@ -3706,7 +3707,7 @@ const translations = {
37063707
description: 'Rooms are a great place to discuss and work with multiple people. To begin collaborating, create or join a workspace',
37073708
},
37083709
switcher: {
3709-
headerTitle: 'Choose a workspace',
3710+
headerTitle: 'Filter by workspace',
37103711
everythingSection: 'Everything',
37113712
placeholder: 'Find a workspace',
37123713
},

src/languages/es.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2504,6 +2504,7 @@ const translations = {
25042504
notAuthorized: `No tienes acceso a esta página. Si estás intentando unirte a este espacio de trabajo, pide al dueño del espacio de trabajo que te añada como miembro. ¿Necesitas algo más? Comunícate con ${CONST.EMAIL.CONCIERGE}`,
25052505
goToRoom: ({roomName}: GoToRoomParams) => `Ir a la sala ${roomName}`,
25062506
goToWorkspace: 'Ir al espacio de trabajo',
2507+
clearFilter: 'Borrar filtro',
25072508
workspaceName: 'Nombre del espacio de trabajo',
25082509
workspaceOwner: 'Dueño',
25092510
workspaceType: 'Tipo de espacio de trabajo',
@@ -3751,7 +3752,7 @@ const translations = {
37513752
description: 'Las salas son un gran lugar para discutir y trabajar con varias personas. Para comenzar a colaborar, cree o únase a un espacio de trabajo',
37523753
},
37533754
switcher: {
3754-
headerTitle: 'Elige un espacio de trabajo',
3755+
headerTitle: 'Filtrar por espacio de trabajo',
37553756
everythingSection: 'Todo',
37563757
placeholder: 'Encuentra un espacio de trabajo',
37573758
},

src/pages/WorkspaceSwitcherPage/index.tsx

Lines changed: 11 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
import React, {useCallback, useMemo} from 'react';
2-
import {View} from 'react-native';
32
import {useOnyx} from 'react-native-onyx';
43
import HeaderWithBackButton from '@components/HeaderWithBackButton';
54
import * as Expensicons from '@components/Icon/Expensicons';
65
import ScreenWrapper from '@components/ScreenWrapper';
76
import SelectionList from '@components/SelectionList';
87
import type {ListItem, SectionListDataType} from '@components/SelectionList/types';
98
import UserListItem from '@components/SelectionList/UserListItem';
10-
import Text from '@components/Text';
119
import useActiveWorkspace from '@hooks/useActiveWorkspace';
1210
import useDebouncedState from '@hooks/useDebouncedState';
1311
import useLocalize from '@hooks/useLocalize';
1412
import useNetwork from '@hooks/useNetwork';
15-
import useTheme from '@hooks/useTheme';
16-
import useThemeStyles from '@hooks/useThemeStyles';
1713
import Navigation from '@libs/Navigation/Navigation';
1814
import * as PolicyUtils from '@libs/PolicyUtils';
1915
import {sortWorkspacesBySelected} from '@libs/PolicyUtils';
@@ -35,8 +31,6 @@ type WorkspaceListItem = {
3531
const WorkspaceCardCreateAWorkspaceInstance = <WorkspaceCardCreateAWorkspace />;
3632

3733
function WorkspaceSwitcherPage() {
38-
const styles = useThemeStyles();
39-
const theme = useTheme();
4034
const {isOffline} = useNetwork();
4135
const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState('');
4236
const {translate} = useLocalize();
@@ -82,17 +76,13 @@ function WorkspaceSwitcherPage() {
8276
);
8377

8478
const selectPolicy = useCallback(
85-
(option?: WorkspaceListItem) => {
86-
if (!option) {
87-
return;
88-
}
89-
90-
const {policyID} = option;
79+
(policyID?: string) => {
80+
const newPolicyID = policyID === activeWorkspaceID ? undefined : policyID;
9181

92-
setActiveWorkspaceID(policyID);
82+
setActiveWorkspaceID(newPolicyID);
9383
Navigation.goBack();
94-
if (policyID !== activeWorkspaceID) {
95-
Navigation.navigateWithSwitchPolicyID({policyID});
84+
if (newPolicyID !== activeWorkspaceID) {
85+
Navigation.navigateWithSwitchPolicyID({policyID: newPolicyID});
9686
}
9787
},
9888
[activeWorkspaceID, setActiveWorkspaceID],
@@ -147,53 +137,22 @@ function WorkspaceSwitcherPage() {
147137
const headerMessage = filteredAndSortedUserWorkspaces.length === 0 && usersWorkspaces.length ? translate('common.noResultsFound') : '';
148138
const shouldShowCreateWorkspace = usersWorkspaces.length === 0;
149139

150-
const defaultPolicy = {
151-
text: CONST.WORKSPACE_SWITCHER.NAME,
152-
icons: [{source: Expensicons.ExpensifyAppIcon, name: CONST.WORKSPACE_SWITCHER.NAME, type: CONST.ICON_TYPE_AVATAR}],
153-
brickRoadIndicator: getIndicatorTypeForPolicy(undefined),
154-
keyForList: CONST.WORKSPACE_SWITCHER.NAME,
155-
isSelected: activeWorkspaceID === undefined,
156-
};
157-
158140
return (
159141
<ScreenWrapper
160142
testID={WorkspaceSwitcherPage.displayName}
161143
includeSafeAreaPaddingBottom={false}
144+
shouldEnableMaxHeight
162145
>
163146
{({didScreenTransitionEnd}) => (
164147
<>
165148
<HeaderWithBackButton
166149
title={translate('workspace.switcher.headerTitle')}
167150
onBackButtonPress={Navigation.goBack}
168151
/>
169-
<View style={[styles.ph5, styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter, styles.mb1]}>
170-
<Text
171-
style={styles.label}
172-
color={theme.textSupporting}
173-
>
174-
{translate('workspace.switcher.everythingSection')}
175-
</Text>
176-
</View>
177-
<UserListItem
178-
item={defaultPolicy}
179-
isFocused={activeWorkspaceID === undefined}
180-
showTooltip={false}
181-
onSelectRow={() => selectPolicy(defaultPolicy)}
182-
pressableStyle={styles.flexRow}
183-
shouldSyncFocus={false}
184-
/>
185-
<View style={[styles.ph5, styles.mv2]}>
186-
<Text
187-
style={styles.label}
188-
color={theme.textSupporting}
189-
>
190-
{translate('common.workspaces')}
191-
</Text>
192-
</View>
193152
<SelectionList<WorkspaceListItem>
194153
ListItem={UserListItem}
195154
sections={sections}
196-
onSelectRow={selectPolicy}
155+
onSelectRow={(option) => selectPolicy(option.policyID)}
197156
textInputLabel={usersWorkspaces.length >= CONST.STANDARD_LIST_ITEM_LIMIT ? translate('common.search') : undefined}
198157
textInputValue={searchTerm}
199158
onChangeText={setSearchTerm}
@@ -202,6 +161,10 @@ function WorkspaceSwitcherPage() {
202161
shouldShowListEmptyContent={shouldShowCreateWorkspace}
203162
initiallyFocusedOptionKey={activeWorkspaceID ?? CONST.WORKSPACE_SWITCHER.NAME}
204163
showLoadingPlaceholder={fetchStatus.status === 'loading' || !didScreenTransitionEnd}
164+
showConfirmButton={!!activeWorkspaceID}
165+
shouldUseDefaultTheme
166+
confirmButtonText={translate('workspace.common.clearFilter')}
167+
onConfirm={() => selectPolicy(undefined)}
205168
/>
206169
</>
207170
)}

0 commit comments

Comments
 (0)