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

input-output-hk / lace / 7104287749

05 Dec 2023 05:20PM UTC coverage: 52.945% (-0.9%) from 53.839%
7104287749

push

github

91f891
pczeglik-iohk
chore(extension): update lace version v1.8.0 (#772)

1989 of 4674 branches covered (0.0%)

Branch coverage included in aggregate %.

4483 of 7550 relevant lines covered (59.38%)

56.08 hits per line

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

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

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

18
export interface DropdownMenuProps {
19
  isPopup?: boolean;
20
}
21

22
export const DropdownMenu = ({ isPopup }: DropdownMenuProps): React.ReactElement => {
24✔
23
  const analytics = useAnalyticsContext();
×
24
  const { walletInfo } = useWalletStore();
×
25
  const [open, setOpen] = useState(false);
×
26
  const [handle] = useGetHandles();
×
27
  const handleImage = handle?.profilePic;
×
28
  const Chevron = isPopup ? ChevronSmall : ChevronNormal;
×
29

30
  const sendAnalyticsEvent = (event: PostHogAction) => {
×
31
    analytics.sendEventToPostHog(event);
×
32
  };
33

34
  const handleDropdownState = (openDropdown: boolean) => {
×
35
    setOpen(openDropdown);
×
36
    if (openDropdown) {
×
37
      sendAnalyticsEvent(PostHogAction.UserWalletProfileIconClick);
×
38
    }
39
  };
40

41
  return (
×
42
    <Dropdown
43
      destroyPopupOnHide
44
      onVisibleChange={handleDropdownState}
45
      overlay={<DropdownMenuOverlay isPopup={isPopup} sendAnalyticsEvent={sendAnalyticsEvent} />}
46
      placement="bottomRight"
47
      trigger={['click']}
48
    >
49
      {process.env.USE_MULTI_WALLET === 'true' ? (
50
        <div className={styles.profileDropdownTrigger}>
×
51
          <ProfileDropdown.Trigger
52
            title={walletInfo.name}
53
            subtitle="Account #0"
54
            profile={
55
              handleImage
56
                ? {
×
57
                    fallback: walletInfo.name,
58
                    imageSrc: getAssetImageUrl(handleImage)
59
                  }
60
                : undefined
61
            }
62
            type="cold"
63
            id="menu"
64
          />
65
        </div>
66
      ) : (
67
        <Button
68
          variant="outlined"
69
          color="secondary"
70
          className={cn(styles.avatarBtn, { [styles.open]: open })}
71
          data-testid="header-menu-button"
72
        >
73
          <span className={cn(styles.content, { [styles.isPopup]: isPopup })}>
74
            <UserAvatar walletName={walletInfo.name} isPopup={isPopup} />
75
            <Chevron
76
              className={cn(styles.chevron, { [styles.open]: open })}
77
              data-testid={`chevron-${open ? 'up' : 'down'}`}
×
78
            />
79
          </span>
80
        </Button>
81
      )}
82
    </Dropdown>
83
  );
84
};
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