Skip to content

Commit 368acc1

Browse files
authored
fix: hide staking and add shared wallet options when in shared wallet (#1447)
1 parent 50dc461 commit 368acc1

File tree

5 files changed

+52
-36
lines changed

5 files changed

+52
-36
lines changed

apps/browser-extension-wallet/src/components/MainMenu/DropdownMenuOverlay/DropdownMenuOverlay.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const DropdownMenuOverlay: VFC<Props> = ({
4040
...props
4141
}): React.ReactElement => {
4242
const [currentSection, setCurrentSection] = useState<Sections>(Sections.Main);
43-
const { environmentName, setManageAccountsWallet, walletType } = useWalletStore();
43+
const { environmentName, setManageAccountsWallet, walletType, isSharedWallet } = useWalletStore();
4444

4545
const openWalletAccounts = (wallet: AnyBip32Wallet<Wallet.WalletMetadata, Wallet.AccountMetadata>) => {
4646
setManageAccountsWallet(wallet);
@@ -85,7 +85,7 @@ export const DropdownMenuOverlay: VFC<Props> = ({
8585
{process.env.USE_MULTI_WALLET === 'true' && (
8686
<AddNewWalletLink isPopup={isPopup} sendAnalyticsEvent={sendAnalyticsEvent} />
8787
)}
88-
{process.env.USE_SHARED_WALLET === 'true' && <AddSharedWalletLink isPopup={isPopup} />}
88+
{process.env.USE_SHARED_WALLET === 'true' && !isSharedWallet && <AddSharedWalletLink isPopup={isPopup} />}
8989
<AddressBookLink />
9090
<SettingsLink />
9191
<Separator />

apps/browser-extension-wallet/src/components/MainMenu/MainFooter.tsx

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@ import { MenuItemList } from '@src/utils/constants';
2121
import styles from './MainFooter.module.scss';
2222
import { useAnalyticsContext } from '@providers';
2323
import { PostHogAction } from '@providers/AnalyticsProvider/analyticsTracker';
24+
import { useWalletStore } from '@stores';
2425

2526
const includesCoin = /coin/i;
2627

28+
// eslint-disable-next-line complexity
2729
export const MainFooter = (): React.ReactElement => {
2830
const location = useLocation<{ pathname: string }>();
2931
const history = useHistory();
3032
const analytics = useAnalyticsContext();
33+
const { isSharedWallet } = useWalletStore();
3134

3235
const currentLocation = location?.pathname;
3336
const isWalletIconActive =
@@ -105,18 +108,20 @@ export const MainFooter = (): React.ReactElement => {
105108
<TransactionsIcon className={styles.icon} />
106109
)}
107110
</button>
108-
<button
109-
onMouseEnter={() => onMouseEnterItem(MenuItemList.STAKING)}
110-
onMouseLeave={onMouseLeaveItem}
111-
data-testid="main-footer-staking"
112-
onClick={() => handleNavigation(walletRoutePaths.earn)}
113-
>
114-
{currentLocation === walletRoutePaths.earn ? (
115-
<StakingIconActive className={styles.icon} />
116-
) : (
117-
<StakingIcon className={styles.icon} />
118-
)}
119-
</button>
111+
{!isSharedWallet && (
112+
<button
113+
onMouseEnter={() => onMouseEnterItem(MenuItemList.STAKING)}
114+
onMouseLeave={onMouseLeaveItem}
115+
data-testid="main-footer-staking"
116+
onClick={() => handleNavigation(walletRoutePaths.earn)}
117+
>
118+
{currentLocation === walletRoutePaths.earn ? (
119+
<StakingIconActive className={styles.icon} />
120+
) : (
121+
<StakingIcon className={styles.icon} />
122+
)}
123+
</button>
124+
)}
120125
</div>
121126
</div>
122127
);

apps/browser-extension-wallet/src/routes/ExtensionRoutes.tsx

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,27 @@ import { AddressBook } from '../features/address-book';
1212
import { Settings } from '../features/settings';
1313
import { SignMessageDrawer } from '@views/browser/features/sign-message/SignMessageDrawer';
1414
import { NftDetail, Nfts } from '@src/features/nfts';
15+
import { useWalletStore } from '@stores';
1516

16-
export const ExtensionRoutes = (): React.ReactElement => (
17-
<MainLayout>
18-
<Switch>
19-
<Route exact path={walletRoutePaths.assets} component={PopupAssets} />
20-
<Route exact path={walletRoutePaths.receive} component={ReceiveInfoContainer} />
21-
<Route exact path={walletRoutePaths.activity} component={Activity} />
22-
<Route exact path={walletRoutePaths.send} component={Send} />
23-
<Route exact path={walletRoutePaths.nftDetail} component={NftDetail} />
24-
<Route exact path={walletRoutePaths.earn} component={DelegationContainer} />
25-
<Route exact path={walletRoutePaths.addressBook} component={AddressBook} />
26-
<Route exact path={walletRoutePaths.settings} component={Settings} />
27-
<Route exact path={walletRoutePaths.signMessage} component={SignMessageDrawer} />
28-
<Route exact path={walletRoutePaths.nfts} component={Nfts} />
29-
<Route path="*" render={() => <Redirect to={walletRoutePaths.assets} />} />
30-
</Switch>
31-
{/* TODO: LW-7575 Remove old staking in post-MVP of multi delegation staking.*/}
32-
<StakingWarningModals popupView />
33-
</MainLayout>
34-
);
17+
export const ExtensionRoutes = (): React.ReactElement => {
18+
const { isSharedWallet } = useWalletStore();
19+
return (
20+
<MainLayout>
21+
<Switch>
22+
<Route exact path={walletRoutePaths.assets} component={PopupAssets} />
23+
<Route exact path={walletRoutePaths.receive} component={ReceiveInfoContainer} />
24+
<Route exact path={walletRoutePaths.activity} component={Activity} />
25+
<Route exact path={walletRoutePaths.send} component={Send} />
26+
<Route exact path={walletRoutePaths.nftDetail} component={NftDetail} />
27+
{!isSharedWallet && <Route exact path={walletRoutePaths.earn} component={DelegationContainer} />}
28+
<Route exact path={walletRoutePaths.addressBook} component={AddressBook} />
29+
<Route exact path={walletRoutePaths.settings} component={Settings} />
30+
<Route exact path={walletRoutePaths.signMessage} component={SignMessageDrawer} />
31+
<Route exact path={walletRoutePaths.nfts} component={Nfts} />
32+
<Route path="*" render={() => <Redirect to={walletRoutePaths.assets} />} />
33+
</Switch>
34+
{/* TODO: LW-7575 Remove old staking in post-MVP of multi delegation staking.*/}
35+
<StakingWarningModals popupView />
36+
</MainLayout>
37+
);
38+
};

apps/browser-extension-wallet/src/views/browser-view/components/SideMenu/SideMenu.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { PostHogAction } from '@providers/AnalyticsProvider/analyticsTracker';
77
import { sideMenuConfig } from './side-menu-config';
88
import { SideMenuContent } from './SideMenuContent';
99
import { walletRoutePaths as routes } from '@routes/wallet-paths';
10+
import { useWalletStore } from '@stores';
1011

1112
const isPathAvailable = (path: string) => Object.values(routes).includes(path);
1213

@@ -17,6 +18,7 @@ export const SideMenu = (): React.ReactElement => {
1718
listen
1819
} = useHistory();
1920
const analytics = useAnalyticsContext();
21+
const { isSharedWallet } = useWalletStore();
2022

2123
const [currentHoveredItem, setCurrentHoveredItem] = useState<MenuItemList | undefined>();
2224

@@ -60,9 +62,11 @@ export const SideMenu = (): React.ReactElement => {
6062
// eslint-disable-next-line unicorn/no-useless-undefined
6163
const onMouseLeaveItem = () => setCurrentHoveredItem(undefined);
6264

65+
const menuItems = isSharedWallet ? sideMenuConfig.filter((item) => item.id !== MenuItemList.STAKING) : sideMenuConfig;
66+
6367
return (
6468
<SideMenuContent
65-
menuItems={sideMenuConfig}
69+
menuItems={menuItems}
6670
activeItemId={tab}
6771
hoveredItemId={currentHoveredItem}
6872
onClick={handleRedirection}

apps/browser-extension-wallet/src/views/browser-view/routes/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ export const BrowserViewRoutes = ({ routesMap = defaultRoutes }: { routesMap?: R
103103
deletingWallet,
104104
stayOnAllDonePage,
105105
cardanoWallet,
106-
initialHdDiscoveryCompleted
106+
initialHdDiscoveryCompleted,
107+
isSharedWallet
107108
} = useWalletStore();
108109
const [{ chainName }] = useAppSettingsContext();
109110
const { areExperimentsLoading } = useExperimentsContext();
@@ -112,6 +113,8 @@ export const BrowserViewRoutes = ({ routesMap = defaultRoutes }: { routesMap?: R
112113

113114
const location = useLocation<{ background?: Location<unknown> }>();
114115

116+
const currentRoutes = isSharedWallet ? routesMap.filter((route) => route.path !== routes.staking) : routesMap;
117+
115118
useEffect(() => {
116119
const isCreatingWallet = [routes.newWallet.root, routes.sharedWallet.root].some((path) =>
117120
location.pathname.startsWith(path)
@@ -188,7 +191,7 @@ export const BrowserViewRoutes = ({ routesMap = defaultRoutes }: { routesMap?: R
188191
return (
189192
<>
190193
<Switch location={page || location}>
191-
{routesMap.map((route) => (
194+
{currentRoutes.map((route) => (
192195
<Route key={route.path} path={route.path} component={route.component} />
193196
))}
194197
<Route path="*" render={() => <Redirect to={routes.assets} />} />

0 commit comments

Comments
 (0)