| 1 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 2 |
import React from 'react'; |
| 3 |
import { createRoot } from "react-dom/client"; |
| 4 |
|
| 5 |
import '../lib/patternfly/patternfly-6-cockpit.scss'; |
| 6 |
|
| 7 |
import { Button } from "@patternfly/react-core/dist/esm/components/Button/index.js"; |
| 8 |
import { Card, CardBody, CardTitle } from '@patternfly/react-core/dist/esm/components/Card/index.js'; |
| 9 |
import { Content } from "@patternfly/react-core/dist/esm/components/Content/index.js"; |
| 10 |
import { Page, PageSection } from "@patternfly/react-core/dist/esm/components/Page/index.js"; |
| 11 |
import { TextInput } from "@patternfly/react-core/dist/esm/components/TextInput/index.js"; |
| 12 |
|
| 13 |
import { install_dialog } from "../lib/cockpit-components-install-dialog.jsx"; |
| 14 |
|
| 15 |
import 'cockpit-dark-theme'; // once per page |
| 16 |
import 'page.scss'; |
| 17 |
|
| 18 |
const PackageManagerPage = () => { |
| 19 |
const [isInstalling, setIsInstalling] = React.useState(false); |
| 20 |
const [installPackages, setInstallPackages] = React.useState(""); |
| 21 |
|
| 22 |
const openInstallDialog = async () => { |
| 23 |
setIsInstalling(true); |
| 24 |
try { |
| 25 |
await install_dialog(installPackages.split(",")); |
| 26 |
} finally { |
| 27 |
setIsInstalling(false); |
| 28 |
} |
| 29 |
}; |
| 30 |
|
| 31 |
return ( |
| 32 |
<Page isContentFilled className="no-masthead-sidebar"> |
| 33 |
<PageSection hasBodyWrapper={false}> |
| 34 |
<Content> |
| 35 |
<Card> |
| 36 |
<CardTitle id="install-card-title">Install dialog test</CardTitle> |
| 37 |
<CardBody> |
| 38 |
<TextInput id="install-packages" value={installPackages} onChange={(_event, value) => setInstallPackages(value)} /> |
| 39 |
<Button id="install-button" variant="primary" onClick={() => openInstallDialog()} isLoading={isInstalling}>Install Package</Button> |
| 40 |
</CardBody> |
| 41 |
</Card> |
| 42 |
</Content> |
| 43 |
</PageSection> |
| 44 |
</Page> |
| 45 |
); |
| 46 |
}; |
| 47 |
|
| 48 |
document.addEventListener("DOMContentLoaded", async () => { |
| 49 |
const root = createRoot(document.getElementById("packagemanager")!); |
| 50 |
root.render(<PackageManagerPage />); |
| 51 |
}); |