/* * Copyright (C) 2019 Red Hat, Inc. * SPDX-License-Identifier: LGPL-2.1-or-later */ import React from 'react'; import { Button } from "@patternfly/react-core/dist/esm/components/Button/index.js"; import { Card, CardBody, CardHeader, CardTitle } from "@patternfly/react-core/dist/esm/components/Card/index.js"; import { DataList, DataListCell, DataListItem, DataListItemCells, DataListItemRow } from "@patternfly/react-core/dist/esm/components/DataList/index.js"; import { Modal, ModalBody, ModalFooter, ModalHeader } from '@patternfly/react-core/dist/esm/components/Modal/index.js'; import { Tab, Tabs } from "@patternfly/react-core/dist/esm/components/Tabs/index.js"; import { TextArea } from "@patternfly/react-core/dist/esm/components/TextArea/index.js"; import { Icon } from "@patternfly/react-core/dist/esm/components/Icon/index.js"; import { CheckIcon, CopyIcon, ExternalLinkAltIcon, OutlinedQuestionCircleIcon } from '@patternfly/react-icons'; import cockpit from "cockpit"; import 'cockpit-components-modifications.css'; const _ = cockpit.gettext; /* Dialog for showing scripts to modify system * * Enables showing shell and ansible script. Shell one is mandatory and ansible one can be omitted. * */ export const ModificationsExportDialog = ({ onClose, shell, ansible }: { onClose: () => void; shell: string; ansible?: string | undefined; }) => { const [active_tab, setActiveTab] = React.useState(ansible ? "ansible" : "shell"); const [copied, setCopied] = React.useState(false); const [timeoutId, setTimeoutId] = React.useState(null); const handleSelect = (_event: React.MouseEvent, active_tab: string | number) => { setCopied(false); setActiveTab(active_tab); if (timeoutId !== null) { clearTimeout(timeoutId); setTimeoutId(null); } }; const copyToClipboard = () => { try { navigator.clipboard.writeText((active_tab === "ansible" ? ansible! : shell).trim()) .then(() => { setCopied(true); setTimeoutId(setTimeout(() => { setCopied(false); setTimeoutId(null); }, 3000)); }) .catch(e => console.error('Text could not be copied: ', e ? e.toString() : "")); } catch (error) { console.error('Text could not be copied: ', String(error)); } }; const footer = ( ); return ( { ansible ?