diff --git a/portal-ui/src/common/SecureComponent/permissions.ts b/portal-ui/src/common/SecureComponent/permissions.ts index 966d6d95c3..09d72f2a8d 100644 --- a/portal-ui/src/common/SecureComponent/permissions.ts +++ b/portal-ui/src/common/SecureComponent/permissions.ts @@ -199,6 +199,8 @@ export const IAM_PAGES = { NAMESPACE_TENANT_HOP: "/namespaces/:tenantNamespace/tenants/:tenantName/hop", NAMESPACE_TENANT_PODS: "/namespaces/:tenantNamespace/tenants/:tenantName/pods/:podName", + NAMESPACE_TENANT_PVCS: + "/namespaces/:tenantNamespace/tenants/:tenantName/pvcs/:PVCName", NAMESPACE_TENANT_PODS_LIST: "/namespaces/:tenantNamespace/tenants/:tenantName/pods", NAMESPACE_TENANT_SUMMARY: diff --git a/portal-ui/src/screens/Console/Console.tsx b/portal-ui/src/screens/Console/Console.tsx index 7102f87400..95564521b8 100644 --- a/portal-ui/src/screens/Console/Console.tsx +++ b/portal-ui/src/screens/Console/Console.tsx @@ -416,6 +416,11 @@ const Console = ({ path: IAM_PAGES.NAMESPACE_TENANT_PODS, forceDisplay: true, }, + { + component: TenantDetails, + path: IAM_PAGES.NAMESPACE_TENANT_PVCS, + forceDisplay: true, + }, { component: TenantDetails, path: IAM_PAGES.NAMESPACE_TENANT_SUMMARY, diff --git a/portal-ui/src/screens/Console/Tenants/TenantDetails/PVCDetails.tsx b/portal-ui/src/screens/Console/Tenants/TenantDetails/PVCDetails.tsx new file mode 100644 index 0000000000..51de31cbd5 --- /dev/null +++ b/portal-ui/src/screens/Console/Tenants/TenantDetails/PVCDetails.tsx @@ -0,0 +1,114 @@ +// This file is part of MinIO Console Server +// Copyright (c) 2021 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program 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 Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +import React, { Fragment, useEffect, useState } from "react"; +import { Theme } from "@mui/material/styles"; +import createStyles from "@mui/styles/createStyles"; +import withStyles from "@mui/styles/withStyles"; +import { containerForHeader } from "../../Common/FormComponents/common/styleLibrary"; +import Grid from "@mui/material/Grid"; +import { Link } from "react-router-dom"; +import { setErrorSnackMessage } from "../../../../actions"; +import api from "../../../../common/api"; +import { IEvent } from "../ListTenants/types"; +import { niceDays } from "../../../../common/utils"; +import { ErrorResponseHandler } from "../../../../common/types"; +import TableWrapper from "../../Common/TableWrapper/TableWrapper"; + +interface IPVCDetailsProps { + classes: any; + match: any; + setErrorSnackMessage: typeof setErrorSnackMessage; +} + +const styles = (theme: Theme) => + createStyles({ + breadcrumLink: { + textDecoration: "none", + color: "black", + }, + ...containerForHeader(theme.spacing(4)), + }); + +const PVCDetails = ({ + classes, + match, + setErrorSnackMessage, +}: IPVCDetailsProps) => { + const [loading, setLoading] = useState(true); + const tenantNamespace = match.params["tenantNamespace"]; + const tenantName = match.params["tenantName"]; + const PVCName = match.params["PVCName"]; + const [event, setEvent] = useState([]); + + useEffect(() => { + if (loading) { + api + .invoke( + "GET", + `/api/v1/namespaces/${tenantNamespace}/tenants/${tenantName}/pvcs/${PVCName}/events` + ) + .then((res: IEvent[]) => { + for (let i = 0; i < res.length; i++) { + let currentTime = (Date.now() / 1000) | 0; + + res[i].seen = niceDays((currentTime - res[i].last_seen).toString()); + } + setEvent(res); + setLoading(false); + }) + .catch((err: ErrorResponseHandler) => { + setErrorSnackMessage(err); + setLoading(false); + }); + } + }, [loading, PVCName, tenantNamespace, tenantName, setErrorSnackMessage]); + + return ( + + +

+ + PVCs + {" "} + > {PVCName} +

+
+ +

Events

+ +
+
+ ); +}; + +export default withStyles(styles)(PVCDetails); diff --git a/portal-ui/src/screens/Console/Tenants/TenantDetails/TenantDetails.tsx b/portal-ui/src/screens/Console/Tenants/TenantDetails/TenantDetails.tsx index db976ed91e..3e321222be 100644 --- a/portal-ui/src/screens/Console/Tenants/TenantDetails/TenantDetails.tsx +++ b/portal-ui/src/screens/Console/Tenants/TenantDetails/TenantDetails.tsx @@ -50,6 +50,7 @@ import BackLink from "../../../../common/BackLink"; import VerticalTabs from "../../Common/VerticalTabs/VerticalTabs"; import BoxIconButton from "../../Common/BoxIconButton/BoxIconButton"; import withSuspense from "../../Common/Components/withSuspense"; +import PVCDetails from "./PVCDetails"; const TenantYAML = withSuspense(React.lazy(() => import("./TenantYAML"))); const TenantSummary = withSuspense(React.lazy(() => import("./TenantSummary"))); @@ -438,6 +439,10 @@ const TenantDetails = ({ path="/namespaces/:tenantNamespace/tenants/:tenantName/pods" component={PodsSummary} /> + import("./DeletePVC"))); interface ITenantVolumesProps { classes: any; setErrorSnackMessage: typeof setErrorSnackMessage; + history: any; match: any; loadingTenant: boolean; setTenantDetailsLoad: typeof setTenantDetailsLoad; @@ -61,6 +63,7 @@ const styles = (theme: Theme) => const TenantVolumes = ({ classes, setErrorSnackMessage, + history, match, loadingTenant, }: ITenantVolumesProps) => { @@ -106,6 +109,13 @@ const TenantVolumes = ({ elementItem.name.includes(filter) ); + const PVCViewAction = (PVC: IPodListElement) => { + history.push( + `/namespaces/${tenantNamespace}/tenants/${tenantName}/pvcs/${PVC.name}` + ); + return; + }; + const closeDeleteModalAndRefresh = (reloadData: boolean) => { setDeleteOpen(false); setLoading(true); @@ -152,7 +162,7 @@ const TenantVolumes = ({