• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

input-output-hk / lace / 8519959931

29 Mar 2024 01:42PM UTC coverage: 50.577% (-3.3%) from 53.839%
8519959931

push

github

b4f7c8
web-flow
chore: LW-9786 enable single pool delegation in multi-delegation view (#970)

* chore: enable single pool delegation in multi-delegation view

* fix: fix hw multi-delegation tx signing

* fix(extension): fix broken ledger connection

2172 of 5359 branches covered (40.53%)

Branch coverage included in aggregate %.

5146 of 9110 relevant lines covered (56.49%)

52.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

36.0
/apps/browser-extension-wallet/src/components/DropdownMenu/DropdownMenu.tsx
1
import React, { useEffect } from 'react';
70✔
2
import cn from 'classnames';
70✔
3
import { Dropdown } from 'antd';
70✔
4
import { Button, addEllipsis } from '@lace/common';
70✔
5
import { DropdownMenuOverlay } from '../MainMenu';
70✔
6

7
import ChevronNormal from '../../assets/icons/chevron-down.component.svg';
70✔
8
import ChevronSmall from '../../assets/icons/chevron-down-small.component.svg';
70✔
9
import styles from './DropdownMenu.module.scss';
70✔
10
import { useWalletStore } from '@src/stores';
70✔
11
import { UserAvatar } from '../MainMenu/DropdownMenuOverlay/components';
70✔
12
import { useAnalyticsContext } from '@providers';
70✔
13
import { PostHogAction } from '@providers/AnalyticsProvider/analyticsTracker';
70✔
14
import { ProfileDropdown } from '@lace/ui';
70✔
15
import { useGetHandles } from '@hooks';
70✔
16
import { getAssetImageUrl } from '@src/utils/get-asset-image-url';
70✔
17
import { getActiveWalletSubtitle } from '@src/utils/get-wallet-subtitle';
70✔
18
import { getUiWalletType } from '@src/utils/get-ui-wallet-type';
70✔
19

20
export interface DropdownMenuProps {
21
  isPopup?: boolean;
22
}
23

24
export const DropdownMenu = ({ isPopup }: DropdownMenuProps): React.ReactElement => {
70✔
25
  const analytics = useAnalyticsContext();
×
26
  const {
27
    cardanoWallet,
28
    walletUI: { isDropdownMenuOpen = false },
×
29
    setIsDropdownMenuOpen
30
  } = useWalletStore();
×
31
  const [handle] = useGetHandles();
×
32
  const handleImage = handle?.profilePic;
×
33
  const Chevron = isPopup ? ChevronSmall : ChevronNormal;
×
34

35
  const sendAnalyticsEvent = (event: PostHogAction) => {
×
36
    analytics.sendEventToPostHog(event);
×
37
  };
38

39
  const handleDropdownState = (openDropdown: boolean) => {
×
40
    setIsDropdownMenuOpen(openDropdown);
×
41
    if (openDropdown) {
×
42
      sendAnalyticsEvent(PostHogAction.UserWalletProfileIconClick);
×
43
    }
44
  };
45

46
  useEffect(() => () => setIsDropdownMenuOpen(false), [setIsDropdownMenuOpen]);
×
47

48
  const walletName = cardanoWallet.source.wallet.metadata.name;
×
49

50
  const titleCharBeforeEll = 10;
×
51
  const titleCharAfterEll = 0;
×
52

53
  return (
×
54
    <Dropdown
55
      overlayClassName={styles.overlay}
56
      destroyPopupOnHide
57
      onOpenChange={handleDropdownState}
58
      overlay={<DropdownMenuOverlay isPopup={isPopup} sendAnalyticsEvent={sendAnalyticsEvent} />}
59
      placement="bottomRight"
60
      trigger={['click']}
61
    >
62
      {process.env.USE_MULTI_WALLET === 'true' ? (
63
        <div className={styles.profileDropdownTrigger}>
×
64
          <ProfileDropdown.Trigger
65
            title={addEllipsis(walletName, titleCharBeforeEll, titleCharAfterEll)}
66
            subtitle={getActiveWalletSubtitle(cardanoWallet.source.account)}
67
            active={isDropdownMenuOpen}
68
            profile={
69
              handleImage
70
                ? {
×
71
                    fallback: walletName,
72
                    imageSrc: getAssetImageUrl(handleImage)
73
                  }
74
                : undefined
75
            }
76
            type={getUiWalletType(cardanoWallet.source.wallet.type)}
77
            id="menu"
78
          />
79
        </div>
80
      ) : (
81
        <Button
82
          variant="outlined"
83
          color="secondary"
84
          className={cn(styles.avatarBtn, { [styles.open]: isDropdownMenuOpen })}
85
          data-testid="header-menu-button"
86
        >
87
          <span className={cn(styles.content, { [styles.isPopup]: isPopup })}>
88
            <UserAvatar walletName={walletName} isPopup={isPopup} />
89
            <Chevron
90
              className={cn(styles.chevron, { [styles.open]: isDropdownMenuOpen })}
91
              data-testid={`chevron-${isDropdownMenuOpen ? 'up' : 'down'}`}
×
92
            />
93
          </span>
94
        </Button>
95
      )}
96
    </Dropdown>
97
  );
98
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc