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

inventree / InvenTree / 8591603326

07 Apr 2024 09:06PM UTC coverage: 49.547% (-39.9%) from 89.48%
8591603326

Pull #6945

github

web-flow
Merge 61ceb2ebd into 3b87c84ae
Pull Request #6945: Fix test coverage

221 of 649 branches covered (34.05%)

Branch coverage included in aggregate %.

708 of 1226 relevant lines covered (57.75%)

6.16 hits per line

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

17.86
/src/frontend/src/components/images/Thumbnail.tsx
1
import { t } from '@lingui/macro';
2
import { Anchor, Skeleton } from '@mantine/core';
3
import { Group } from '@mantine/core';
4
import { Text } from '@mantine/core';
5
import { ReactNode, useMemo } from 'react';
6

7
import { ApiImage } from './ApiImage';
8

9
/*
10
 * Render an image, loaded via the API
11
 */
12
export function Thumbnail({
13
  src,
14
  alt = t`Thumbnail`,
×
15
  size = 20,
×
16
  text,
17
  align
18
}: {
19
  src?: string | undefined;
20
  alt?: string;
21
  size?: number;
22
  text?: ReactNode;
23
  align?: string;
24
}) {
25
  const backup_image = '/static/img/blank_image.png';
×
26

27
  return (
×
28
    <Group align={align ?? 'left'} spacing="xs" noWrap={true}>
×
29
      <ApiImage
30
        src={src || backup_image}
×
31
        alt={alt}
32
        width={size}
33
        fit="contain"
34
        radius="xs"
35
        withPlaceholder
36
        imageProps={{
37
          style: {
38
            maxHeight: size
39
          }
40
        }}
41
      />
42
      {text}
43
    </Group>
44
  );
45
}
2✔
46

47
export function ThumbnailHoverCard({
2✔
48
  src,
49
  text,
50
  link = '',
×
51
  alt = t`Thumbnail`,
×
52
  size = 20
×
53
}: {
54
  src: string;
55
  text: string;
56
  link?: string;
57
  alt?: string;
58
  size?: number;
59
}) {
×
60
  const card = useMemo(() => {
×
61
    return (
×
62
      <Group position="left" spacing={10} noWrap={true}>
63
        <Thumbnail src={src} alt={alt} size={size} />
64
        <Text>{text}</Text>
65
      </Group>
66
    );
67
  }, [src, text, alt, size]);
68

69
  if (link) {
×
70
    return (
×
71
      <Anchor href={link} style={{ textDecoration: 'none' }}>
72
        {card}
73
      </Anchor>
74
    );
75
  }
76

77
  return <div>{card}</div>;
×
78
}
2✔
79

80
export function PartHoverCard({ part }: { part: any }) {
6✔
81
  return part ? (
×
82
    <ThumbnailHoverCard
83
      src={part.thumbnail || part.image}
×
84
      text={part.full_name}
85
      alt={part.description}
86
      link=""
87
    />
88
  ) : (
89
    <Skeleton />
90
  );
91
}
2✔
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