@@ -71,7 +71,10 @@ import ScreenTitle from "../../../../Common/ScreenTitle/ScreenTitle";
71
71
import { AppState , useAppDispatch } from "../../../../../../store" ;
72
72
import PageLayout from "../../../../Common/Layout/PageLayout" ;
73
73
74
- import { IAM_SCOPES } from "../../../../../../common/SecureComponent/permissions" ;
74
+ import {
75
+ IAM_SCOPES ,
76
+ permissionTooltipHelper ,
77
+ } from "../../../../../../common/SecureComponent/permissions" ;
75
78
import {
76
79
hasPermission ,
77
80
SecureComponent ,
@@ -1055,11 +1058,23 @@ const ListObjects = () => {
1055
1058
1056
1059
const onDrop = useCallback (
1057
1060
( acceptedFiles : any [ ] ) => {
1058
- if ( acceptedFiles && acceptedFiles . length > 0 ) {
1061
+ if ( acceptedFiles && acceptedFiles . length > 0 && canUpload ) {
1059
1062
let newFolderPath : string = acceptedFiles [ 0 ] . path ;
1060
1063
uploadObject ( acceptedFiles , newFolderPath ) ;
1061
1064
}
1065
+ if ( ! canUpload ) {
1066
+ dispatch (
1067
+ setErrorSnackMessage ( {
1068
+ errorMessage : "Upload not allowed" ,
1069
+ detailedError : permissionTooltipHelper (
1070
+ [ IAM_SCOPES . S3_PUT_OBJECT ] ,
1071
+ "upload objects to this location"
1072
+ ) ,
1073
+ } )
1074
+ ) ;
1075
+ }
1062
1076
} ,
1077
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1063
1078
[ uploadObject ]
1064
1079
) ;
1065
1080
@@ -1221,6 +1236,10 @@ const ListObjects = () => {
1221
1236
uploadPath = uploadPath . concat ( currentPath ) ;
1222
1237
}
1223
1238
1239
+ const canDownload = hasPermission ( bucketName , [ IAM_SCOPES . S3_GET_OBJECT ] ) ;
1240
+ const canDelete = hasPermission ( bucketName , [ IAM_SCOPES . S3_DELETE_OBJECT ] ) ;
1241
+ const canUpload = hasPermission ( uploadPath , [ IAM_SCOPES . S3_PUT_OBJECT ] ) ;
1242
+
1224
1243
const onClosePanel = ( forceRefresh : boolean ) => {
1225
1244
dispatch ( setSelectedObjectView ( null ) ) ;
1226
1245
dispatch ( setVersionsModeEnabled ( { status : false } ) ) ;
@@ -1272,23 +1291,28 @@ const ListObjects = () => {
1272
1291
{
1273
1292
action : downloadSelected ,
1274
1293
label : "Download" ,
1275
- disabled : selectedObjects . length === 0 ,
1294
+ disabled : ! canDownload || selectedObjects . length === 0 ,
1276
1295
icon : < DownloadIcon /> ,
1277
- tooltip : "Download Selected" ,
1296
+ tooltip : canDownload
1297
+ ? "Download Selected"
1298
+ : permissionTooltipHelper (
1299
+ [ IAM_SCOPES . S3_GET_OBJECT ] ,
1300
+ "download objects from this bucket"
1301
+ ) ,
1278
1302
} ,
1279
1303
{
1280
1304
action : openShare ,
1281
1305
label : "Share" ,
1282
1306
disabled : selectedObjects . length !== 1 || ! canShareFile ,
1283
1307
icon : < ShareIcon /> ,
1284
- tooltip : "Share Selected File" ,
1308
+ tooltip : canShareFile ? "Share Selected File" : "Sharing unavailable ",
1285
1309
} ,
1286
1310
{
1287
1311
action : openPreview ,
1288
1312
label : "Preview" ,
1289
1313
disabled : selectedObjects . length !== 1 || ! canPreviewFile ,
1290
1314
icon : < PreviewIcon /> ,
1291
- tooltip : "Preview Selected File" ,
1315
+ tooltip : canPreviewFile ? "Preview Selected File" : "Preview unavailable ",
1292
1316
} ,
1293
1317
{
1294
1318
action : ( ) => {
@@ -1297,10 +1321,13 @@ const ListObjects = () => {
1297
1321
label : "Delete" ,
1298
1322
icon : < DeleteIcon /> ,
1299
1323
disabled :
1300
- ! hasPermission ( bucketName , [ IAM_SCOPES . S3_DELETE_OBJECT ] ) ||
1301
- selectedObjects . length === 0 ||
1302
- ! displayDeleteObject ,
1303
- tooltip : "Delete Selected Files" ,
1324
+ ! canDelete || selectedObjects . length === 0 || ! displayDeleteObject ,
1325
+ tooltip : canDelete
1326
+ ? "Delete Selected Files"
1327
+ : permissionTooltipHelper (
1328
+ [ IAM_SCOPES . S3_DELETE_OBJECT ] ,
1329
+ "delete objects in this bucket"
1330
+ ) ,
1304
1331
} ,
1305
1332
] ;
1306
1333
0 commit comments