Skip to content

Commit cc8d5ab

Browse files
adfostprakashsvmxdvaldivia
authored
Adding PVC events UI (#1448)
* adding PVC events UI * adding label Co-authored-by: Prakash Senthil Vel <23444145+prakashsvmx@users.noreply.github.com> Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
1 parent 83a4c35 commit cc8d5ab

File tree

5 files changed

+137
-1
lines changed

5 files changed

+137
-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
@@ -416,6 +416,11 @@ const Console = ({
416416
path: IAM_PAGES.NAMESPACE_TENANT_PODS,
417417
forceDisplay: true,
418418
},
419+
{
420+
component: TenantDetails,
421+
path: IAM_PAGES.NAMESPACE_TENANT_PVCS,
422+
forceDisplay: true,
423+
},
419424
{
420425
component: TenantDetails,
421426
path: IAM_PAGES.NAMESPACE_TENANT_SUMMARY,
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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+
useEffect(() => {
58+
if (loading) {
59+
api
60+
.invoke(
61+
"GET",
62+
`/api/v1/namespaces/${tenantNamespace}/tenants/${tenantName}/pvcs/${PVCName}/events`
63+
)
64+
.then((res: IEvent[]) => {
65+
for (let i = 0; i < res.length; i++) {
66+
let currentTime = (Date.now() / 1000) | 0;
67+
68+
res[i].seen = niceDays((currentTime - res[i].last_seen).toString());
69+
}
70+
setEvent(res);
71+
setLoading(false);
72+
})
73+
.catch((err: ErrorResponseHandler) => {
74+
setErrorSnackMessage(err);
75+
setLoading(false);
76+
});
77+
}
78+
}, [loading, PVCName, tenantNamespace, tenantName, setErrorSnackMessage]);
79+
80+
return (
81+
<Fragment>
82+
<Grid item xs={12}>
83+
<h1 className={classes.sectionTitle}>
84+
<Link
85+
to={`/namespaces/${tenantNamespace}/tenants/${tenantName}/volumes`}
86+
className={classes.breadcrumLink}
87+
>
88+
PVCs
89+
</Link>{" "}
90+
&gt; {PVCName}
91+
</h1>
92+
</Grid>
93+
<Grid container>
94+
<h1 className={classes.sectionTitle}>Events</h1>
95+
<TableWrapper
96+
itemActions={[]}
97+
columns={[
98+
{ label: "Namespace", elementKey: "namespace" },
99+
{ label: "Last Seen", elementKey: "seen" },
100+
{ label: "Message", elementKey: "message" },
101+
{ label: "Event Type", elementKey: "event_type" },
102+
{ label: "Reason", elementKey: "reason" },
103+
]}
104+
isLoading={loading}
105+
records={event}
106+
entityName="Events"
107+
idField="event"
108+
/>
109+
</Grid>
110+
</Fragment>
111+
);
112+
};
113+
114+
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,6 +33,7 @@ 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
import withSuspense from "../../Common/Components/withSuspense";
3738
import { setTenantDetailsLoad } from "../actions";
3839
import { AppState } from "../../../../store";
@@ -42,6 +43,7 @@ const DeletePVC = withSuspense(React.lazy(() => import("./DeletePVC")));
4243
interface ITenantVolumesProps {
4344
classes: any;
4445
setErrorSnackMessage: typeof setErrorSnackMessage;
46+
history: any;
4547
match: any;
4648
loadingTenant: boolean;
4749
setTenantDetailsLoad: typeof setTenantDetailsLoad;
@@ -61,6 +63,7 @@ const styles = (theme: Theme) =>
6163
const TenantVolumes = ({
6264
classes,
6365
setErrorSnackMessage,
66+
history,
6467
match,
6568
loadingTenant,
6669
}: ITenantVolumesProps) => {
@@ -106,6 +109,13 @@ const TenantVolumes = ({
106109
elementItem.name.includes(filter)
107110
);
108111

112+
const PVCViewAction = (PVC: IPodListElement) => {
113+
history.push(
114+
`/namespaces/${tenantNamespace}/tenants/${tenantName}/pvcs/${PVC.name}`
115+
);
116+
return;
117+
};
118+
109119
const closeDeleteModalAndRefresh = (reloadData: boolean) => {
110120
setDeleteOpen(false);
111121
setLoading(true);
@@ -152,7 +162,7 @@ const TenantVolumes = ({
152162
</Grid>
153163
<Grid item xs={12} className={classes.tableBlock}>
154164
<TableWrapper
155-
itemActions={[{ type: "delete", onClick: confirmDeletePVC }]}
165+
itemActions={[{ type: "view", onClick: PVCViewAction }, { type: "delete", onClick: confirmDeletePVC }]}
156166
columns={[
157167
{
158168
label: "Name",

0 commit comments

Comments
 (0)