@@ -340,20 +340,20 @@ const ListObjects = () => {
340340 putObjectPermScopes
341341 ) ;
342342
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+ ) ;
348351 const canUpload =
349352 hasPermission (
350353 [ pathAsResourceInPolicy , ...sessionGrantWildCards ] ,
351354 putObjectPermScopes
352355 ) || anonymousMode ;
353356
354- const displayDeleteObject = hasPermission ( bucketName , [
355- IAM_SCOPES . S3_DELETE_OBJECT ,
356- ] ) ;
357357 const canSetAnonymousAccess = hasPermission ( bucketName , [
358358 IAM_SCOPES . S3_GET_BUCKET_POLICY ,
359359 IAM_SCOPES . S3_PUT_BUCKET_POLICY ,
@@ -393,22 +393,22 @@ const ListObjects = () => {
393393 if ( selectedObjects . length === 1 ) {
394394 const objectName = selectedObjects [ 0 ] ;
395395
396- if ( extensionPreview ( objectName ) !== "none" ) {
396+ if ( extensionPreview ( objectName ) !== "none" && canDownload ) {
397397 setCanPreviewFile ( true ) ;
398398 } else {
399399 setCanPreviewFile ( false ) ;
400400 }
401401
402- if ( objectName . endsWith ( "/" ) ) {
403- setCanShareFile ( false ) ;
404- } else {
402+ if ( objectName . endsWith ( "/" ) || canDownload ) {
405403 setCanShareFile ( true ) ;
404+ } else {
405+ setCanShareFile ( false ) ;
406406 }
407407 } else {
408408 setCanShareFile ( false ) ;
409409 setCanPreviewFile ( false ) ;
410410 }
411- } , [ selectedObjects ] ) ;
411+ } , [ selectedObjects , canDownload ] ) ;
412412
413413 useEffect ( ( ) => {
414414 if ( ! quota && ! anonymousMode ) {
@@ -931,8 +931,7 @@ const ListObjects = () => {
931931 } ,
932932 label : "Delete" ,
933933 icon : < DeleteIcon /> ,
934- disabled :
935- ! canDelete || selectedObjects . length === 0 || ! displayDeleteObject ,
934+ disabled : ! canDelete || selectedObjects . length === 0 ,
936935 tooltip : canDelete
937936 ? "Delete Selected Files"
938937 : permissionTooltipHelper (
0 commit comments