Skip to content

Commit 04adf25

Browse files
authored
Add csr under tenant details (#1938)
1 parent 8f77261 commit 04adf25

File tree

4 files changed

+151
-0
lines changed

4 files changed

+151
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ export const IAM_PAGES = {
210210
"/namespaces/:tenantNamespace/tenants/:tenantName/logging",
211211
NAMESPACE_TENANT_EVENTS:
212212
"/namespaces/:tenantNamespace/tenants/:tenantName/events",
213+
NAMESPACE_TENANT_CSR:
214+
"/namespaces/:tenantNamespace/tenants/:tenantName/csr",
213215
};
214216

215217
// roles

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,11 @@ const Console = ({ classes }: IConsoleProps) => {
556556
path: IAM_PAGES.NAMESPACE_TENANT_EVENTS,
557557
forceDisplay: true,
558558
},
559+
{
560+
component: TenantDetails,
561+
path: IAM_PAGES.NAMESPACE_TENANT_CSR,
562+
forceDisplay: true,
563+
},
559564
{
560565
component: License,
561566
path: IAM_PAGES.LICENSE,
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
// This file is part of MinIO Console Server
2+
// Copyright (c) 2022 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, { useEffect, useState, Fragment } from "react";
18+
import {useDispatch} from "react-redux";
19+
import { Theme } from "@mui/material/styles";
20+
import createStyles from "@mui/styles/createStyles";
21+
import withStyles from "@mui/styles/withStyles";
22+
import {
23+
setErrorSnackMessage,
24+
} from "../../../../systemSlice";
25+
import {
26+
actionsTray,
27+
containerForHeader,
28+
searchField, tableStyles,
29+
} from "../../Common/FormComponents/common/styleLibrary";
30+
import { ErrorResponseHandler } from "../../../../common/types";
31+
import api from "../../../../common/api";
32+
import TableContainer from "@mui/material/TableContainer";
33+
import Paper from "@mui/material/Paper";
34+
import Table from "@mui/material/Table";
35+
import TableHead from "@mui/material/TableHead";
36+
import TableRow from "@mui/material/TableRow";
37+
import TableCell from "@mui/material/TableCell";
38+
import TableBody from "@mui/material/TableBody";
39+
40+
interface ITenantCSRProps {
41+
classes: any;
42+
match: any;
43+
loadingTenant: boolean;
44+
setErrorSnackMessage: typeof setErrorSnackMessage;
45+
}
46+
47+
const styles = (theme: Theme) =>
48+
createStyles({
49+
tableWrapper: {
50+
height: "450px",
51+
},
52+
...actionsTray,
53+
...searchField,
54+
...tableStyles,
55+
...containerForHeader(theme.spacing(4)),
56+
});
57+
58+
const TenantCSR = ({
59+
classes,
60+
match,
61+
loadingTenant,
62+
setErrorSnackMessage,
63+
}: ITenantCSRProps) => {
64+
const [loading, setLoading] = useState<boolean>(true);
65+
const tenantName = match.params["tenantName"];
66+
const tenantNamespace = match.params["tenantNamespace"];
67+
const [csrStatus] = useState([""]);
68+
const [csrName] = useState([""]);
69+
const [csrAnnotations] = useState([""]);
70+
const dispatch = useDispatch();
71+
useEffect(() => {
72+
if (loadingTenant) {
73+
setLoading(true);
74+
}
75+
}, [loadingTenant]);
76+
77+
useEffect(() => {
78+
if (loading) {
79+
api
80+
.invoke(
81+
"GET",
82+
`/api/v1/namespaces/${tenantNamespace}/tenants/${tenantName}/csr`
83+
)
84+
.then((res) => {
85+
for (var _i = 0; _i < res.csrElement.length; _i++) {
86+
var entry = res.csrElement[_i];
87+
csrStatus.push(entry.status)
88+
csrName.push(entry.name)
89+
csrAnnotations.push(entry.annotations)
90+
}
91+
setLoading(false);
92+
})
93+
.catch((err: ErrorResponseHandler) => {
94+
dispatch(setErrorSnackMessage(err));
95+
});
96+
}
97+
}, [loading, tenantNamespace, tenantName, setErrorSnackMessage, csrAnnotations, csrName, csrStatus, dispatch]);
98+
99+
return (
100+
<Fragment>
101+
<h1 className={classes.sectionTitle}>Certificate Signing Requests</h1>
102+
<TableContainer component={Paper}>
103+
<Table aria-label="collapsible table">
104+
<TableHead>
105+
<TableRow>
106+
<TableCell>Name</TableCell>
107+
<TableCell>Status</TableCell>
108+
<TableCell>Annotation</TableCell>
109+
<TableCell />
110+
</TableRow>
111+
</TableHead>
112+
<TableBody>
113+
<TableRow>
114+
<TableCell>
115+
{csrName.map((csrName)=><p>{csrName}</p>)}
116+
</TableCell>
117+
<TableCell>
118+
{csrStatus.map((csrStatus)=><p>{csrStatus}</p>)}
119+
</TableCell>
120+
<TableCell>
121+
{csrAnnotations.map((csrAnnotations)=><p>{csrAnnotations}</p>)}
122+
</TableCell>
123+
</TableRow>
124+
</TableBody>
125+
</Table>
126+
</TableContainer>
127+
</Fragment>
128+
);
129+
};
130+
131+
export default withStyles(styles)(TenantCSR);

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const PoolsSummary = withSuspense(React.lazy(() => import("./PoolsSummary")));
6363
const PodsSummary = withSuspense(React.lazy(() => import("./PodsSummary")));
6464
const TenantLogging = withSuspense(React.lazy(() => import("./TenantLogging")));
6565
const TenantEvents = withSuspense(React.lazy(() => import("./TenantEvents")));
66+
const TenantCSR = withSuspense(React.lazy(() => import("./TenantCSR")));
6667
const VolumesSummary = withSuspense(
6768
React.lazy(() => import("./VolumesSummary"))
6869
);
@@ -493,6 +494,10 @@ const TenantDetails = ({ classes, match, history }: ITenantDetailsProps) => {
493494
path={IAM_PAGES.NAMESPACE_TENANT_EVENTS}
494495
component={TenantEvents}
495496
/>
497+
<Route
498+
path={IAM_PAGES.NAMESPACE_TENANT_CSR}
499+
component={TenantCSR}
500+
/>
496501
<Route
497502
path={IAM_PAGES.NAMESPACE_TENANT}
498503
component={() => (
@@ -604,6 +609,14 @@ const TenantDetails = ({ classes, match, history }: ITenantDetailsProps) => {
604609
to: getRoutePath("license"),
605610
},
606611
}}
612+
{{
613+
tabConfig: {
614+
label: "Certificate Signing Request",
615+
value: "csr",
616+
component: Link,
617+
to: getRoutePath("csr"),
618+
}
619+
}}
607620
</VerticalTabs>
608621
</PageLayout>
609622
</Fragment>

0 commit comments

Comments
 (0)