@@ -340,20 +340,20 @@ const ListObjects = () => {
340
340
putObjectPermScopes
341
341
) ;
342
342
343
- const canDownload = hasPermission ( bucketName , [
344
- IAM_SCOPES . S3_GET_OBJECT ,
345
- IAM_SCOPES . S3_GET_ACTIONS ,
346
- ] ) ;
347
- const canDelete = hasPermission ( bucketName , [ IAM_SCOPES . S3_DELETE_OBJECT ] ) ;
343
+ const canDownload = hasPermission (
344
+ [ pathAsResourceInPolicy , ...sessionGrantWildCards ] ,
345
+ [ IAM_SCOPES . S3_GET_OBJECT , IAM_SCOPES . S3_GET_ACTIONS ]
346
+ ) ;
347
+ const canDelete = hasPermission (
348
+ [ pathAsResourceInPolicy , ...sessionGrantWildCards ] ,
349
+ [ IAM_SCOPES . S3_DELETE_OBJECT ]
350
+ ) ;
348
351
const canUpload =
349
352
hasPermission (
350
353
[ pathAsResourceInPolicy , ...sessionGrantWildCards ] ,
351
354
putObjectPermScopes
352
355
) || anonymousMode ;
353
356
354
- const displayDeleteObject = hasPermission ( bucketName , [
355
- IAM_SCOPES . S3_DELETE_OBJECT ,
356
- ] ) ;
357
357
const canSetAnonymousAccess = hasPermission ( bucketName , [
358
358
IAM_SCOPES . S3_GET_BUCKET_POLICY ,
359
359
IAM_SCOPES . S3_PUT_BUCKET_POLICY ,
@@ -393,22 +393,22 @@ const ListObjects = () => {
393
393
if ( selectedObjects . length === 1 ) {
394
394
const objectName = selectedObjects [ 0 ] ;
395
395
396
- if ( extensionPreview ( objectName ) !== "none" ) {
396
+ if ( extensionPreview ( objectName ) !== "none" && canDownload ) {
397
397
setCanPreviewFile ( true ) ;
398
398
} else {
399
399
setCanPreviewFile ( false ) ;
400
400
}
401
401
402
- if ( objectName . endsWith ( "/" ) ) {
403
- setCanShareFile ( false ) ;
404
- } else {
402
+ if ( objectName . endsWith ( "/" ) || canDownload ) {
405
403
setCanShareFile ( true ) ;
404
+ } else {
405
+ setCanShareFile ( false ) ;
406
406
}
407
407
} else {
408
408
setCanShareFile ( false ) ;
409
409
setCanPreviewFile ( false ) ;
410
410
}
411
- } , [ selectedObjects ] ) ;
411
+ } , [ selectedObjects , canDownload ] ) ;
412
412
413
413
useEffect ( ( ) => {
414
414
if ( ! quota && ! anonymousMode ) {
@@ -931,8 +931,7 @@ const ListObjects = () => {
931
931
} ,
932
932
label : "Delete" ,
933
933
icon : < DeleteIcon /> ,
934
- disabled :
935
- ! canDelete || selectedObjects . length === 0 || ! displayDeleteObject ,
934
+ disabled : ! canDelete || selectedObjects . length === 0 ,
936
935
tooltip : canDelete
937
936
? "Delete Selected Files"
938
937
: permissionTooltipHelper (
0 commit comments