Skip to content

Commit cf27e20

Browse files
authored
Add the current state to tenant details. Fix Enable/Disable Encryption (#749)
* Add the current state to tenant details Signed-off-by: Daniel Valdivia <[email protected]> * Fix the Enable Signed-off-by: Daniel Valdivia <[email protected]> * Linting Signed-off-by: Daniel Valdivia <[email protected]>
1 parent 3b10eb5 commit cf27e20

File tree

3 files changed

+54
-38
lines changed

3 files changed

+54
-38
lines changed

portal-ui/src/screens/Console/Buckets/ViewBucket/EnableBucketEncryption.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
import React, { useState } from "react";
17+
import React, { useEffect, useState } from "react";
1818
import { connect } from "react-redux";
1919
import Grid from "@material-ui/core/Grid";
2020
import { Button, LinearProgress } from "@material-ui/core";
@@ -25,6 +25,7 @@ import api from "../../../../common/api";
2525
import ModalWrapper from "../../Common/ModalWrapper/ModalWrapper";
2626
import InputBoxWrapper from "../../Common/FormComponents/InputBoxWrapper/InputBoxWrapper";
2727
import SelectWrapper from "../../Common/FormComponents/SelectWrapper/SelectWrapper";
28+
import { BucketEncryptionInfo } from "../types";
2829

2930
const styles = (theme: Theme) =>
3031
createStyles({
@@ -46,6 +47,7 @@ interface IEnableBucketEncryptionProps {
4647
classes: any;
4748
open: boolean;
4849
encryptionEnabled: boolean;
50+
encryptionCfg: BucketEncryptionInfo | null;
4951
selectedBucket: string;
5052
closeModalAndRefresh: () => void;
5153
setModalErrorSnackMessage: typeof setModalErrorSnackMessage;
@@ -55,15 +57,25 @@ const EnableBucketEncryption = ({
5557
classes,
5658
open,
5759
encryptionEnabled,
60+
encryptionCfg,
5861
selectedBucket,
5962
closeModalAndRefresh,
6063
setModalErrorSnackMessage,
6164
}: IEnableBucketEncryptionProps) => {
6265
const [loading, setLoading] = useState<boolean>(false);
6366
const [kmsKeyID, setKmsKeyID] = useState<string>("");
64-
const [encryptionType, setEncryptionType] = useState<string>(
65-
encryptionEnabled ? "sse-s3" : "disabled"
66-
);
67+
const [encryptionType, setEncryptionType] = useState<string>("disabled");
68+
69+
useEffect(() => {
70+
if (encryptionCfg) {
71+
if (encryptionCfg.algorithm === "AES256") {
72+
setEncryptionType("sse-s3");
73+
} else {
74+
setEncryptionType("sse-kms");
75+
setKmsKeyID(encryptionCfg.kmsMasterKeyID);
76+
}
77+
}
78+
}, []);
6779

6880
const enableBucketEncryption = (event: React.FormEvent) => {
6981
event.preventDefault();

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

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,17 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
import React, { useEffect, useState, Fragment } from "react";
17+
import React, { Fragment, useEffect, useState } from "react";
1818
import { connect } from "react-redux";
1919
import { createStyles, Theme, withStyles } from "@material-ui/core/styles";
20-
import { Button, IconButton, TextField } from "@material-ui/core";
20+
import { Button, TextField } from "@material-ui/core";
2121
import * as reactMoment from "react-moment";
2222
import get from "lodash/get";
2323
import Paper from "@material-ui/core/Paper";
2424
import Grid from "@material-ui/core/Grid";
2525
import Tabs from "@material-ui/core/Tabs";
2626
import Tab from "@material-ui/core/Tab";
2727
import CircularProgress from "@material-ui/core/CircularProgress";
28-
import Checkbox from "@material-ui/core/Checkbox";
2928
import Typography from "@material-ui/core/Typography";
3029
import api from "../../../../common/api";
3130
import {
@@ -65,7 +64,6 @@ import TableWrapper from "../../Common/TableWrapper/TableWrapper";
6564
import AddReplicationModal from "./AddReplicationModal";
6665
import PageHeader from "../../Common/PageHeader/PageHeader";
6766
import EnableBucketEncryption from "./EnableBucketEncryption";
68-
import PencilIcon from "../../Common/TableWrapper/TableActionIcons/PencilIcon";
6967
import EnableVersioningModal from "./EnableVersioningModal";
7068
import UsageIcon from "../../../../icons/UsageIcon";
7169
import AddPolicy from "../../Policies/AddPolicy";
@@ -265,6 +263,8 @@ const ViewBucket = ({
265263
const [isVersioned, setIsVersioned] = useState<boolean>(false);
266264
const [hasObjectLocking, setHasObjectLocking] = useState<boolean>(false);
267265
const [encryptionEnabled, setEncryptionEnabled] = useState<boolean>(false);
266+
const [encryptionCfg, setEncryptionCfg] =
267+
useState<BucketEncryptionInfo | null>(null);
268268
const [retentionConfigOpen, setRetentionConfigOpen] =
269269
useState<boolean>(false);
270270
const [policyEdit, setPolicyEdit] = useState<any>(null);
@@ -477,6 +477,7 @@ const ViewBucket = ({
477477
.then((res: BucketEncryptionInfo) => {
478478
if (res.algorithm) {
479479
setEncryptionEnabled(true);
480+
setEncryptionCfg(res);
480481
}
481482
setLoadingEncryption(false);
482483
})
@@ -485,6 +486,7 @@ const ViewBucket = ({
485486
err === "The server side encryption configuration was not found"
486487
) {
487488
setEncryptionEnabled(false);
489+
setEncryptionCfg(null);
488490
}
489491
setLoadingEncryption(false);
490492
});
@@ -718,6 +720,7 @@ const ViewBucket = ({
718720
open={enableEncryptionScreenOpen}
719721
selectedBucket={bucketName}
720722
encryptionEnabled={encryptionEnabled}
723+
encryptionCfg={encryptionCfg}
721724
closeModalAndRefresh={closeEnableBucketEncryption}
722725
/>
723726
)}
@@ -846,15 +849,23 @@ const ViewBucket = ({
846849
</td>
847850
<td>Encryption:</td>
848851
<td>
849-
<Checkbox
850-
color="primary"
851-
className={classes.encCheckbox}
852-
inputProps={{
853-
"aria-label": "secondary checkbox",
854-
}}
855-
onChange={(event) => handleEncryptionCheckbox(event)}
856-
checked={encryptionEnabled}
857-
/>
852+
{loadingEncryption ? (
853+
<CircularProgress
854+
color="primary"
855+
size={16}
856+
variant="indeterminate"
857+
/>
858+
) : (
859+
<Button
860+
color="primary"
861+
className={classes.anchorButton}
862+
onClick={() => {
863+
setEnableEncryptionScreenOpen(true);
864+
}}
865+
>
866+
{encryptionEnabled ? "Enabled" : "Disabled"}
867+
</Button>
868+
)}
858869
</td>
859870
</tr>
860871
<tr>
@@ -880,10 +891,10 @@ const ViewBucket = ({
880891
</Grid>
881892
<Grid xs={3} className={classes.reportedUsage}>
882893
<Grid container direction="row" alignItems="center">
883-
<Grid item className={classes.icon}>
894+
<Grid item className={classes.icon} xs={2}>
884895
<UsageIcon />
885896
</Grid>
886-
<Grid item>
897+
<Grid item xs={10}>
887898
<Typography className={classes.elementTitle}>
888899
Reported Usage
889900
</Typography>
@@ -914,17 +925,13 @@ const ViewBucket = ({
914925
/>
915926
) : (
916927
<Fragment>
917-
{isVersioned && !loadingVersioning ? "Yes" : "No"}
918-
&nbsp;
919-
<IconButton
928+
<Button
920929
color="primary"
921-
aria-label="retention"
922-
size="small"
923-
className={classes.propertiesIcon}
930+
className={classes.anchorButton}
924931
onClick={setBucketVersioning}
925932
>
926-
<PencilIcon active={true} />
927-
</IconButton>
933+
{isVersioned ? "Enabled" : "Disabled"}
934+
</Button>
928935
</Fragment>
929936
)}
930937
</td>
@@ -954,18 +961,15 @@ const ViewBucket = ({
954961
/>
955962
) : (
956963
<Fragment>
957-
&nbsp;
958-
<IconButton
964+
<Button
959965
color="primary"
960-
aria-label="retention"
961-
size="small"
962-
className={classes.propertiesIcon}
966+
className={classes.anchorButton}
963967
onClick={() => {
964968
setRetentionConfigOpen(true);
965969
}}
966970
>
967-
<PencilIcon active={true} />
968-
</IconButton>
971+
Configure
972+
</Button>
969973
</Fragment>
970974
)}
971975
</td>

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import {
3333
Menu,
3434
MenuItem,
3535
TextField,
36-
Typography,
3736
} from "@material-ui/core";
3837
import Tabs from "@material-ui/core/Tabs";
3938
import Tab from "@material-ui/core/Tab";
@@ -49,14 +48,11 @@ import { IPodListElement, IPool, ITenant } from "../ListTenants/types";
4948
import PageHeader from "../../Common/PageHeader/PageHeader";
5049
import UsageBarWrapper from "../../Common/UsageBarWrapper/UsageBarWrapper";
5150
import UpdateTenantModal from "./UpdateTenantModal";
52-
import PencilIcon from "../../Common/TableWrapper/TableActionIcons/PencilIcon";
5351
import { LicenseInfo } from "../../License/types";
5452
import { Link } from "react-router-dom";
5553
import { setErrorSnackMessage } from "../../../../actions";
56-
import Moment from "react-moment";
5754
import MoreVertIcon from "@material-ui/icons/MoreVert";
5855
import TenantYAML from "./TenantYAML";
59-
import Checkbox from "@material-ui/core/Checkbox";
6056
import SubnetLicenseTenant from "./SubnetLicenseTenant";
6157
import InputAdornment from "@material-ui/core/InputAdornment";
6258
import SearchIcon from "@material-ui/icons/Search";
@@ -510,6 +506,10 @@ const TenantDetails = ({
510506
</React.Fragment>
511507
)}
512508
</tr>
509+
<tr>
510+
<td>State:</td>
511+
<td colSpan={3}>{tenant?.currentState}</td>
512+
</tr>
513513
</table>
514514
</Grid>
515515
<Grid item xs={4}>

0 commit comments

Comments
 (0)