|
16 | 16 |
|
17 | 17 | import React, { Fragment, useEffect } from "react";
|
18 | 18 | import Grid from "@mui/material/Grid";
|
19 |
| -import { Button, LinearProgress, Box } from "@mui/material"; |
| 19 | +import { Box, Button, LinearProgress } from "@mui/material"; |
20 | 20 | import { Theme } from "@mui/material/styles";
|
| 21 | +import { useNavigate } from "react-router-dom"; |
21 | 22 | import createStyles from "@mui/styles/createStyles";
|
22 | 23 | import withStyles from "@mui/styles/withStyles";
|
23 | 24 | import { containerForHeader } from "../../../Common/FormComponents/common/styleLibrary";
|
@@ -51,7 +52,8 @@ import {
|
51 | 52 | } from "./addBucketsSlice";
|
52 | 53 | import { addBucketAsync } from "./addBucketThunks";
|
53 | 54 | import AddBucketName from "./AddBucketName";
|
54 |
| -import { useNavigate } from "react-router-dom"; |
| 55 | +import { IAM_SCOPES } from "../../../../../common/SecureComponent/permissions"; |
| 56 | +import { hasPermission } from "../../../../../common/SecureComponent"; |
55 | 57 |
|
56 | 58 | const styles = (theme: Theme) =>
|
57 | 59 | createStyles({
|
@@ -142,6 +144,11 @@ const AddBucket = ({ classes }: IsetProps) => {
|
142 | 144 | (state: AppState) => state.addBucket.navigateTo
|
143 | 145 | );
|
144 | 146 |
|
| 147 | + const lockingAllowed = hasPermission("*", [ |
| 148 | + IAM_SCOPES.S3_PUT_BUCKET_VERSIONING, |
| 149 | + IAM_SCOPES.S3_PUT_BUCKET_OBJECT_LOCK_CONFIGURATION, |
| 150 | + ]); |
| 151 | + |
145 | 152 | const resForm = () => {
|
146 | 153 | dispatch(resetForm());
|
147 | 154 | };
|
@@ -178,15 +185,31 @@ const AddBucket = ({ classes }: IsetProps) => {
|
178 | 185 | <br />
|
179 | 186 | <b>Object Locking</b> prevents objects from being deleted.
|
180 | 187 | Required to support retention and legal hold. Can only be
|
181 |
| - enabled at bucket creation. |
| 188 | + enabled at bucket creation.{" "} |
| 189 | + {!lockingAllowed ? ( |
| 190 | + <Fragment> |
| 191 | + <br /> |
| 192 | + <span> |
| 193 | + To enable this option{" "} |
| 194 | + <i>s3:PutBucketObjectLockConfiguration</i> and{" "} |
| 195 | + <i>s3:PutBucketVersioning</i> permissions must be set. |
| 196 | + </span> |
| 197 | + </Fragment> |
| 198 | + ) : ( |
| 199 | + "" |
| 200 | + )} |
182 | 201 | <br />
|
183 | 202 | <br />
|
184 | 203 | <b>Quota</b> limits the amount of data in the bucket.
|
185 |
| - <br /> |
186 |
| - <br /> |
187 |
| - <b>Retention</b> imposes rules to prevent object deletion for |
188 |
| - a period of time. Versioning must be enabled in order to set |
189 |
| - bucket retention policies. |
| 204 | + {lockingAllowed && ( |
| 205 | + <Fragment> |
| 206 | + <br /> |
| 207 | + <br /> |
| 208 | + <b>Retention</b> imposes rules to prevent object deletion |
| 209 | + for a period of time. Versioning must be enabled in order |
| 210 | + to set bucket retention policies. |
| 211 | + </Fragment> |
| 212 | + )} |
190 | 213 | <br />
|
191 | 214 | <br />
|
192 | 215 | <b>Bucket Naming Rules</b>
|
@@ -340,7 +363,9 @@ const AddBucket = ({ classes }: IsetProps) => {
|
340 | 363 | value="locking"
|
341 | 364 | id="locking"
|
342 | 365 | name="locking"
|
343 |
| - disabled={lockingFieldDisabled || !distributedSetup} |
| 366 | + disabled={ |
| 367 | + lockingFieldDisabled || !distributedSetup || !lockingAllowed |
| 368 | + } |
344 | 369 | checked={lockingEnabled}
|
345 | 370 | onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
|
346 | 371 | dispatch(setEnableObjectLocking(event.target.checked));
|
@@ -399,7 +424,7 @@ const AddBucket = ({ classes }: IsetProps) => {
|
399 | 424 | </Grid>
|
400 | 425 | </React.Fragment>
|
401 | 426 | )}
|
402 |
| - {versioningEnabled && distributedSetup && ( |
| 427 | + {versioningEnabled && distributedSetup && lockingAllowed && ( |
403 | 428 | <Grid item xs={12}>
|
404 | 429 | <FormSwitchWrapper
|
405 | 430 | value="bucket_retention"
|
|
0 commit comments