LCOV - code coverage report
Current view: top level - pkg/storaged/iscsi - session.jsx Coverage Total Hit
Test: cockpit Lines: 100.0 % 56 56
Test Date: 2026-06-25 09:20:42

            Line data    Source code
       1              : /*
       2              :  * Copyright (C) 2023 Red Hat, Inc.
       3              :  * SPDX-License-Identifier: LGPL-2.1-or-later
       4              :  */
       5              : 
       6          113 : import cockpit from "cockpit";
       7          113 : import React from "react";
       8              : import client from "../client";
       9              : 
      10              : import { CardBody } from "@patternfly/react-core/dist/esm/components/Card/index.js";
      11              : import { DescriptionList } from "@patternfly/react-core/dist/esm/components/DescriptionList/index.js";
      12              : 
      13              : import { NetworkIcon } from "../icons/gnome-icons.jsx";
      14              : import {
      15              :     new_page, new_card, PAGE_CATEGORY_NETWORK,
      16              :     StorageDescription, ChildrenTable, StorageCard
      17              : } from "../pages.jsx";
      18              : 
      19              : import { make_drive_page } from "../drive/drive.jsx";
      20              : 
      21          113 : const _ = cockpit.gettext;
      22              : 
      23            1 : async function disconnect(session, goto_page) {
      24            1 :     const loc = cockpit.location;
      25            1 :     await session.Logout({ 'node.startup': { t: 's', v: "manual" } });
      26            1 :     loc.go(goto_page.location);
      27            1 : }
      28              : 
      29            1 : export function make_iscsi_session_page(parent, session) {
      30            1 :     const session_card = new_card({
      31            1 :         title: _("iSCSI portal"),
      32            1 :         next: null,
      33            1 :         page_location: ["iscsi", session.data.target_name],
      34            1 :         page_name: session.data.target_name,
      35            1 :         page_icon: NetworkIcon,
      36            1 :         page_category: PAGE_CATEGORY_NETWORK,
      37            1 :         component: ISCSISessionCard,
      38            1 :         props: { session },
      39            1 :         actions: [
      40            1 :             {
      41            1 :                 title: _("Disconnect"),
      42            1 :                 action: () => disconnect(session, parent),
      43            1 :                 danger: true
      44            1 :             },
      45            1 :         ]
      46            1 :     });
      47              : 
      48            1 :     const drives_card = new_card({
      49            1 :         title: _("iSCSI drives"),
      50            1 :         next: session_card,
      51            1 :         component: ISCSIDrivesCard,
      52            1 :         props: { session },
      53            1 :     });
      54              : 
      55            1 :     const p = new_page(parent, drives_card);
      56              : 
      57            1 :     if (client.iscsi_sessions_drives[session.path])
      58            1 :         client.iscsi_sessions_drives[session.path].forEach(d => make_drive_page(p, d));
      59            1 : }
      60              : 
      61            1 : const ISCSIDrivesCard = ({ card, session }) => {
      62            1 :     return (
      63            1 :         <StorageCard card={card}>
      64            1 :             <ChildrenTable
      65            1 :                 emptyCaption={_("No drives found")}
      66            1 :                 aria-label={_("iSCSI drives")}
      67            1 :                 page={card.page} />
      68            1 :         </StorageCard>
      69              :     );
      70            1 : };
      71              : 
      72            1 : const ISCSISessionCard = ({ card, session }) => {
      73            1 :     return (
      74            1 :         <StorageCard card={card}>
      75            1 :             <CardBody>
      76            1 :                 <DescriptionList className="pf-m-horizontal-on-sm">
      77            1 :                     <StorageDescription title={_("Address")} value={session.data.address} />
      78            1 :                     <StorageDescription title={_("Target")} value={session.data.target_name} />
      79            1 :                 </DescriptionList>
      80            1 :             </CardBody>
      81            1 :         </StorageCard>
      82              :     );
      83            1 : };
        

Generated by: LCOV version 2.0-1