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

epam / miew / 10580306892

27 Aug 2024 02:35PM UTC coverage: 25.125%. Remained the same
10580306892

push

github

paulsmirnov
Fix the "Fork me on GitGub" banner

1443 of 5703 branches covered (25.3%)

Branch coverage included in aggregate %.

3968 of 15833 relevant lines covered (25.06%)

47529.52 hits per line

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

0.0
/packages/miew-app/src/components/menu/displayPreference/DisplayPreference.jsx
1
import React, { useEffect, useRef } from 'react';
2

3
import './DisplayPreference.scss';
4
import Thumbnail from './thumbnail/Thumbnail.jsx';
5

6
function DisplayPreferences({
7
  options,
8
  viewer,
9
  showDisplayPreference,
10
  preferenceName,
11
}) {
12
  const ref = useRef();
×
13
  const repr = viewer.rep(viewer.repCurrent());
×
14
  const instances = options.all.map((E) => new E());
×
15

16
  const Thumbnails = instances.map(({ shortName, id }, index) => (
×
17
    <Thumbnail
×
18
      shortName={shortName}
19
      id={id}
20
      key={index}
21
      selected={repr[preferenceName] === id}
22
      preferenceName={preferenceName}
23
      onClick={() => {
24
        viewer.rep({ [preferenceName]: id });
×
25
        showDisplayPreference();
×
26
      }}
27
    />
28
  ));
29

30
  const handleClickOutside = ({ target }) => {
×
31
    if (!ref.current.contains(target)) {
×
32
      showDisplayPreference();
×
33
    }
34
  };
35

36
  useEffect(() => {
×
37
    document.addEventListener('click', handleClickOutside);
×
38
    return () => document.removeEventListener('click', handleClickOutside);
×
39
  }, []);
40

41
  return (
×
42
    <div className="display-preference-container" ref={ref}>
43
      <div className="display-preference">
44
        <h5>Display {preferenceName}</h5>
45
        <div className="thumbnail-group">{Thumbnails}</div>
46
      </div>
47
    </div>
48
  );
49
}
50

51
export default DisplayPreferences;
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