-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutility.tsx
37 lines (34 loc) · 1.09 KB
/
utility.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { type Benchmark } from '@eosc-perf/eosc-perf-client';
/**
* If a specified string is falsy, replace it with a muted gray "None" text or similar
*
* @param value input String to evaluate
* @param altText Text to display instead of "None"
* @returns Either a div with gray None text or the original string.
*/
export const truthyOrNoneTag = (value: string | undefined | null, altText = 'None') => {
if (!value && value !== 0) {
return (
<div className="text-muted" style={{ display: 'inline' }}>
{altText}
</div>
);
}
return value;
};
/**
* Display a label for a benchmark with image and tag, with a link to the docker hub
*
* @param benchmark Benchmark to display label for
*/
export const benchmarkLinkDisplay = (benchmark: Benchmark) => {
const dockerHubLink = `https://hub.docker.com/r/${benchmark.docker_image}`;
return (
<>
<a href={dockerHubLink} style={{ display: 'inline' }}>
{benchmark.docker_image}
</a>
{`:${benchmark.docker_tag}`}
</>
);
};