-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
249 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/* | ||
* This file is part of Cockpit. | ||
* | ||
* Copyright (C) 2017 Red Hat, Inc. | ||
* | ||
* Cockpit is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation; either version 2.1 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Cockpit is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with Cockpit; If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import cockpit from "cockpit"; | ||
import React from "react"; | ||
|
||
import { Page, PageSection } from "@patternfly/react-core/dist/esm/components/Page/index.js"; | ||
import { Card, CardHeader, CardTitle, CardBody } from "@patternfly/react-core/dist/esm/components/Card/index.js"; | ||
import { Stack } from "@patternfly/react-core/dist/esm/layouts/Stack/index.js"; | ||
import { ListingTable } from "cockpit-components-table.jsx"; | ||
|
||
import { StorageBarMenu } from "./storage-controls.jsx"; | ||
|
||
import { thing_menu_items, thing_rows } from "./things-panel.jsx"; | ||
import { drive_rows } from "./drives-panel.jsx"; | ||
import { iscsi_menu_items, iscsi_rows, portal_menu_items } from "./iscsi-panel.jsx"; | ||
import { other_rows } from "./others-panel.jsx"; | ||
import { block_content_rows, vgroup_content_rows, block_menu_items, vgroup_menu_items } from "./content-views.jsx"; | ||
import { stratis_content_rows, pool_menu_items } from "./stratis-details.jsx"; | ||
|
||
import { StoragePlots } from "./plot.jsx"; | ||
import { JobsPanel } from "./jobs-panel.jsx"; | ||
import { StorageLogsPanel } from "./logs-panel.jsx"; | ||
import { fmt_size } from "./utils.js"; | ||
|
||
const _ = cockpit.gettext; | ||
|
||
// XXX - all this needs to be added: | ||
// | ||
// <LockedCryptoPanel client={client} /> | ||
// <NFSPanel client={client} /> | ||
|
||
export const OverviewX = ({ client, plot_state }) => { | ||
const menu_items = [].concat( | ||
thing_menu_items(client, { unified: true }), | ||
iscsi_menu_items(client, { unified: true })); | ||
|
||
const actions = <StorageBarMenu id="devices-menu" | ||
isKebab | ||
label={_("Create devices")} | ||
menuItems={menu_items} />; | ||
|
||
const top_rows = [].concat( | ||
drive_rows(client, { unified: true }), | ||
thing_rows(client, { unified: true }), | ||
iscsi_rows(client, { unified: true }), | ||
other_rows(client, { unified: true })); | ||
|
||
let rows = []; | ||
top_rows.forEach(t => { | ||
let m = []; | ||
if (t.block) | ||
m = block_menu_items(client, t.block, { unified: true }); | ||
if (t.vgroup) | ||
m = vgroup_menu_items(client, t.vgroup, { unified: true }); | ||
if (t.pool) | ||
m = pool_menu_items(client, t.pool, { unified: true }); | ||
if (t.portal) | ||
m = portal_menu_items(client, t.portal, { unified: true }); | ||
const actions = (m.length > 0 | ||
? <StorageBarMenu isKebab label={_("Create")} menuItems={m} /> | ||
: null); | ||
rows.push({ | ||
props: { key: t.path, go: t.go }, | ||
columns: [ | ||
{ title: t.name }, // XXX - use "ID", name is taken. | ||
{ title: t.type }, | ||
{ title: t.location || t.devname }, | ||
{ title: fmt_size(t.size), props: { className: "pf-v5-u-text-align-right" } }, | ||
{ title: actions, props: { className: "pf-v5-c-table__action content-action" } }, | ||
] | ||
}); | ||
if (t.block) | ||
rows = rows.concat(block_content_rows(client, t.block, { unified: true })); | ||
if (t.vgroup) | ||
rows = rows.concat(vgroup_content_rows(client, t.vgroup, { unified: true })); | ||
if (t.pool) | ||
rows = rows.concat(stratis_content_rows(client, t.pool, { unified: true })); | ||
}); | ||
|
||
function onRowClick(event, row) { | ||
if (!event || event.button !== 0) | ||
return; | ||
|
||
// StorageBarMenu sets this to tell us not to navigate when | ||
// the kebabs are opened. | ||
if (event.defaultPrevented) | ||
return; | ||
|
||
console.log("CLICK", event, row.props); | ||
if (row.props.go) | ||
row.props.go(); | ||
} | ||
|
||
return ( | ||
<Page id="main-storage"> | ||
<PageSection> | ||
<Stack hasGutter> | ||
<Card> | ||
<CardBody> | ||
<StoragePlots plot_state={plot_state} /> | ||
</CardBody> | ||
</Card> | ||
<Card> | ||
<CardHeader actions={{ actions }}> | ||
<CardTitle component="h2">{_("Storage")}</CardTitle> | ||
</CardHeader> | ||
<CardBody className="contains-list"> | ||
<ListingTable | ||
id="unified" | ||
variant="compact" | ||
aria-label={_("Storage")} | ||
onRowClick={onRowClick} | ||
columns={[ | ||
{ title: _("ID") }, | ||
{ title: _("Type") }, | ||
{ title: _("Location") }, | ||
{ title: _("Size") }, | ||
]} | ||
rows={rows} /> | ||
</CardBody> | ||
</Card> | ||
<JobsPanel client={client} /> | ||
<StorageLogsPanel /> | ||
</Stack> | ||
</PageSection> | ||
</Page> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.