diff --git a/portal-ui/src/screens/Console/Buckets/ListBuckets/BucketListItem.tsx b/portal-ui/src/screens/Console/Buckets/ListBuckets/BucketListItem.tsx index cef1208b8..cbea13c97 100644 --- a/portal-ui/src/screens/Console/Buckets/ListBuckets/BucketListItem.tsx +++ b/portal-ui/src/screens/Console/Buckets/ListBuckets/BucketListItem.tsx @@ -13,7 +13,8 @@ // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -import React from "react"; +import React, {Fragment} from "react"; +import get from "lodash/get"; import { Theme } from "@mui/material/styles"; import createStyles from "@mui/styles/createStyles"; import withStyles from "@mui/styles/withStyles"; @@ -26,7 +27,7 @@ import { } from "../../../../icons"; import { Bucket } from "../types"; import { Box, Grid, Typography } from "@mui/material"; -import { niceBytes, prettyNumber } from "../../../../common/utils"; +import {calculateBytes, niceBytes, prettyNumber} from "../../../../common/utils"; import CheckboxWrapper from "../../Common/FormComponents/CheckboxWrapper/CheckboxWrapper"; import { Link } from "react-router-dom"; import { @@ -163,7 +164,6 @@ const styles = (theme: Theme) => interface IBucketListItem { bucket: Bucket; classes: any; - onDelete: (bucketName: string) => void; onSelect: (e: React.ChangeEvent) => void; selected: boolean; bulkSelect: boolean; @@ -172,7 +172,6 @@ interface IBucketListItem { const BucketListItem = ({ classes, bucket, - onDelete, onSelect, selected, bulkSelect, @@ -181,6 +180,10 @@ const BucketListItem = ({ const usageScalar = usage.split(" ")[0]; const usageUnit = usage.split(" ")[1]; + const quota = get(bucket, "details.quota.quota", "0"); + const quotaForString = calculateBytes(quota); + + const accessToStr = (bucket: Bucket): string => { if (bucket.rw_access?.read && !bucket.rw_access?.write) { return "R"; @@ -287,6 +290,11 @@ const BucketListItem = ({
{usageScalar} {usageUnit} + {quota !== "0" && ( + + {" "}/{" "}{quotaForString.total}{quotaForString.unit} + + )}
diff --git a/portal-ui/src/screens/Console/Buckets/ListBuckets/ListBuckets.tsx b/portal-ui/src/screens/Console/Buckets/ListBuckets/ListBuckets.tsx index 9c2a03572..ac36ad340 100644 --- a/portal-ui/src/screens/Console/Buckets/ListBuckets/ListBuckets.tsx +++ b/portal-ui/src/screens/Console/Buckets/ListBuckets/ListBuckets.tsx @@ -23,7 +23,6 @@ import { LinearProgress } from "@mui/material"; import Grid from "@mui/material/Grid"; import { Bucket, BucketList } from "../types"; import { AddIcon, BucketsIcon, LifecycleConfigIcon } from "../../../../icons"; -import { AppState } from "../../../../store"; import { setErrorSnackMessage } from "../../../../actions"; import { containerForHeader, @@ -31,12 +30,10 @@ import { } from "../../Common/FormComponents/common/styleLibrary"; import { ErrorResponseHandler } from "../../../../common/types"; import api from "../../../../common/api"; -import DeleteBucket from "./DeleteBucket"; import PageHeader from "../../Common/PageHeader/PageHeader"; import BucketListItem from "./BucketListItem"; import BulkReplicationModal from "./BulkReplicationModal"; import HelpBox from "../../../../common/HelpBox"; -import { ISessionResponse } from "../../types"; import RefreshIcon from "../../../../icons/RefreshIcon"; import AButton from "../../Common/AButton/AButton"; import MultipleBucketsIcon from "../../../../icons/MultipleBucketsIcon"; @@ -85,19 +82,15 @@ interface IListBucketsProps { classes: any; history: any; setErrorSnackMessage: typeof setErrorSnackMessage; - session: ISessionResponse; } const ListBuckets = ({ classes, history, setErrorSnackMessage, - session, }: IListBucketsProps) => { const [records, setRecords] = useState([]); const [loading, setLoading] = useState(true); - const [deleteOpen, setDeleteOpen] = useState(false); - const [selectedBucket, setSelectedBucket] = useState(""); const [filterBuckets, setFilterBuckets] = useState(""); const [selectedBuckets, setSelectedBuckets] = useState([]); const [replicationModalOpen, setReplicationModalOpen] = @@ -125,28 +118,11 @@ const ListBuckets = ({ } }, [loading, setErrorSnackMessage]); - const closeDeleteModalAndRefresh = (refresh: boolean) => { - setDeleteOpen(false); - if (refresh) { - setLoading(true); - setSelectedBuckets([]); - } - }; - - const confirmDeleteBucket = (bucket: string) => { - setDeleteOpen(true); - setSelectedBucket(bucket); - }; - const filteredRecords = records.filter((b: Bucket) => { if (filterBuckets === "") { return true; } else { - if (b.name.indexOf(filterBuckets) >= 0) { - return true; - } else { - return false; - } + return b.name.indexOf(filterBuckets) >= 0; } }); @@ -191,7 +167,6 @@ const ListBuckets = ({ return ( - {deleteOpen && ( - { - closeDeleteModalAndRefresh(refresh); - }} - /> - )} {replicationModalOpen && ( ({ - session: state.console.session, -}); - -const connector = connect(mapState, { +const connector = connect(null, { setErrorSnackMessage, }); diff --git a/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjects.tsx b/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjects.tsx index cf02f1fd6..adebb06ec 100644 --- a/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjects.tsx +++ b/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjects.tsx @@ -24,7 +24,6 @@ import React, { } from "react"; import { connect } from "react-redux"; import { useDropzone } from "react-dropzone"; - import { Theme } from "@mui/material/styles"; import createStyles from "@mui/styles/createStyles"; import withStyles from "@mui/styles/withStyles"; @@ -74,7 +73,7 @@ import { setErrorSnackMessage, setSnackBarMessage, } from "../../../../../../actions"; -import { BucketInfo, BucketVersioning } from "../../../types"; +import { BucketInfo, BucketQuota, BucketVersioning } from "../../../types"; import { ErrorResponseHandler } from "../../../../../../common/types"; import ScreenTitle from "../../../../Common/ScreenTitle/ScreenTitle"; @@ -292,6 +291,7 @@ const ListObjects = ({ const [selectedInternalPaths, setSelectedInternalPaths] = useState< string | null >(null); + const [quota, setQuota] = useState(null); const internalPaths = get(match.params, "subpaths", ""); const bucketName = match.params["bucketName"]; @@ -327,6 +327,25 @@ const ListObjects = ({ } }, [selectedObjects]); + useEffect(() => { + if (!quota) { + api + .invoke("GET", `/api/v1/buckets/${bucketName}/quota`) + .then((res: BucketQuota) => { + let quotaVals = null; + + if (res.quota) { + quotaVals = res; + } + + setQuota(quotaVals); + }) + .catch(() => { + setQuota(null); + }); + } + }, [quota, bucketName]); + const displayDeleteObject = hasPermission(bucketName, [ IAM_SCOPES.S3_DELETE_OBJECT, ]); @@ -1176,7 +1195,10 @@ const ListObjects = ({ {bucketInfo.size && ( {niceBytesInt(bucketInfo.size)} )} - {bucketInfo.size && bucketInfo.objects ? " / " : ""} + {bucketInfo.size && quota && ( + / {niceBytesInt(quota.quota)} + )} + {bucketInfo.size && bucketInfo.objects ? " - " : ""} {bucketInfo.objects && ( {bucketInfo.objects} Object