LCOV - code coverage report
Current view: top level - src - ImageUsedBy.jsx Coverage Total Hit
Test: cockpit-podman Lines: 93.8 % 32 30
Test Date: 2025-05-21 17:35:03

            Line data    Source code
       1           43 : import React from 'react';
       2              : 
       3              : import { Badge } from "@patternfly/react-core/dist/esm/components/Badge";
       4              : import { Button } from "@patternfly/react-core/dist/esm/components/Button";
       5              : import { List, ListItem } from "@patternfly/react-core/dist/esm/components/List";
       6              : import { Flex } from "@patternfly/react-core/dist/esm/layouts/Flex";
       7              : 
       8              : import cockpit from 'cockpit';
       9              : 
      10           43 : const _ = cockpit.gettext;
      11              : 
      12           41 : const ImageUsedBy = ({ containers, showAll }) => {
      13           41 :     if (containers === null)
      14            0 :         return _("Loading...");
      15           41 :     if (containers === undefined)
      16            0 :         return _("No containers are using this image");
      17              : 
      18           41 :     return (
      19           41 :         <List isPlain>
      20           41 :             {containers.map(c => {
      21           41 :                 const container = c.container;
      22           41 :                 const isRunning = container.State?.Status === "running";
      23           41 :                 return (
      24           41 :                     <ListItem key={container.Id}>
      25           41 :                         <Flex>
      26           41 :                             <Button variant="link"
      27           41 :                                     isInline
      28            2 :                                     onClick={() => {
      29            2 :                                         const loc = document.location.toString().split('#')[0];
      30            2 :                                         document.location = loc + '#' + container.Id;
      31              : 
      32            2 :                                         if (!isRunning)
      33            2 :                                             showAll();
      34            2 :                                     }}>
      35           41 :                                 {container.Name}
      36           41 :                             </Button>
      37           36 :                             {isRunning && <Badge className="ct-badge-container-running">{_("Running")}</Badge>}
      38           41 :                         </Flex>
      39           41 :                     </ListItem>
      40              :                 );
      41           41 :             })}
      42           41 :         </List>
      43              :     );
      44           41 : };
      45              : 
      46           43 : export default ImageUsedBy;
        

Generated by: LCOV version 2.0-1