forked from chabad360/cockpit-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImageUsedBy.jsx
44 lines (39 loc) · 1.68 KB
/
ImageUsedBy.jsx
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
38
39
40
41
42
43
44
import React from 'react';
import cockpit from 'cockpit';
import { Button } from "@patternfly/react-core/dist/esm/components/Button";
import { Badge } from "@patternfly/react-core/dist/esm/components/Badge";
import { Flex } from "@patternfly/react-core/dist/esm/layouts/Flex";
import { List, ListItem } from "@patternfly/react-core/dist/esm/components/List";
const _ = cockpit.gettext;
const ImageUsedBy = ({ containers, showAll }) => {
if (containers === null)
return _("Loading...");
if (containers === undefined)
return _("No containers are using this image");
return (
<List isPlain>
{containers.map(c => {
const container = c.container;
const isRunning = container.State?.Status === "running";
return (
<ListItem key={container.Id}>
<Flex>
<Button variant="link"
isInline
onClick={() => {
const loc = document.location.toString().split('#')[0];
document.location = loc + '#' + container.Id;
if (!isRunning)
showAll();
}}>
{container.Name}
</Button>
{isRunning && <Badge className="ct-badge-container-running">{_("Running")}</Badge>}
</Flex>
</ListItem>
);
})}
</List>
);
};
export default ImageUsedBy;