From 16474cbd819b4c3e08f538bd8afbd17745929805 Mon Sep 17 00:00:00 2001 From: Alex <33497058+bexsoft@users.noreply.github.com> Date: Wed, 4 May 2022 21:09:47 -0500 Subject: [PATCH] Disabled versioning button when site replication is enabled (#1951) Signed-off-by: Benjamin Perez --- portal-ui/src/icons/AlertIcon.tsx | 32 ++++++++++++++ portal-ui/src/icons/InfoIcon.tsx | 32 ++++++++++++++ portal-ui/src/icons/index.ts | 2 + .../Console/Buckets/ListBuckets/AddBucket.tsx | 43 +++++++++++++++++-- .../screens/Console/Common/IconsScreen.tsx | 12 ++++++ 5 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 portal-ui/src/icons/AlertIcon.tsx create mode 100644 portal-ui/src/icons/InfoIcon.tsx diff --git a/portal-ui/src/icons/AlertIcon.tsx b/portal-ui/src/icons/AlertIcon.tsx new file mode 100644 index 000000000..d33193c2c --- /dev/null +++ b/portal-ui/src/icons/AlertIcon.tsx @@ -0,0 +1,32 @@ +// This file is part of MinIO Console Server +// Copyright (c) 2022 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 * as React from "react"; +import { SVGProps } from "react"; + +const AlertIcon = (props: SVGProps) => ( + + + +); + +export default AlertIcon; diff --git a/portal-ui/src/icons/InfoIcon.tsx b/portal-ui/src/icons/InfoIcon.tsx new file mode 100644 index 000000000..c4805991d --- /dev/null +++ b/portal-ui/src/icons/InfoIcon.tsx @@ -0,0 +1,32 @@ +// This file is part of MinIO Console Server +// Copyright (c) 2022 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 * as React from "react"; +import { SVGProps } from "react"; + +const InfoIcon = (props: SVGProps) => ( + + + +); + +export default InfoIcon; diff --git a/portal-ui/src/icons/index.ts b/portal-ui/src/icons/index.ts index 102d1cb90..a5b70e0c5 100644 --- a/portal-ui/src/icons/index.ts +++ b/portal-ui/src/icons/index.ts @@ -190,3 +190,5 @@ export { default as RemoveAllIcon } from "./RemoveAllIcon"; export { default as CancelledIcon } from "./CancelledIcon"; export { default as EditTagIcon } from "./EditTagIcon"; export { default as LinkIcon } from "./LinkIcon"; +export { default as AlertIcon } from "./AlertIcon"; +export { default as InfoIcon } from "./InfoIcon"; diff --git a/portal-ui/src/screens/Console/Buckets/ListBuckets/AddBucket.tsx b/portal-ui/src/screens/Console/Buckets/ListBuckets/AddBucket.tsx index 91803126e..f10f7bc72 100644 --- a/portal-ui/src/screens/Console/Buckets/ListBuckets/AddBucket.tsx +++ b/portal-ui/src/screens/Console/Buckets/ListBuckets/AddBucket.tsx @@ -47,13 +47,14 @@ import FormSwitchWrapper from "../../Common/FormComponents/FormSwitchWrapper/For import { ErrorResponseHandler } from "../../../../common/types"; import PageHeader from "../../Common/PageHeader/PageHeader"; import BackLink from "../../../../common/BackLink"; -import { BucketsIcon } from "../../../../icons"; +import { BucketsIcon, InfoIcon } from "../../../../icons"; import { setErrorSnackMessage } from "../../../../actions"; import PageLayout from "../../Common/Layout/PageLayout"; import InputUnitMenu from "../../Common/FormComponents/InputUnitMenu/InputUnitMenu"; import FormLayout from "../../Common/FormLayout"; import HelpBox from "../../../../common/HelpBox"; import SectionTitle from "../../Common/SectionTitle"; +import { SRInfoStateType } from "../../../../types"; const styles = (theme: Theme) => createStyles({ @@ -70,6 +71,20 @@ const styles = (theme: Theme) => padding: 8, borderRadius: 3, }, + alertVersioning: { + border: "#E2E2E2 1px solid", + backgroundColor: "#FBFAFA", + borderRadius: 3, + display: "flex", + alignItems: "center", + padding: "10px", + color: "#767676", + "& > .min-icon ": { + width: 20, + height: 20, + marginRight: 10, + }, + }, title: { marginBottom: 8, }, @@ -112,6 +127,7 @@ interface IAddBucketProps { retentionUnit: string; retentionValidity: number; distributedSetup: boolean; + siteReplicationInfo: SRInfoStateType; } const AddBucket = ({ @@ -140,6 +156,7 @@ const AddBucket = ({ retentionUnit, retentionValidity, distributedSetup, + siteReplicationInfo, }: IAddBucketProps) => { const [addLoading, setAddLoading] = useState(false); const [sendEnabled, setSendEnabled] = useState(false); @@ -155,7 +172,10 @@ const AddBucket = ({ let request: MakeBucketRequest = { name: bucketName, - versioning: distributedSetup ? versioningEnabled : false, + versioning: + distributedSetup && !siteReplicationInfo.enabled + ? versioningEnabled + : false, locking: distributedSetup ? lockingEnabled : false, }; @@ -346,6 +366,16 @@ const AddBucket = ({ + {siteReplicationInfo.enabled && ( + +
+
+ Versioning setting cannot be changed as + cluster replication is enabled for this site. +
+
+
+ )}
@@ -367,7 +401,7 @@ const AddBucket = ({ checked={lockingEnabled} onChange={(event: React.ChangeEvent) => { enableObjectLocking(event.target.checked); - if (event.target.checked) { + if (event.target.checked && !siteReplicationInfo.enabled) { addBucketVersioned(true); } }} @@ -525,6 +559,7 @@ const mapState = (state: AppState) => ({ retentionUnit: state.buckets.addBucketRetentionUnit, retentionValidity: state.buckets.addBucketRetentionValidity, distributedSetup: state.system.distributedSetup, + siteReplicationInfo: state.system.siteReplicationInfo, }); const connector = connect(mapState, { diff --git a/portal-ui/src/screens/Console/Common/IconsScreen.tsx b/portal-ui/src/screens/Console/Common/IconsScreen.tsx index eb52501c7..51bd07761 100644 --- a/portal-ui/src/screens/Console/Common/IconsScreen.tsx +++ b/portal-ui/src/screens/Console/Common/IconsScreen.tsx @@ -163,6 +163,12 @@ const IconsScreen = ({ classes }: IIconsScreenSimple) => { AddNewTagIcon + + +
+ AlertIcon +
+
@@ -625,6 +631,12 @@ const IconsScreen = ({ classes }: IIconsScreenSimple) => { IAMPoliciesIcon
+ + +
+ InfoIcon +
+