Skip to content

Commit

Permalink
chore: hide lock option if wallet already locked
Browse files Browse the repository at this point in the history
  • Loading branch information
pete-watters committed Aug 21, 2024
1 parent 9bc13ab commit b43cf8b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/app/components/layout/footer/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ export function Footer({ children, ...props }: HasChildren & FlexProps) {
gap="space.05"
p="space.05"
bottom={0}
width="100vw"
maxWidth="100%"
width="100%"
zIndex={1}
minHeight="footerHeight"
position="fixed"
Expand Down
7 changes: 2 additions & 5 deletions src/app/features/container/headers/unlock.header.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import { useNavigate, useOutletContext } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';

import { SettingsSelectors } from '@tests/selectors/settings.selectors';

import { HamburgerIcon } from '@leather.io/ui';

import { RouteUrls } from '@shared/route-urls';
import { SwitchAccountOutletContext } from '@shared/switch-account';

import { Header } from '@app/components/layout/headers/header';
import { HeaderGrid, HeaderGridRightCol } from '@app/components/layout/headers/header-grid';
import { LogoBox } from '@app/components/layout/headers/logo-box';
import { Settings } from '@app/features/settings/settings';

export function UnlockHeader() {
const { isShowingSwitchAccount, setIsShowingSwitchAccount } =
useOutletContext<SwitchAccountOutletContext>();
const navigate = useNavigate();

return (
Expand All @@ -26,8 +23,8 @@ export function UnlockHeader() {
rightCol={
<HeaderGridRightCol>
<Settings
canLockWallet={false}
triggerButton={<HamburgerIcon data-testid={SettingsSelectors.SettingsMenuBtn} />}
toggleSwitchAccount={() => setIsShowingSwitchAccount(!isShowingSwitchAccount)}
/>
</HeaderGridRightCol>
}
Expand Down
15 changes: 10 additions & 5 deletions src/app/features/settings/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,15 @@ import { AdvancedMenuItems } from './components/advanced-menu-items';
import { LedgerDeviceItemRow } from './components/ledger-item-row';

interface SettingsProps {
canLockWallet?: boolean;
triggerButton: React.ReactNode;
toggleSwitchAccount(): void;
toggleSwitchAccount?(): void;
}
export function Settings({ triggerButton, toggleSwitchAccount }: SettingsProps) {
export function Settings({
canLockWallet = true,
triggerButton,
toggleSwitchAccount,
}: SettingsProps) {
const [showSignOut, setShowSignOut] = useState(false);
const [showChangeTheme, setShowChangeTheme] = useState(false);
const [showChangeNetwork, setShowChangeNetwork] = useState(false);
Expand All @@ -70,7 +75,7 @@ export function Settings({ triggerButton, toggleSwitchAccount }: SettingsProps)
() =>
[
showAdvancedMenuOptions && <AdvancedMenuItems />,
hasKeys && walletType === 'software' && (
canLockWallet && hasKeys && walletType === 'software' && (
<DropdownMenu.Item
onSelect={() => {
void analytics.track('lock_session');
Expand All @@ -96,7 +101,7 @@ export function Settings({ triggerButton, toggleSwitchAccount }: SettingsProps)
</DropdownMenu.Item>
),
].filter(Boolean),
[hasKeys, lockWallet, navigate, showAdvancedMenuOptions, showSignOut, walletType]
[canLockWallet, hasKeys, lockWallet, navigate, showAdvancedMenuOptions, showSignOut, walletType]
);

return (
Expand All @@ -120,7 +125,7 @@ export function Settings({ triggerButton, toggleSwitchAccount }: SettingsProps)
<LedgerDeviceItemRow deviceType={extractDeviceNameFromKnownTargetIds(targetId)} />
</DropdownMenu.Item>
)}
{hasKeys && (
{hasKeys && toggleSwitchAccount && (
<DropdownMenu.Item
data-testid={SettingsSelectors.SwitchAccountTrigger}
onSelect={toggleSwitchAccount}
Expand Down

0 comments on commit b43cf8b

Please sign in to comment.