Skip to content

Commit fd87bf9

Browse files
committed
adding PVC events UI
1 parent df4c63e commit fd87bf9

File tree

5 files changed

+143
-1
lines changed

5 files changed

+143
-1
lines changed

portal-ui/src/common/SecureComponent/permissions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ export const IAM_PAGES = {
199199
NAMESPACE_TENANT_HOP: "/namespaces/:tenantNamespace/tenants/:tenantName/hop",
200200
NAMESPACE_TENANT_PODS:
201201
"/namespaces/:tenantNamespace/tenants/:tenantName/pods/:podName",
202+
NAMESPACE_TENANT_PVCS:
203+
"/namespaces/:tenantNamespace/tenants/:tenantName/pvcs/:PVCName",
202204
NAMESPACE_TENANT_PODS_LIST:
203205
"/namespaces/:tenantNamespace/tenants/:tenantName/pods",
204206
NAMESPACE_TENANT_SUMMARY:

portal-ui/src/screens/Console/Console.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,11 @@ const Console = ({
415415
path: IAM_PAGES.NAMESPACE_TENANT_PODS,
416416
forceDisplay: true,
417417
},
418+
{
419+
component: TenantDetails,
420+
path: IAM_PAGES.NAMESPACE_TENANT_PVCS,
421+
forceDisplay: true,
422+
},
418423
{
419424
component: TenantDetails,
420425
path: IAM_PAGES.NAMESPACE_TENANT_SUMMARY,
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
// This file is part of MinIO Console Server
2+
// Copyright (c) 2021 MinIO, Inc.
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
import React, { Fragment, useEffect, useState } from "react";
18+
import { Theme } from "@mui/material/styles";
19+
import createStyles from "@mui/styles/createStyles";
20+
import withStyles from "@mui/styles/withStyles";
21+
import { containerForHeader } from "../../Common/FormComponents/common/styleLibrary";
22+
import Grid from "@mui/material/Grid";
23+
import { Link } from "react-router-dom";
24+
import { setErrorSnackMessage } from "../../../../actions";
25+
import api from "../../../../common/api";
26+
import { IEvent } from "../ListTenants/types";
27+
import { niceDays } from "../../../../common/utils";
28+
import { ErrorResponseHandler } from "../../../../common/types";
29+
import TableWrapper from "../../Common/TableWrapper/TableWrapper";
30+
31+
interface IPVCDetailsProps {
32+
classes: any;
33+
match: any;
34+
setErrorSnackMessage: typeof setErrorSnackMessage;
35+
}
36+
37+
const styles = (theme: Theme) =>
38+
createStyles({
39+
breadcrumLink: {
40+
textDecoration: "none",
41+
color: "black",
42+
},
43+
...containerForHeader(theme.spacing(4)),
44+
});
45+
46+
const PVCDetails = ({
47+
classes,
48+
match,
49+
setErrorSnackMessage,
50+
}: IPVCDetailsProps) => {
51+
const [loading, setLoading] = useState<boolean>(true);
52+
const tenantNamespace = match.params["tenantNamespace"];
53+
const tenantName = match.params["tenantName"];
54+
const PVCName = match.params["PVCName"];
55+
const [event, setEvent] = useState<IEvent[]>([]);
56+
57+
function a11yProps(index: any) {
58+
return {
59+
id: `simple-tab-${index}`,
60+
"aria-controls": `simple-tabpanel-${index}`,
61+
};
62+
}
63+
64+
useEffect(() => {
65+
if (loading) {
66+
api
67+
.invoke(
68+
"GET",
69+
`/api/v1/namespaces/${tenantNamespace}/tenants/${tenantName}/pvcs/${PVCName}/events`
70+
)
71+
.then((res: IEvent[]) => {
72+
for (let i = 0; i < res.length; i++) {
73+
let currentTime = (Date.now() / 1000) | 0;
74+
75+
res[i].seen = niceDays((currentTime - res[i].last_seen).toString());
76+
}
77+
setEvent(res);
78+
setLoading(false);
79+
})
80+
.catch((err: ErrorResponseHandler) => {
81+
setErrorSnackMessage(err);
82+
setLoading(false);
83+
});
84+
}
85+
}, [loading, PVCName, tenantNamespace, tenantName, setErrorSnackMessage]);
86+
87+
return (
88+
<Fragment>
89+
<Grid item xs={12}>
90+
<h1 className={classes.sectionTitle}>
91+
<Link
92+
to={`/namespaces/${tenantNamespace}/tenants/${tenantName}/volumes`}
93+
className={classes.breadcrumLink}
94+
>
95+
PVCs
96+
</Link>{" "}
97+
&gt; {PVCName}
98+
</h1>
99+
</Grid>
100+
<Grid container>
101+
<TableWrapper
102+
itemActions={[]}
103+
columns={[
104+
{ label: "Namespace", elementKey: "namespace" },
105+
{ label: "Last Seen", elementKey: "seen" },
106+
{ label: "Message", elementKey: "message" },
107+
{ label: "Event Type", elementKey: "event_type" },
108+
{ label: "Reason", elementKey: "reason" },
109+
]}
110+
isLoading={loading}
111+
records={event}
112+
entityName="Events"
113+
idField="event"
114+
/>
115+
</Grid>
116+
</Fragment>
117+
);
118+
};
119+
120+
export default withStyles(styles)(PVCDetails);

portal-ui/src/screens/Console/Tenants/TenantDetails/TenantDetails.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import BackLink from "../../../../common/BackLink";
5050
import VerticalTabs from "../../Common/VerticalTabs/VerticalTabs";
5151
import BoxIconButton from "../../Common/BoxIconButton/BoxIconButton";
5252
import withSuspense from "../../Common/Components/withSuspense";
53+
import PVCDetails from "./PVCDetails";
5354

5455
const TenantYAML = withSuspense(React.lazy(() => import("./TenantYAML")));
5556
const TenantSummary = withSuspense(React.lazy(() => import("./TenantSummary")));
@@ -438,6 +439,10 @@ const TenantDetails = ({
438439
path="/namespaces/:tenantNamespace/tenants/:tenantName/pods"
439440
component={PodsSummary}
440441
/>
442+
<Route
443+
path="/namespaces/:tenantNamespace/tenants/:tenantName/pvcs/:PVCName"
444+
component={PVCDetails}
445+
/>
441446
<Route
442447
path="/namespaces/:tenantNamespace/tenants/:tenantName/volumes"
443448
component={VolumesSummary}

portal-ui/src/screens/Console/Tenants/TenantDetails/VolumesSummary.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ import { ErrorResponseHandler } from "../../../../common/types";
3333
import api from "../../../../common/api";
3434
import TableWrapper from "../../Common/TableWrapper/TableWrapper";
3535
import SearchIcon from "../../../../icons/SearchIcon";
36+
import { IPodListElement } from "../ListTenants/types";
3637

3738
interface ITenantVolumesProps {
3839
classes: any;
3940
setErrorSnackMessage: typeof setErrorSnackMessage;
41+
history: any;
4042
match: any;
4143
}
4244

@@ -54,6 +56,7 @@ const styles = (theme: Theme) =>
5456
const TenantVolumes = ({
5557
classes,
5658
setErrorSnackMessage,
59+
history,
5760
match,
5861
}: ITenantVolumesProps) => {
5962
const [records, setRecords] = useState<IStoragePVCs[]>([]);
@@ -86,6 +89,13 @@ const TenantVolumes = ({
8689
elementItem.name.includes(filter)
8790
);
8891

92+
const PVCViewAction = (PVC: IPodListElement) => {
93+
history.push(
94+
`/namespaces/${tenantNamespace}/tenants/${tenantName}/pvcs/${PVC.name}`
95+
);
96+
return;
97+
};
98+
8999
return (
90100
<Fragment>
91101
<h1 className={classes.sectionTitle}>Volumes</h1>
@@ -114,7 +124,7 @@ const TenantVolumes = ({
114124
</Grid>
115125
<Grid item xs={12} className={classes.tableBlock}>
116126
<TableWrapper
117-
itemActions={[]}
127+
itemActions={[{ type: "view", onClick: PVCViewAction }]}
118128
columns={[
119129
{
120130
label: "Name",

0 commit comments

Comments
 (0)