Skip to content

Commit

Permalink
Merge pull request #52254 from twilight2294/dontShowAddbutton
Browse files Browse the repository at this point in the history
Don't show two creation options at the same time in the workspace switcher
  • Loading branch information
MariaHCD authored Nov 11, 2024
2 parents 4e0dc82 + 4bf05cc commit 52c6ce2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
49 changes: 28 additions & 21 deletions src/pages/WorkspaceSwitcherPage/WorkspacesSectionHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ import Navigation from '@libs/Navigation/Navigation';
import * as App from '@userActions/App';
import CONST from '@src/CONST';

function WorkspacesSectionHeader() {
type WorkspacesSectionHeaderProps = {
/** Should show the create workspace icon */
shouldShowCreateWorkspaceIcon: boolean;
};

function WorkspacesSectionHeader({shouldShowCreateWorkspaceIcon}: WorkspacesSectionHeaderProps) {
const theme = useTheme();
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand All @@ -28,26 +33,28 @@ function WorkspacesSectionHeader() {
{translate('common.workspaces')}
</Text>
</View>
<Tooltip text={translate('workspace.new.newWorkspace')}>
<PressableWithFeedback
accessibilityLabel={translate('workspace.new.newWorkspace')}
role={CONST.ROLE.BUTTON}
onPress={() => {
const activeRoute = Navigation.getActiveRouteWithoutParams();
interceptAnonymousUser(() => App.createWorkspaceWithPolicyDraftAndNavigateToIt('', '', false, false, activeRoute));
}}
>
{({hovered}) => (
<Icon
src={Expensicons.Plus}
width={12}
height={12}
additionalStyles={[styles.buttonDefaultBG, styles.borderRadiusNormal, styles.p2, hovered && styles.buttonHoveredBG]}
fill={theme.icon}
/>
)}
</PressableWithFeedback>
</Tooltip>
{shouldShowCreateWorkspaceIcon && (
<Tooltip text={translate('workspace.new.newWorkspace')}>
<PressableWithFeedback
accessibilityLabel={translate('workspace.new.newWorkspace')}
role={CONST.ROLE.BUTTON}
onPress={() => {
const activeRoute = Navigation.getActiveRouteWithoutParams();
interceptAnonymousUser(() => App.createWorkspaceWithPolicyDraftAndNavigateToIt('', '', false, false, activeRoute));
}}
>
{({hovered}) => (
<Icon
src={Expensicons.Plus}
width={12}
height={12}
additionalStyles={[styles.buttonDefaultBG, styles.borderRadiusNormal, styles.p2, hovered && styles.buttonHoveredBG]}
fill={theme.icon}
/>
)}
</PressableWithFeedback>
</Tooltip>
)}
</View>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/WorkspaceSwitcherPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function WorkspaceSwitcherPage() {
pressableStyle={styles.flexRow}
shouldSyncFocus={false}
/>
<WorkspacesSectionHeader />
<WorkspacesSectionHeader shouldShowCreateWorkspaceIcon={!shouldShowCreateWorkspace} />
<SelectionList<WorkspaceListItem>
ListItem={UserListItem}
sections={sections}
Expand Down

0 comments on commit 52c6ce2

Please sign in to comment.