/* * Copyright (C) 2024 Red Hat, Inc. * SPDX-License-Identifier: LGPL-2.1-or-later */ import cockpit from "cockpit"; import React, { useEffect, useState } from "react"; import { Banner } from "@patternfly/react-core/dist/esm/components/Banner/index.js"; import { Button } from "@patternfly/react-core/dist/esm/components/Button/index.js"; import { Content } from "@patternfly/react-core/dist/esm/components/Content/index.js"; import { Modal, ModalBody, ModalFooter, ModalHeader, ModalVariant } from "@patternfly/react-core/dist/esm/components/Modal/index.js"; import { PageSection } from "@patternfly/react-core/dist/esm/components/Page/index.js"; import { Flex, FlexItem } from "@patternfly/react-core/dist/esm/layouts/Flex/index.js"; import { ArrowLeftIcon } from "@patternfly/react-icons/dist/esm/icons/arrow-left-icon"; import { ExclamationTriangleIcon } from "@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon"; import { TimesIcon } from "@patternfly/react-icons/dist/esm/icons/times-icon"; import { useMaybeBackdrop } from "../../../hooks/CockpitIntegration.jsx"; import { CheckStorageDialog } from "./CheckStorageDialog.jsx"; import { ModifyStorageSideBar } from "./CockpitStorageIntegrationSidebar.jsx"; import "./CockpitStorageIntegration.scss"; const _ = cockpit.gettext; const idPrefix = "cockpit-storage-integration"; const ReturnToInstallationButton = ({ onAction }) => ( ); const CockpitStorageConfirmationModal = ({ handleCancelOpenModal, handleConfirmOpenModal, showConfirmation }) => { return ( {_("The storage editor lets you resize, delete, and create partitions. It can set up LVM and much more. It is meant to be used as an advanced utility and not intended to be used in a typical installation.")} {_("All changes made in the storage editor take effect immediately.")} ); }; export const CockpitStorageIntegration = ({ dispatch, onCritFail, setShowStorage, }) => { const [showDialog, setShowDialog] = useState(false); const [isIframeMounted, setIsIframeMounted] = useState(false); const [isConfirmed, setIsConfirmed] = useState(false); const backdropClass = useMaybeBackdrop(); const handleIframeLoad = () => setIsIframeMounted(true); useEffect(() => { if (isIframeMounted) { const iframe = document.getElementById("cockpit-storage-frame"); iframe.contentWindow.addEventListener("error", exception => { onCritFail({ context: _("Storage plugin failed") })({ message: exception.error.message, stack: exception.error.stack }); }); } }, [isIframeMounted, onCritFail]); const handleConfirmOpenModal = () => { setIsConfirmed(true); setShowStorage(true); }; const handleCancelOpenModal = () => { setShowStorage(false); setIsConfirmed(false); }; return ( <> { _("Changes made here will immediately affect the system. There is no 'undo'.") }