From 52ee9bb49b02ef21fb6b1e857e27b3ebe9dd73e6 Mon Sep 17 00:00:00 2001 From: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> Date: Wed, 15 Sep 2021 21:11:46 -0700 Subject: [PATCH] Reactive Tenant Details and Summary (#1051) Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> --- .../Tenants/TenantDetails/TenantDetails.tsx | 196 ++++++---- .../Tenants/TenantDetails/TenantSummary.tsx | 354 ++++++++++-------- 2 files changed, 323 insertions(+), 227 deletions(-) diff --git a/portal-ui/src/screens/Console/Tenants/TenantDetails/TenantDetails.tsx b/portal-ui/src/screens/Console/Tenants/TenantDetails/TenantDetails.tsx index 0839bd2db..9d36b3c18 100644 --- a/portal-ui/src/screens/Console/Tenants/TenantDetails/TenantDetails.tsx +++ b/portal-ui/src/screens/Console/Tenants/TenantDetails/TenantDetails.tsx @@ -18,7 +18,7 @@ import React, { Fragment, useEffect, useState } from "react"; import { connect } from "react-redux"; import { Link, Redirect, Route, Router, Switch } from "react-router-dom"; import { createStyles, Theme, withStyles } from "@material-ui/core/styles"; -import { IconButton, Tooltip } from "@material-ui/core"; +import { Box, IconButton, Tab, Tabs, Tooltip } from "@material-ui/core"; import get from "lodash/get"; import Grid from "@material-ui/core/Grid"; import { setErrorSnackMessage, setSnackBarMessage } from "../../../../actions"; @@ -242,6 +242,94 @@ const TenantDetails = ({ : classes.greyState; }; + interface ListMenuItem { + label: string; + value: string; + onclick: (val: string) => void; + selected: () => boolean; + } + + const menu: ListMenuItem[] = [ + { + label: "Summary", + value: "summary", + onclick: (val) => { + changeRoute(val); + }, + selected: () => { + return currentTab === "summary"; + }, + }, + { + label: "Metrics", + value: "metrics", + onclick: (val) => { + changeRoute("metrics"); + }, + selected: () => { + return currentTab === "metrics"; + }, + }, + { + label: "Security", + value: "security", + onclick: (val) => { + changeRoute("security"); + }, + selected: () => { + return currentTab === "security"; + }, + }, + { + label: "Pools", + value: "pools", + onclick: (val) => { + changeRoute("pools"); + }, + selected: () => { + return currentTab === "pools"; + }, + }, + { + label: "Pods", + value: "pods", + onclick: (val) => { + changeRoute("pods"); + }, + selected: () => { + return currentTab === "pods" || currentTab === ":podName"; + }, + }, + { + label: "Volumes", + value: "volumes", + onclick: (val) => { + changeRoute("volumes"); + }, + selected: () => { + return currentTab === "volumes"; + }, + }, + { + label: "License", + value: "license", + onclick: (val) => { + changeRoute("license"); + }, + selected: () => { + return currentTab === "license"; + }, + }, + ]; + + let value = menu[0].value; + for (const mli of menu) { + if (mli.selected()) { + value = mli.value; + break; + } + } + return ( {yamlScreenOpen && ( @@ -336,74 +424,48 @@ const TenantDetails = ({ } /> - - - { - changeRoute("summary"); - }} + + + + {menu.map((mli) => { + return ( + { + mli.onclick(mli.value); + }} + > + + + ); + })} + + + + - - - { - changeRoute("metrics"); - }} - > - - - { - changeRoute("security"); - }} - > - - - { - changeRoute("pools"); - }} - > - - - { - changeRoute("pods"); - }} - > - - - { - changeRoute("volumes"); - }} - > - - - { - changeRoute("license"); - }} - > - - - + {menu.map((mli) => { + return ( + { + mli.onclick(mli.value); + }} + /> + ); + })} + + - + centerAlign: { textAlign: "center", }, + detailSection: { + "& div": { + "& b,i": { + minWidth: 80, + display: "block", + float: "left", + }, + "& i": { + fontStyle: "normal", + wordWrap: "break-word", + overflowWrap: "break-word", + }, + "& div": { + clear: "both", + }, + clear: "both", + marginBottom: 2, + }, + }, + ...containerForHeader(theme.spacing(4)), }); @@ -200,83 +220,101 @@ const TenantSummary = ({

Summary

- - - - - - - {loadingTenant ? ( - - - - ) : ( - - - - - - - - - - - - - - {tenant?.endpoints && ( - - - - - - - )} - - - - - - - - - - )} - -
-

Details

-
-
- -
Capacity:{niceBytes(capacity.toString(10))}Clusters:{poolCount}
Instances:{instances}Volumes:{volumes}
Endpoint: - - {tenant?.endpoints.minio} - - Console: - - {tenant?.endpoints.console} - -
MinIO: - -
State:{tenant?.currentState}
+ + + +

Details

+
+
+ +
+ Capacity: + {niceBytes(capacity.toString(10))} +
+
+
+ Instances: + {instances} +
+
+
+ Endpoint: + + + {tenant?.endpoints.minio} + + +
+
+ + +
+ Clusters: + {poolCount} +
+
+
+ Volumes: + {volumes} +
+
+
+ Console: + + + {tenant?.endpoints.console} + + +
+
+ + +
+ MinIO: + + + +
+
+ + +
+ State: + {tenant?.currentState} +
+
+ + - + {loadingTenant ? (
@@ -354,91 +392,87 @@ const TenantSummary = ({ - - - - - - {loadingTenant ? ( - - - - ) : ( - - - - - - - - - - - - - - - - - - - - - - - - - )} - -
-

Features

-
-
- -
Logs: - - Monitoring: - -
MinIO TLS: - - Encryption: - -
Active Directory: - - OpenID: - -
+

Features

+
+ {loadingTenant ? ( + + + + ) : ( + + +
+ Logs: + + + +
+
+
+ MinIO TLS: + + + +
+
+
+ AD/LDAP: + + + +
+
+ + +
+ Monitoring: + + + +
+
+
+ Encryption: + + + +
+
+
+ OpenID: + + + +
+
+ + + )}