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 ea6b9a8cc..0d00d7fbc 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 @@ -359,9 +359,26 @@ const ListObjects = () => { const internalPaths = pathSegment.length === 2 ? pathSegment[1] : ""; const bucketName = params.bucketName || ""; + const pageTitle = decodeURLString(internalPaths); + const currentPath = pageTitle.split("/").filter((i: string) => i !== ""); + + let uploadPath = [bucketName]; + if (currentPath.length > 0) { + uploadPath = uploadPath.concat(currentPath); + } + const fileUpload = useRef(null); const folderUpload = useRef(null); + const canDownload = hasPermission(bucketName, [IAM_SCOPES.S3_GET_OBJECT]); + const canDelete = hasPermission(bucketName, [IAM_SCOPES.S3_DELETE_OBJECT]); + const canUpload = hasPermission( + uploadPath, + [IAM_SCOPES.S3_PUT_OBJECT], + true, + true + ); + useEffect(() => { if (folderUpload.current !== null) { folderUpload.current.setAttribute("directory", ""); @@ -1179,9 +1196,6 @@ const ListObjects = () => { dispatch(setLoadingObjectsList(true)); }; - const pageTitle = decodeURLString(internalPaths); - const currentPath = pageTitle.split("/").filter((i: string) => i !== ""); - const plSelect = filteredRecords; const sortASC = plSelect.sort(sortListObjects(currentSortField)); @@ -1231,14 +1245,6 @@ const ListObjects = () => { }); } }; - let uploadPath = [bucketName]; - if (currentPath.length > 0) { - uploadPath = uploadPath.concat(currentPath); - } - - const canDownload = hasPermission(bucketName, [IAM_SCOPES.S3_GET_OBJECT]); - const canDelete = hasPermission(bucketName, [IAM_SCOPES.S3_DELETE_OBJECT]); - const canUpload = hasPermission(uploadPath, [IAM_SCOPES.S3_PUT_OBJECT]); const onClosePanel = (forceRefresh: boolean) => { dispatch(setSelectedObjectView(null));