@scality/data-browser-library 1.0.0-preview.9 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/DataBrowserUI.d.ts +12 -0
- package/dist/components/DataBrowserUI.js +99 -0
- package/dist/components/Editor.d.ts +1 -1
- package/dist/components/Editor.js +3 -3
- package/dist/components/__tests__/BucketAccessor.test.js +214 -0
- package/dist/components/__tests__/BucketCorsPage.test.d.ts +1 -0
- package/dist/components/__tests__/BucketCorsPage.test.js +263 -0
- package/dist/components/__tests__/BucketCreate.test.js +271 -105
- package/dist/components/__tests__/BucketDetails.test.d.ts +1 -0
- package/dist/components/__tests__/BucketDetails.test.js +421 -0
- package/dist/components/__tests__/BucketLifecycleFormPage.test.d.ts +13 -0
- package/dist/components/__tests__/BucketLifecycleFormPage.test.js +178 -178
- package/dist/components/__tests__/BucketLifecycleList.test.js +85 -85
- package/dist/components/__tests__/BucketList.test.js +463 -239
- package/dist/components/__tests__/BucketNotificationFormPage.test.d.ts +1 -0
- package/dist/components/__tests__/BucketNotificationFormPage.test.js +348 -0
- package/dist/components/__tests__/BucketNotificationList.test.d.ts +1 -0
- package/dist/components/__tests__/BucketNotificationList.test.js +379 -0
- package/dist/components/__tests__/BucketOverview.test.js +281 -266
- package/dist/components/__tests__/BucketPolicyPage.test.js +151 -99
- package/dist/components/__tests__/BucketReplicationFormPage.test.d.ts +15 -0
- package/dist/components/__tests__/BucketReplicationFormPage.test.js +544 -544
- package/dist/components/__tests__/BucketReplicationList.test.js +106 -106
- package/dist/components/__tests__/CreateFolderButton.test.js +56 -56
- package/dist/components/__tests__/DeleteBucketButton.test.js +64 -64
- package/dist/components/__tests__/DeleteBucketConfigRuleButton.test.js +47 -47
- package/dist/components/__tests__/DeleteObjectButton.test.js +64 -64
- package/dist/components/__tests__/EmptyBucketButton.test.js +59 -59
- package/dist/components/__tests__/MetadataSearch.test.js +65 -65
- package/dist/components/__tests__/ObjectList.test.js +741 -240
- package/dist/components/__tests__/UploadButton.test.js +45 -45
- package/dist/components/breadcrumb/Breadcrumb.d.ts +6 -0
- package/dist/components/breadcrumb/Breadcrumb.js +37 -0
- package/dist/components/breadcrumb/DataBrowserBreadcrumb.d.ts +1 -0
- package/dist/components/breadcrumb/DataBrowserBreadcrumb.js +10 -0
- package/dist/components/breadcrumb/__tests__/Breadcrumb.test.d.ts +1 -0
- package/dist/components/breadcrumb/__tests__/Breadcrumb.test.js +196 -0
- package/dist/components/breadcrumb/__tests__/DataBrowserBreadcrumb.test.d.ts +1 -0
- package/dist/components/breadcrumb/__tests__/DataBrowserBreadcrumb.test.js +153 -0
- package/dist/components/breadcrumb/__tests__/useBreadcrumbPaths.test.d.ts +1 -0
- package/dist/components/breadcrumb/__tests__/useBreadcrumbPaths.test.js +134 -0
- package/dist/components/breadcrumb/index.d.ts +8 -0
- package/dist/components/breadcrumb/index.js +4 -0
- package/dist/components/breadcrumb/useBreadcrumbPaths.d.ts +2 -0
- package/dist/components/breadcrumb/useBreadcrumbPaths.js +82 -0
- package/dist/components/buckets/BucketAccessor.d.ts +2 -0
- package/dist/components/buckets/BucketAccessor.js +125 -0
- package/dist/components/buckets/BucketConfigEditButton.d.ts +8 -0
- package/dist/components/buckets/{BucketPolicyButton.js → BucketConfigEditButton.js} +9 -5
- package/dist/components/buckets/BucketCorsPage.d.ts +1 -0
- package/dist/components/buckets/BucketCorsPage.js +234 -0
- package/dist/components/buckets/BucketCreate.d.ts +3 -2
- package/dist/components/buckets/BucketCreate.js +89 -47
- package/dist/components/buckets/BucketDetails.d.ts +42 -0
- package/dist/components/buckets/BucketDetails.js +249 -85
- package/dist/components/buckets/BucketLifecycleFormPage.js +206 -190
- package/dist/components/buckets/BucketLifecycleList.d.ts +2 -2
- package/dist/components/buckets/BucketLifecycleList.js +47 -47
- package/dist/components/buckets/BucketList.d.ts +7 -8
- package/dist/components/buckets/BucketList.js +158 -101
- package/dist/components/buckets/BucketLocation.js +4 -4
- package/dist/components/buckets/BucketOverview.d.ts +22 -2
- package/dist/components/buckets/BucketOverview.js +394 -187
- package/dist/components/buckets/BucketPage.js +43 -21
- package/dist/components/buckets/BucketPolicyPage.js +155 -127
- package/dist/components/buckets/BucketReplicationFormPage.js +134 -133
- package/dist/components/buckets/BucketReplicationList.d.ts +2 -2
- package/dist/components/buckets/BucketReplicationList.js +42 -42
- package/dist/components/buckets/BucketVersioning.d.ts +4 -0
- package/dist/components/buckets/BucketVersioning.js +76 -0
- package/dist/components/buckets/DeleteBucketButton.js +8 -8
- package/dist/components/buckets/DeleteBucketConfigRuleButton.d.ts +2 -2
- package/dist/components/buckets/DeleteBucketConfigRuleButton.js +2 -2
- package/dist/components/buckets/EmptyBucketButton.js +24 -24
- package/dist/components/buckets/EmptyBucketSummary.d.ts +2 -2
- package/dist/components/buckets/EmptyBucketSummary.js +1 -1
- package/dist/components/buckets/EmptyBucketSummaryList.d.ts +1 -1
- package/dist/components/buckets/EmptyBucketSummaryList.js +22 -22
- package/dist/components/buckets/__tests__/BucketVersioning.test.d.ts +1 -0
- package/dist/components/buckets/__tests__/BucketVersioning.test.js +163 -0
- package/dist/components/buckets/notifications/BucketNotificationFormPage.d.ts +1 -0
- package/dist/components/buckets/notifications/BucketNotificationFormPage.js +316 -0
- package/dist/components/buckets/notifications/BucketNotificationList.d.ts +10 -0
- package/dist/components/buckets/notifications/BucketNotificationList.js +267 -0
- package/dist/components/buckets/notifications/EventsSection.js +145 -29
- package/dist/components/buckets/notifications/__tests__/events.test.d.ts +1 -0
- package/dist/components/buckets/notifications/__tests__/events.test.js +56 -0
- package/dist/components/buckets/notifications/events.d.ts +71 -7
- package/dist/components/buckets/notifications/events.js +98 -16
- package/dist/components/index.d.ts +27 -20
- package/dist/components/index.js +17 -10
- package/dist/components/layouts/ArrowNavigation.d.ts +3 -0
- package/dist/components/layouts/ArrowNavigation.js +28 -0
- package/dist/components/layouts/BrowserPageLayout.d.ts +5 -1
- package/dist/components/layouts/BrowserPageLayout.js +10 -5
- package/dist/components/objects/CreateFolderButton.d.ts +2 -2
- package/dist/components/objects/CreateFolderButton.js +12 -12
- package/dist/components/objects/DeleteObjectButton.d.ts +1 -1
- package/dist/components/objects/DeleteObjectButton.js +19 -21
- package/dist/components/objects/GetPresignedUrlButton.d.ts +7 -0
- package/dist/components/objects/GetPresignedUrlButton.js +255 -0
- package/dist/components/objects/ObjectDetails/ObjectMetadata.d.ts +2 -2
- package/dist/components/objects/ObjectDetails/ObjectMetadata.js +263 -230
- package/dist/components/objects/ObjectDetails/ObjectSummary.d.ts +2 -2
- package/dist/components/objects/ObjectDetails/ObjectSummary.js +540 -138
- package/dist/components/objects/ObjectDetails/ObjectTags.d.ts +2 -2
- package/dist/components/objects/ObjectDetails/ObjectTags.js +95 -123
- package/dist/components/objects/ObjectDetails/__tests__/ObjectDetails.test.d.ts +1 -0
- package/dist/components/objects/ObjectDetails/__tests__/ObjectDetails.test.js +516 -0
- package/dist/components/objects/ObjectDetails/__tests__/ObjectSummary.test.d.ts +1 -0
- package/dist/components/objects/ObjectDetails/__tests__/ObjectSummary.test.js +1064 -0
- package/dist/components/objects/ObjectDetails/index.d.ts +18 -2
- package/dist/components/objects/ObjectDetails/index.js +152 -40
- package/dist/components/objects/ObjectList.d.ts +12 -10
- package/dist/components/objects/ObjectList.js +590 -263
- package/dist/components/objects/ObjectLock/EditRetentionButton.js +4 -4
- package/dist/components/objects/ObjectLock/ObjectLockRetentionSettings.js +15 -15
- package/dist/components/objects/ObjectLock/ObjectLockSettings.d.ts +1 -1
- package/dist/components/objects/ObjectLock/ObjectLockSettings.js +32 -31
- package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.d.ts +1 -1
- package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.js +6 -6
- package/dist/components/objects/ObjectLock/__tests__/EditRetentionButton.test.js +51 -51
- package/dist/components/objects/ObjectLock/__tests__/ObjectLockSettings.test.js +78 -78
- package/dist/components/objects/ObjectPage.js +12 -8
- package/dist/components/objects/UploadButton.d.ts +3 -3
- package/dist/components/objects/UploadButton.js +10 -10
- package/dist/components/objects/__tests__/GetPresignedUrlButton.test.d.ts +1 -0
- package/dist/components/objects/__tests__/GetPresignedUrlButton.test.js +531 -0
- package/dist/components/providers/DataBrowserProvider.d.ts +23 -12
- package/dist/components/providers/DataBrowserProvider.js +60 -38
- package/dist/components/providers/QueryProvider.d.ts +9 -0
- package/dist/components/providers/QueryProvider.js +21 -0
- package/dist/components/search/MetadataSearch.js +29 -28
- package/dist/components/search/SearchHints.js +1 -1
- package/dist/components/ui/ArrayFieldActions.js +12 -7
- package/dist/components/ui/ConfirmDeleteRuleModal.d.ts +2 -2
- package/dist/components/ui/ConfirmDeleteRuleModal.js +6 -1
- package/dist/components/ui/DeleteObjectModalContent.d.ts +1 -1
- package/dist/components/ui/DeleteObjectModalContent.js +12 -12
- package/dist/components/ui/FilterFormSection.d.ts +2 -2
- package/dist/components/ui/FilterFormSection.js +29 -29
- package/dist/components/ui/Search.elements.d.ts +2 -2
- package/dist/components/ui/Search.elements.js +7 -7
- package/dist/components/ui/Table.elements.d.ts +2 -1
- package/dist/components/ui/Table.elements.js +18 -12
- package/dist/config/__tests__/factory.test.d.ts +1 -0
- package/dist/config/__tests__/factory.test.js +311 -0
- package/dist/config/factory.d.ts +10 -56
- package/dist/config/factory.js +23 -71
- package/dist/config/types.d.ts +212 -34
- package/dist/contexts/DataBrowserUICustomizationContext.d.ts +27 -0
- package/dist/contexts/DataBrowserUICustomizationContext.js +13 -0
- package/dist/hooks/__tests__/useAccessibleBuckets.test.d.ts +1 -0
- package/dist/hooks/__tests__/useAccessibleBuckets.test.js +145 -0
- package/dist/hooks/__tests__/useISVBucketDetection.test.js +45 -45
- package/dist/hooks/__tests__/useIsBucketEmpty.test.js +27 -27
- package/dist/hooks/__tests__/useLoginMutation.test.d.ts +1 -0
- package/dist/hooks/__tests__/useLoginMutation.test.js +194 -0
- package/dist/hooks/bucketConfiguration.d.ts +8 -1
- package/dist/hooks/bucketConfiguration.js +52 -51
- package/dist/hooks/bucketOperations.d.ts +10 -1
- package/dist/hooks/bucketOperations.js +10 -9
- package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.js +80 -80
- package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.js +80 -80
- package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.js +44 -44
- package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.js +63 -63
- package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.js +65 -65
- package/dist/hooks/factories/index.d.ts +4 -4
- package/dist/hooks/factories/index.js +2 -2
- package/dist/hooks/factories/useCreateS3InfiniteQueryHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3InfiniteQueryHook.js +16 -13
- package/dist/hooks/factories/useCreateS3LoginHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3LoginHook.js +1 -1
- package/dist/hooks/factories/useCreateS3MutationHook.d.ts +3 -3
- package/dist/hooks/factories/useCreateS3MutationHook.js +7 -2
- package/dist/hooks/factories/useCreateS3QueryHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3QueryHook.js +11 -6
- package/dist/hooks/index.d.ts +19 -12
- package/dist/hooks/index.js +16 -9
- package/dist/hooks/loginOperations.d.ts +1 -1
- package/dist/hooks/loginOperations.js +1 -1
- package/dist/hooks/objectOperations.d.ts +2 -2
- package/dist/hooks/objectOperations.js +50 -49
- package/dist/hooks/presignedOperations.d.ts +4 -4
- package/dist/hooks/presignedOperations.js +5 -5
- package/dist/hooks/useAccessibleBuckets.d.ts +11 -0
- package/dist/hooks/useAccessibleBuckets.js +115 -0
- package/dist/hooks/useBatchObjectLegalHold.d.ts +11 -0
- package/dist/hooks/useBatchObjectLegalHold.js +48 -0
- package/dist/hooks/useBucketConfigEditor.d.ts +31 -0
- package/dist/hooks/useBucketConfigEditor.js +82 -0
- package/dist/hooks/useDataBrowserNavigate.d.ts +28 -0
- package/dist/hooks/useDataBrowserNavigate.js +24 -0
- package/dist/hooks/useDeleteBucketConfigRule.d.ts +2 -2
- package/dist/hooks/useDeleteBucketConfigRule.js +4 -4
- package/dist/hooks/useEmptyBucket.js +11 -11
- package/dist/hooks/useFeatures.d.ts +7 -0
- package/dist/hooks/useFeatures.js +8 -0
- package/dist/hooks/useISVBucketDetection.js +6 -6
- package/dist/hooks/useIsBucketEmpty.js +4 -4
- package/dist/hooks/useLimitedAccessFlow.d.ts +48 -0
- package/dist/hooks/useLimitedAccessFlow.js +23 -0
- package/dist/hooks/useS3Client.d.ts +6 -0
- package/dist/hooks/useS3Client.js +3 -2
- package/dist/hooks/useS3ConfigSwitch.d.ts +11 -0
- package/dist/hooks/useS3ConfigSwitch.js +37 -0
- package/dist/hooks/useSupportedNotificationEvents.d.ts +6 -0
- package/dist/hooks/useSupportedNotificationEvents.js +8 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +2 -2
- package/dist/schemas/bucketPolicySchema.json +3 -13
- package/dist/test/msw/handlers/deleteBucket.d.ts +1 -1
- package/dist/test/msw/handlers/deleteBucket.js +20 -10
- package/dist/test/msw/handlers/getBucketAcl.d.ts +1 -1
- package/dist/test/msw/handlers/getBucketAcl.js +29 -17
- package/dist/test/msw/handlers/getBucketLocation.d.ts +1 -1
- package/dist/test/msw/handlers/getBucketLocation.js +29 -15
- package/dist/test/msw/handlers/getBucketPolicy.d.ts +1 -1
- package/dist/test/msw/handlers/getBucketPolicy.js +52 -32
- package/dist/test/msw/handlers/headObject.d.ts +1 -1
- package/dist/test/msw/handlers/headObject.js +31 -13
- package/dist/test/msw/handlers/listBuckets.d.ts +1 -1
- package/dist/test/msw/handlers/listBuckets.js +5 -3
- package/dist/test/msw/handlers/listObjectVersions.d.ts +1 -1
- package/dist/test/msw/handlers/listObjectVersions.js +38 -26
- package/dist/test/msw/handlers/listObjects.d.ts +1 -1
- package/dist/test/msw/handlers/listObjects.js +35 -23
- package/dist/test/msw/handlers/objectLegalHold.d.ts +1 -1
- package/dist/test/msw/handlers/objectLegalHold.js +32 -17
- package/dist/test/msw/handlers/objectRetention.d.ts +1 -1
- package/dist/test/msw/handlers/objectRetention.js +31 -17
- package/dist/test/msw/handlers/putBucketAcl.d.ts +1 -1
- package/dist/test/msw/handlers/putBucketAcl.js +29 -14
- package/dist/test/msw/handlers/putObject.d.ts +1 -1
- package/dist/test/msw/handlers/putObject.js +27 -12
- package/dist/test/msw/handlers.d.ts +3 -3
- package/dist/test/msw/handlers.js +77 -54
- package/dist/test/msw/index.d.ts +2 -2
- package/dist/test/msw/index.js +1 -1
- package/dist/test/msw/server.d.ts +1 -1
- package/dist/test/msw/server.js +1 -1
- package/dist/test/msw/utils.js +2 -2
- package/dist/test/setup.d.ts +1 -1
- package/dist/test/setup.js +13 -30
- package/dist/test/testUtils.d.ts +85 -33
- package/dist/test/testUtils.js +176 -111
- package/dist/test/utils/errorHandling.test.js +119 -119
- package/dist/types/index.d.ts +49 -36
- package/dist/types/monaco.d.ts +13 -0
- package/dist/types/monaco.js +0 -0
- package/dist/utils/__tests__/proxyMiddleware.test.d.ts +1 -0
- package/dist/utils/__tests__/proxyMiddleware.test.js +579 -0
- package/dist/utils/__tests__/s3Client.test.d.ts +1 -0
- package/dist/utils/__tests__/s3Client.test.js +340 -0
- package/dist/utils/__tests__/s3ConfigIdentifier.test.d.ts +1 -0
- package/dist/utils/__tests__/s3ConfigIdentifier.test.js +437 -0
- package/dist/utils/constants.d.ts +10 -0
- package/dist/utils/constants.js +19 -9
- package/dist/utils/deletion/index.d.ts +2 -2
- package/dist/utils/deletion/index.js +1 -1
- package/dist/utils/deletion/messages.d.ts +1 -1
- package/dist/utils/deletion/messages.js +4 -4
- package/dist/utils/errorHandling.d.ts +3 -3
- package/dist/utils/errorHandling.js +6 -6
- package/dist/utils/hooks.js +8 -8
- package/dist/utils/index.d.ts +5 -4
- package/dist/utils/index.js +4 -2
- package/dist/utils/proxyMiddleware.d.ts +32 -13
- package/dist/utils/proxyMiddleware.js +90 -36
- package/dist/utils/s3Client.d.ts +14 -4
- package/dist/utils/s3Client.js +5 -26
- package/dist/utils/s3ConfigIdentifier.d.ts +79 -0
- package/dist/utils/s3ConfigIdentifier.js +57 -0
- package/dist/utils/s3RuleUtils.d.ts +5 -5
- package/dist/utils/s3RuleUtils.js +17 -17
- package/package.json +10 -8
- package/dist/components/__tests__/BucketNotificationCreatePage.test.js +0 -316
- package/dist/components/buckets/BucketPolicyButton.d.ts +0 -7
- package/dist/components/buckets/notifications/BucketNotificationCreatePage.d.ts +0 -1
- package/dist/components/buckets/notifications/BucketNotificationCreatePage.js +0 -234
- package/dist/hooks/useLoginMutation.d.ts +0 -21
- package/dist/hooks/useLoginMutation.js +0 -9
- package/dist/utils/useFeatures.d.ts +0 -1
- package/dist/utils/useFeatures.js +0 -7
- /package/dist/components/__tests__/{BucketNotificationCreatePage.test.d.ts → BucketAccessor.test.d.ts} +0 -0
|
@@ -1,66 +1,67 @@
|
|
|
1
1
|
import { CopyObjectCommand, DeleteObjectCommand, DeleteObjectTaggingCommand, DeleteObjectsCommand, GetObjectAclCommand, GetObjectAttributesCommand, GetObjectCommand, GetObjectLegalHoldCommand, GetObjectRetentionCommand, GetObjectTaggingCommand, GetObjectTorrentCommand, HeadObjectCommand, ListMultipartUploadsCommand, ListObjectVersionsCommand, ListObjectsV2Command, PutObjectAclCommand, PutObjectCommand, PutObjectLegalHoldCommand, PutObjectRetentionCommand, PutObjectTaggingCommand, RestoreObjectCommand, SelectObjectContentCommand } from "@aws-sdk/client-s3";
|
|
2
|
+
import { SearchObjectsV2Command, SearchObjectsVersionCommand } from "@scality/zenkoclient";
|
|
2
3
|
import { useCreateS3InfiniteQueryHook } from "./factories/useCreateS3InfiniteQueryHook.js";
|
|
3
4
|
import { useCreateS3MutationHook } from "./factories/useCreateS3MutationHook.js";
|
|
4
5
|
import { useCreateS3QueryHook } from "./factories/useCreateS3QueryHook.js";
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"SearchObjects"
|
|
6
|
+
const useListObjects = useCreateS3InfiniteQueryHook(ListObjectsV2Command, 'ListObjects');
|
|
7
|
+
const useListObjectVersions = useCreateS3InfiniteQueryHook(ListObjectVersionsCommand, 'ListObjectVersions');
|
|
8
|
+
const useSearchObjects = useCreateS3InfiniteQueryHook(SearchObjectsV2Command, 'SearchObjects');
|
|
9
|
+
const useSearchObjectsVersions = useCreateS3InfiniteQueryHook(SearchObjectsVersionCommand, 'SearchObjectsVersions');
|
|
10
|
+
const useObjectMetadata = useCreateS3QueryHook(HeadObjectCommand, 'HeadObject');
|
|
11
|
+
const useGetObject = useCreateS3QueryHook(GetObjectCommand, 'GetObject');
|
|
12
|
+
const usePutObject = useCreateS3MutationHook(PutObjectCommand, 'PutObject', [
|
|
13
|
+
'ListObjects',
|
|
14
|
+
'SearchObjects'
|
|
15
15
|
]);
|
|
16
|
-
const useCreateFolder = useCreateS3MutationHook(PutObjectCommand,
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const useCreateFolder = useCreateS3MutationHook(PutObjectCommand, 'PutObject', [
|
|
17
|
+
'ListObjects',
|
|
18
|
+
'SearchObjects'
|
|
19
19
|
]);
|
|
20
|
-
const useUploadObjects = useCreateS3MutationHook(PutObjectCommand,
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const useUploadObjects = useCreateS3MutationHook(PutObjectCommand, 'PutObject', [
|
|
21
|
+
'ListObjects',
|
|
22
|
+
'SearchObjects'
|
|
23
23
|
]);
|
|
24
|
-
const useDeleteObject = useCreateS3MutationHook(DeleteObjectCommand,
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const useDeleteObject = useCreateS3MutationHook(DeleteObjectCommand, 'DeleteObject', [
|
|
25
|
+
'ListObjects',
|
|
26
|
+
'SearchObjects'
|
|
27
27
|
]);
|
|
28
|
-
const useDeleteObjects = useCreateS3MutationHook(DeleteObjectsCommand,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const useDeleteObjects = useCreateS3MutationHook(DeleteObjectsCommand, 'DeleteObjects', [
|
|
29
|
+
'ListObjects',
|
|
30
|
+
'ListObjectVersions',
|
|
31
|
+
'SearchObjects',
|
|
32
|
+
'SearchObjectsVersions'
|
|
33
33
|
]);
|
|
34
|
-
const useCopyObject = useCreateS3MutationHook(CopyObjectCommand,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
const useCopyObject = useCreateS3MutationHook(CopyObjectCommand, 'CopyObject', [
|
|
35
|
+
'ListObjects',
|
|
36
|
+
'SearchObjects',
|
|
37
|
+
'HeadObject'
|
|
38
38
|
]);
|
|
39
|
-
const useObjectRetention = useCreateS3QueryHook(GetObjectRetentionCommand,
|
|
40
|
-
const useSetObjectRetention = useCreateS3MutationHook(PutObjectRetentionCommand,
|
|
41
|
-
|
|
39
|
+
const useObjectRetention = useCreateS3QueryHook(GetObjectRetentionCommand, 'GetObjectRetention');
|
|
40
|
+
const useSetObjectRetention = useCreateS3MutationHook(PutObjectRetentionCommand, 'PutObjectRetention', [
|
|
41
|
+
'GetObjectRetention'
|
|
42
42
|
]);
|
|
43
|
-
const useObjectLegalHold = useCreateS3QueryHook(GetObjectLegalHoldCommand,
|
|
44
|
-
const useSetObjectLegalHold = useCreateS3MutationHook(PutObjectLegalHoldCommand,
|
|
45
|
-
|
|
43
|
+
const useObjectLegalHold = useCreateS3QueryHook(GetObjectLegalHoldCommand, 'GetObjectLegalHold');
|
|
44
|
+
const useSetObjectLegalHold = useCreateS3MutationHook(PutObjectLegalHoldCommand, 'PutObjectLegalHold', [
|
|
45
|
+
'GetObjectLegalHold',
|
|
46
|
+
'BatchObjectLegalHold'
|
|
46
47
|
]);
|
|
47
|
-
const useObjectTagging = useCreateS3QueryHook(GetObjectTaggingCommand,
|
|
48
|
-
const useSetObjectTagging = useCreateS3MutationHook(PutObjectTaggingCommand,
|
|
49
|
-
|
|
48
|
+
const useObjectTagging = useCreateS3QueryHook(GetObjectTaggingCommand, 'GetObjectTagging');
|
|
49
|
+
const useSetObjectTagging = useCreateS3MutationHook(PutObjectTaggingCommand, 'PutObjectTagging', [
|
|
50
|
+
'GetObjectTagging'
|
|
50
51
|
]);
|
|
51
|
-
const useDeleteObjectTagging = useCreateS3MutationHook(DeleteObjectTaggingCommand,
|
|
52
|
-
|
|
52
|
+
const useDeleteObjectTagging = useCreateS3MutationHook(DeleteObjectTaggingCommand, 'DeleteObjectTagging', [
|
|
53
|
+
'GetObjectTagging'
|
|
53
54
|
]);
|
|
54
|
-
const useObjectAcl = useCreateS3QueryHook(GetObjectAclCommand,
|
|
55
|
-
const useSetObjectAcl = useCreateS3MutationHook(PutObjectAclCommand,
|
|
56
|
-
|
|
55
|
+
const useObjectAcl = useCreateS3QueryHook(GetObjectAclCommand, 'GetObjectAcl');
|
|
56
|
+
const useSetObjectAcl = useCreateS3MutationHook(PutObjectAclCommand, 'PutObjectAcl', [
|
|
57
|
+
'GetObjectAcl'
|
|
57
58
|
]);
|
|
58
|
-
const useGetObjectAttributes = useCreateS3QueryHook(GetObjectAttributesCommand,
|
|
59
|
-
const useGetObjectTorrent = useCreateS3QueryHook(GetObjectTorrentCommand,
|
|
60
|
-
const useRestoreObject = useCreateS3MutationHook(RestoreObjectCommand,
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
const useGetObjectAttributes = useCreateS3QueryHook(GetObjectAttributesCommand, 'GetObjectAttributes');
|
|
60
|
+
const useGetObjectTorrent = useCreateS3QueryHook(GetObjectTorrentCommand, 'GetObjectTorrent');
|
|
61
|
+
const useRestoreObject = useCreateS3MutationHook(RestoreObjectCommand, 'RestoreObject', [
|
|
62
|
+
'HeadObject',
|
|
63
|
+
'ListObjects'
|
|
63
64
|
]);
|
|
64
|
-
const useSelectObjectContent = useCreateS3QueryHook(SelectObjectContentCommand,
|
|
65
|
-
const useListMultipartUploads = useCreateS3InfiniteQueryHook(ListMultipartUploadsCommand,
|
|
65
|
+
const useSelectObjectContent = useCreateS3QueryHook(SelectObjectContentCommand, 'SelectObjectContent');
|
|
66
|
+
const useListMultipartUploads = useCreateS3InfiniteQueryHook(ListMultipartUploadsCommand, 'ListMultipartUploads');
|
|
66
67
|
export { useCopyObject, useCreateFolder, useDeleteObject, useDeleteObjectTagging, useDeleteObjects, useGetObject, useGetObjectAttributes, useGetObjectTorrent, useListMultipartUploads, useListObjectVersions, useListObjects, useObjectAcl, useObjectLegalHold, useObjectMetadata, useObjectRetention, useObjectTagging, usePutObject, useRestoreObject, useSearchObjects, useSearchObjectsVersions, useSelectObjectContent, useSetObjectAcl, useSetObjectLegalHold, useSetObjectRetention, useSetObjectTagging, useUploadObjects };
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* 2. Get Presigned POST
|
|
7
7
|
* 3. Get Presigned Upload (PUT)
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { type GetObjectCommandInput, type PutObjectCommandInput } from '@aws-sdk/client-s3';
|
|
10
|
+
import { type PresignedPost, type PresignedPostOptions } from '@aws-sdk/s3-presigned-post';
|
|
11
11
|
/**
|
|
12
12
|
* Hook for getting presigned download URLs
|
|
13
13
|
*
|
|
@@ -64,10 +64,10 @@ export declare const useGetPresignedPost: (options?: Omit<import("@tanstack/reac
|
|
|
64
64
|
Bucket: string;
|
|
65
65
|
Key: string;
|
|
66
66
|
expiresIn?: number;
|
|
67
|
-
} & Omit<PresignedPostOptions, "
|
|
67
|
+
} & Omit<PresignedPostOptions, "Bucket" | "Expires" | "Key">, unknown>, "mutationFn"> | undefined) => import("@tanstack/react-query").UseMutationResult<PresignedPost & {
|
|
68
68
|
ExpiresAt: Date;
|
|
69
69
|
}, import("../utils/errorHandling").EnhancedS3Error, {
|
|
70
70
|
Bucket: string;
|
|
71
71
|
Key: string;
|
|
72
72
|
expiresIn?: number;
|
|
73
|
-
} & Omit<PresignedPostOptions, "
|
|
73
|
+
} & Omit<PresignedPostOptions, "Bucket" | "Expires" | "Key">>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
|
2
|
-
import { createPresignedPost } from "@aws-sdk/s3-presigned-post";
|
|
3
1
|
import { GetObjectCommand, PutObjectCommand } from "@aws-sdk/client-s3";
|
|
2
|
+
import { createPresignedPost } from "@aws-sdk/s3-presigned-post";
|
|
3
|
+
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
|
4
4
|
import { createS3OperationError } from "../utils/errorHandling.js";
|
|
5
5
|
import { useCreateS3FunctionMutationHook } from "./factories/index.js";
|
|
6
6
|
const generatePresignedDownloadUrl = async (client, config)=>{
|
|
@@ -23,7 +23,7 @@ const generatePresignedDownloadUrl = async (client, config)=>{
|
|
|
23
23
|
VersionId: config.VersionId
|
|
24
24
|
};
|
|
25
25
|
} catch (error) {
|
|
26
|
-
throw createS3OperationError(error,
|
|
26
|
+
throw createS3OperationError(error, 'GeneratePresignedDownload', config.Bucket, config.Key);
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
const generatePresignedUploadUrl = async (client, config)=>{
|
|
@@ -45,7 +45,7 @@ const generatePresignedUploadUrl = async (client, config)=>{
|
|
|
45
45
|
Key: Key
|
|
46
46
|
};
|
|
47
47
|
} catch (error) {
|
|
48
|
-
throw createS3OperationError(error,
|
|
48
|
+
throw createS3OperationError(error, 'GeneratePresignedUpload', config.Bucket, config.Key);
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
const generatePresignedPost = async (client, config)=>{
|
|
@@ -63,7 +63,7 @@ const generatePresignedPost = async (client, config)=>{
|
|
|
63
63
|
ExpiresAt: expiresAt
|
|
64
64
|
};
|
|
65
65
|
} catch (error) {
|
|
66
|
-
throw createS3OperationError(error,
|
|
66
|
+
throw createS3OperationError(error, 'GeneratePresignedPost', config.Bucket, config.Key);
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
69
|
const useGetPresignedDownload = useCreateS3FunctionMutationHook(generatePresignedDownloadUrl);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Bucket } from '@aws-sdk/client-s3';
|
|
2
|
+
export declare const getAccessibleBucketsStorageKey: (s3ConfigIdentifier: string) => string;
|
|
3
|
+
export declare const getLimitedAccessFlagKey: (s3ConfigIdentifier: string) => string;
|
|
4
|
+
export declare const setLimitedAccessFlag: (s3ConfigIdentifier: string, value: boolean) => void;
|
|
5
|
+
export declare const useAccessibleBuckets: () => {
|
|
6
|
+
hasLimitedAccess: boolean;
|
|
7
|
+
setLimitedAccess: (value: boolean) => void;
|
|
8
|
+
accessibleBuckets: Bucket[];
|
|
9
|
+
addAccessibleBucket: (bucketName: string) => void;
|
|
10
|
+
clearAccessibleBuckets: () => void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { useDataBrowserContext } from "../components/providers/DataBrowserProvider.js";
|
|
3
|
+
const STORAGE_KEY_PREFIX = 'data-browser-accessible-buckets';
|
|
4
|
+
const LIMITED_ACCESS_FLAG_PREFIX = 'data-browser-limited-access';
|
|
5
|
+
const getAccessibleBucketsStorageKey = (s3ConfigIdentifier)=>`${STORAGE_KEY_PREFIX}-${s3ConfigIdentifier}`;
|
|
6
|
+
const getLimitedAccessFlagKey = (s3ConfigIdentifier)=>`${LIMITED_ACCESS_FLAG_PREFIX}-${s3ConfigIdentifier}`;
|
|
7
|
+
const setLimitedAccessFlag = (s3ConfigIdentifier, value)=>{
|
|
8
|
+
try {
|
|
9
|
+
const flagKey = getLimitedAccessFlagKey(s3ConfigIdentifier);
|
|
10
|
+
if (value) sessionStorage.setItem(flagKey, 'true');
|
|
11
|
+
else sessionStorage.removeItem(flagKey);
|
|
12
|
+
} catch {}
|
|
13
|
+
};
|
|
14
|
+
const readBucketsFromStorage = (storageKey)=>{
|
|
15
|
+
try {
|
|
16
|
+
const stored = sessionStorage.getItem(storageKey);
|
|
17
|
+
if (!stored) return [];
|
|
18
|
+
const parsed = JSON.parse(stored);
|
|
19
|
+
if (Array.isArray(parsed) && parsed.length > 0) {
|
|
20
|
+
if ('string' == typeof parsed[0]) {
|
|
21
|
+
const now = new Date().toISOString();
|
|
22
|
+
const bucketData = parsed.map((name)=>({
|
|
23
|
+
name,
|
|
24
|
+
addedAt: now
|
|
25
|
+
}));
|
|
26
|
+
sessionStorage.setItem(storageKey, JSON.stringify(bucketData));
|
|
27
|
+
return bucketData.map((item)=>({
|
|
28
|
+
Name: item.name,
|
|
29
|
+
CreationDate: new Date(item.addedAt)
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
const bucketData = parsed;
|
|
33
|
+
return bucketData.map((item)=>({
|
|
34
|
+
Name: item.name,
|
|
35
|
+
CreationDate: new Date(item.addedAt)
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
return [];
|
|
39
|
+
} catch {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const readLimitedAccessFlag = (flagKey)=>{
|
|
44
|
+
try {
|
|
45
|
+
const flag = sessionStorage.getItem(flagKey);
|
|
46
|
+
return 'true' === flag;
|
|
47
|
+
} catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const useAccessibleBuckets = ()=>{
|
|
52
|
+
const { s3ConfigIdentifier } = useDataBrowserContext();
|
|
53
|
+
const storageKey = useMemo(()=>getAccessibleBucketsStorageKey(s3ConfigIdentifier), [
|
|
54
|
+
s3ConfigIdentifier
|
|
55
|
+
]);
|
|
56
|
+
const flagKey = useMemo(()=>getLimitedAccessFlagKey(s3ConfigIdentifier), [
|
|
57
|
+
s3ConfigIdentifier
|
|
58
|
+
]);
|
|
59
|
+
const [hasLimitedAccess, setHasLimitedAccessState] = useState(()=>readLimitedAccessFlag(flagKey));
|
|
60
|
+
const [accessibleBuckets, setAccessibleBucketsState] = useState(()=>readBucketsFromStorage(storageKey));
|
|
61
|
+
useEffect(()=>{
|
|
62
|
+
setHasLimitedAccessState(readLimitedAccessFlag(flagKey));
|
|
63
|
+
setAccessibleBucketsState(readBucketsFromStorage(storageKey));
|
|
64
|
+
}, [
|
|
65
|
+
storageKey,
|
|
66
|
+
flagKey
|
|
67
|
+
]);
|
|
68
|
+
const setLimitedAccess = useCallback((value)=>{
|
|
69
|
+
setLimitedAccessFlag(s3ConfigIdentifier, value);
|
|
70
|
+
setHasLimitedAccessState(value);
|
|
71
|
+
}, [
|
|
72
|
+
s3ConfigIdentifier
|
|
73
|
+
]);
|
|
74
|
+
const addAccessibleBucket = useCallback((bucketName)=>{
|
|
75
|
+
try {
|
|
76
|
+
const stored = sessionStorage.getItem(storageKey);
|
|
77
|
+
const bucketData = stored ? JSON.parse(stored) : [];
|
|
78
|
+
const existingBucket = bucketData.find((b)=>b.name === bucketName);
|
|
79
|
+
if (!existingBucket) {
|
|
80
|
+
const newBucket = {
|
|
81
|
+
name: bucketName,
|
|
82
|
+
addedAt: new Date().toISOString()
|
|
83
|
+
};
|
|
84
|
+
bucketData.push(newBucket);
|
|
85
|
+
sessionStorage.setItem(storageKey, JSON.stringify(bucketData));
|
|
86
|
+
const newBuckets = bucketData.map((item)=>({
|
|
87
|
+
Name: item.name,
|
|
88
|
+
CreationDate: new Date(item.addedAt)
|
|
89
|
+
}));
|
|
90
|
+
setAccessibleBucketsState(newBuckets);
|
|
91
|
+
}
|
|
92
|
+
} catch {}
|
|
93
|
+
}, [
|
|
94
|
+
storageKey
|
|
95
|
+
]);
|
|
96
|
+
const clearAccessibleBuckets = useCallback(()=>{
|
|
97
|
+
try {
|
|
98
|
+
sessionStorage.removeItem(storageKey);
|
|
99
|
+
sessionStorage.removeItem(flagKey);
|
|
100
|
+
setAccessibleBucketsState([]);
|
|
101
|
+
setHasLimitedAccessState(false);
|
|
102
|
+
} catch {}
|
|
103
|
+
}, [
|
|
104
|
+
storageKey,
|
|
105
|
+
flagKey
|
|
106
|
+
]);
|
|
107
|
+
return {
|
|
108
|
+
hasLimitedAccess,
|
|
109
|
+
setLimitedAccess,
|
|
110
|
+
accessibleBuckets,
|
|
111
|
+
addAccessibleBucket,
|
|
112
|
+
clearAccessibleBuckets
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
export { getAccessibleBucketsStorageKey, getLimitedAccessFlagKey, setLimitedAccessFlag, useAccessibleBuckets };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface ObjectIdentifier {
|
|
2
|
+
Key: string;
|
|
3
|
+
VersionId?: string;
|
|
4
|
+
}
|
|
5
|
+
interface LegalHoldStatus {
|
|
6
|
+
key: string;
|
|
7
|
+
versionId?: string;
|
|
8
|
+
isLegalHoldEnabled: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const useBatchObjectLegalHold: (bucketName: string, objects: ObjectIdentifier[], enabled?: boolean) => import("@tanstack/react-query").UseQueryResult<Record<string, LegalHoldStatus>, Error>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { GetObjectLegalHoldCommand } from "@aws-sdk/client-s3";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useDataBrowserContext } from "../components/providers/DataBrowserProvider.js";
|
|
4
|
+
import { useS3Client } from "./useS3Client.js";
|
|
5
|
+
const useBatchObjectLegalHold = (bucketName, objects, enabled = true)=>{
|
|
6
|
+
const { s3ConfigIdentifier } = useDataBrowserContext();
|
|
7
|
+
const s3Client = useS3Client();
|
|
8
|
+
return useQuery({
|
|
9
|
+
queryKey: [
|
|
10
|
+
s3ConfigIdentifier,
|
|
11
|
+
'BatchObjectLegalHold',
|
|
12
|
+
bucketName,
|
|
13
|
+
...objects.map((obj)=>`${obj.Key}:${obj.VersionId || 'null'}`)
|
|
14
|
+
],
|
|
15
|
+
queryFn: async ()=>{
|
|
16
|
+
const results = {};
|
|
17
|
+
await Promise.allSettled(objects.map(async (obj)=>{
|
|
18
|
+
const key = `${obj.Key}:${obj.VersionId || 'null'}`;
|
|
19
|
+
try {
|
|
20
|
+
const command = new GetObjectLegalHoldCommand({
|
|
21
|
+
Bucket: bucketName,
|
|
22
|
+
Key: obj.Key,
|
|
23
|
+
...obj.VersionId && {
|
|
24
|
+
VersionId: obj.VersionId
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const response = await s3Client.send(command);
|
|
28
|
+
results[key] = {
|
|
29
|
+
key: obj.Key,
|
|
30
|
+
versionId: obj.VersionId,
|
|
31
|
+
isLegalHoldEnabled: response.LegalHold?.Status === 'ON'
|
|
32
|
+
};
|
|
33
|
+
} catch (error) {
|
|
34
|
+
results[key] = {
|
|
35
|
+
key: obj.Key,
|
|
36
|
+
versionId: obj.VersionId,
|
|
37
|
+
isLegalHoldEnabled: false
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
return results;
|
|
42
|
+
},
|
|
43
|
+
enabled: enabled && objects.length > 0,
|
|
44
|
+
staleTime: 30000,
|
|
45
|
+
refetchOnWindowFocus: false
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
export { useBatchObjectLegalHold };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { BeforeMount } from '@monaco-editor/react';
|
|
2
|
+
import { useForm } from 'react-hook-form';
|
|
3
|
+
type FormValues = {
|
|
4
|
+
content: string;
|
|
5
|
+
};
|
|
6
|
+
type ValidationResult = {
|
|
7
|
+
isValid: boolean;
|
|
8
|
+
parsed?: unknown;
|
|
9
|
+
error?: string;
|
|
10
|
+
};
|
|
11
|
+
export type BucketConfigEditorConfig = {
|
|
12
|
+
bucketName: string;
|
|
13
|
+
initialContent: string | undefined;
|
|
14
|
+
defaultTemplate: string;
|
|
15
|
+
isLoading: boolean;
|
|
16
|
+
notFoundErrorNames: string[];
|
|
17
|
+
errorInstance: Error | null;
|
|
18
|
+
validate: (content: string) => ValidationResult;
|
|
19
|
+
monacoSchema?: unknown;
|
|
20
|
+
};
|
|
21
|
+
export type BucketConfigEditorResult = {
|
|
22
|
+
bucketName: string;
|
|
23
|
+
form: ReturnType<typeof useForm<FormValues>>;
|
|
24
|
+
content: string;
|
|
25
|
+
isCreateMode: boolean;
|
|
26
|
+
isValidFormat: boolean;
|
|
27
|
+
handleBeforeMount: BeforeMount;
|
|
28
|
+
navigateToBucket: () => void;
|
|
29
|
+
};
|
|
30
|
+
export declare const useBucketConfigEditor: (config: BucketConfigEditorConfig) => BucketConfigEditorResult;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo } from "react";
|
|
2
|
+
import { useForm } from "react-hook-form";
|
|
3
|
+
import { useDataBrowserNavigate } from "./useDataBrowserNavigate.js";
|
|
4
|
+
const useBucketConfigEditor = (config)=>{
|
|
5
|
+
const navigate = useDataBrowserNavigate();
|
|
6
|
+
const { bucketName } = config;
|
|
7
|
+
const form = useForm({
|
|
8
|
+
mode: 'onChange',
|
|
9
|
+
defaultValues: {
|
|
10
|
+
content: ''
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
const { watch, reset } = form;
|
|
14
|
+
const content = watch('content');
|
|
15
|
+
const isCreateMode = useMemo(()=>{
|
|
16
|
+
if (!config.errorInstance) return false;
|
|
17
|
+
return config.notFoundErrorNames.some((name)=>config.errorInstance?.name === name);
|
|
18
|
+
}, [
|
|
19
|
+
config.errorInstance,
|
|
20
|
+
config.notFoundErrorNames
|
|
21
|
+
]);
|
|
22
|
+
const initialValue = useMemo(()=>{
|
|
23
|
+
if (config.initialContent) try {
|
|
24
|
+
const parsed = JSON.parse(config.initialContent);
|
|
25
|
+
return JSON.stringify(parsed, null, 2);
|
|
26
|
+
} catch {
|
|
27
|
+
return config.initialContent;
|
|
28
|
+
}
|
|
29
|
+
return config.defaultTemplate;
|
|
30
|
+
}, [
|
|
31
|
+
config.initialContent,
|
|
32
|
+
config.defaultTemplate
|
|
33
|
+
]);
|
|
34
|
+
useEffect(()=>{
|
|
35
|
+
reset({
|
|
36
|
+
content: initialValue
|
|
37
|
+
});
|
|
38
|
+
}, [
|
|
39
|
+
initialValue,
|
|
40
|
+
reset
|
|
41
|
+
]);
|
|
42
|
+
const isValidFormat = useMemo(()=>config.validate(content).isValid, [
|
|
43
|
+
content,
|
|
44
|
+
config.validate
|
|
45
|
+
]);
|
|
46
|
+
const handleBeforeMount = useCallback((monaco)=>{
|
|
47
|
+
const jsonLanguage = monaco.languages.json;
|
|
48
|
+
if (jsonLanguage?.jsonDefaults) if (config.monacoSchema) jsonLanguage.jsonDefaults.setDiagnosticsOptions({
|
|
49
|
+
validate: true,
|
|
50
|
+
schemas: [
|
|
51
|
+
{
|
|
52
|
+
uri: 'http://myserver/schema.json',
|
|
53
|
+
fileMatch: [
|
|
54
|
+
'*'
|
|
55
|
+
],
|
|
56
|
+
schema: config.monacoSchema
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
});
|
|
60
|
+
else jsonLanguage.jsonDefaults.setDiagnosticsOptions({
|
|
61
|
+
validate: true
|
|
62
|
+
});
|
|
63
|
+
}, [
|
|
64
|
+
config.monacoSchema
|
|
65
|
+
]);
|
|
66
|
+
const navigateToBucket = useCallback(()=>{
|
|
67
|
+
navigate(`/buckets/${bucketName}`);
|
|
68
|
+
}, [
|
|
69
|
+
navigate,
|
|
70
|
+
bucketName
|
|
71
|
+
]);
|
|
72
|
+
return {
|
|
73
|
+
bucketName,
|
|
74
|
+
form,
|
|
75
|
+
content,
|
|
76
|
+
isCreateMode,
|
|
77
|
+
isValidFormat,
|
|
78
|
+
handleBeforeMount,
|
|
79
|
+
navigateToBucket
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
export { useBucketConfigEditor };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type NavigateOptions } from 'react-router';
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes a path by prefixing it with the basePath.
|
|
4
|
+
* Handles edge cases like missing slashes, relative paths, and root paths.
|
|
5
|
+
*
|
|
6
|
+
* @param basePath - The base path prefix (e.g., "/accounts/my-account/buckets")
|
|
7
|
+
* @param to - The target path (e.g., "/my-bucket")
|
|
8
|
+
* @returns The normalized absolute path (e.g., "/accounts/my-account/buckets/my-bucket")
|
|
9
|
+
*/
|
|
10
|
+
export declare const normalizePath: (basePath: string, to: string) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Hook for navigation with automatic basePath prefixing.
|
|
13
|
+
* Must be used within DataBrowserUI component.
|
|
14
|
+
*
|
|
15
|
+
* This hook wraps react-router's useNavigate and automatically prefixes all
|
|
16
|
+
* navigation paths with the basePath configured in DataBrowserUI props.
|
|
17
|
+
* This allows internal navigation to work correctly when DataBrowserUI is
|
|
18
|
+
* mounted at any route within the application.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* // If DataBrowserUI has basePath="/accounts/my-account/buckets"
|
|
23
|
+
* const navigate = useDataBrowserNavigate();
|
|
24
|
+
* navigate('/my-bucket'); // Navigates to "/accounts/my-account/buckets/my-bucket"
|
|
25
|
+
* navigate(-1); // History navigation works as normal (no prefixing)
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const useDataBrowserNavigate: () => (to: string | number, options?: NavigateOptions) => void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useNavigate } from "react-router";
|
|
3
|
+
import { useDataBrowserUICustomization } from "../contexts/DataBrowserUICustomizationContext.js";
|
|
4
|
+
const normalizePath = (basePath, to)=>{
|
|
5
|
+
if (!basePath) return to;
|
|
6
|
+
if (!to.startsWith('/')) return to;
|
|
7
|
+
const base = basePath.replace(/^\/+|\/+$/g, '');
|
|
8
|
+
const path = to.replace(/^\/+/, '');
|
|
9
|
+
if (!path) return base ? `/${base}` : '/';
|
|
10
|
+
return `/${base}/${path}`.replace(/\/+/g, '/');
|
|
11
|
+
};
|
|
12
|
+
const useDataBrowserNavigate = ()=>{
|
|
13
|
+
const navigate = useNavigate();
|
|
14
|
+
const { basePath = '' } = useDataBrowserUICustomization();
|
|
15
|
+
return useCallback((to, options)=>{
|
|
16
|
+
if ('number' == typeof to) return void navigate(to);
|
|
17
|
+
const targetPath = normalizePath(basePath, to);
|
|
18
|
+
options ? navigate(targetPath, options) : navigate(targetPath);
|
|
19
|
+
}, [
|
|
20
|
+
navigate,
|
|
21
|
+
basePath
|
|
22
|
+
]);
|
|
23
|
+
};
|
|
24
|
+
export { normalizePath, useDataBrowserNavigate };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UseMutationResult } from
|
|
1
|
+
import type { UseMutationResult } from '@tanstack/react-query';
|
|
2
2
|
interface BucketCommandInput {
|
|
3
3
|
Bucket: string | undefined;
|
|
4
4
|
}
|
|
@@ -10,7 +10,7 @@ interface UseDeleteBucketConfigRuleOptions<TRule extends {
|
|
|
10
10
|
rules: TRule[];
|
|
11
11
|
updateMutation: UseMutationResult<TUpdateOutput, TError, TUpdateInput, unknown>;
|
|
12
12
|
deleteMutation: UseMutationResult<TDeleteOutput, TError, TDeleteInput, unknown>;
|
|
13
|
-
buildUpdateInput: (remainingRules: TRule[]) => Omit<TUpdateInput,
|
|
13
|
+
buildUpdateInput: (remainingRules: TRule[]) => Omit<TUpdateInput, 'Bucket'>;
|
|
14
14
|
successMessage?: string;
|
|
15
15
|
errorMessage?: string;
|
|
16
16
|
onSuccess?: () => void;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useToast } from "@scality/core-ui";
|
|
2
|
-
function useDeleteBucketConfigRule({ bucketName, ruleId, rules, updateMutation, deleteMutation, buildUpdateInput, successMessage =
|
|
2
|
+
function useDeleteBucketConfigRule({ bucketName, ruleId, rules, updateMutation, deleteMutation, buildUpdateInput, successMessage = 'Rule deleted successfully', errorMessage = 'Failed to delete rule', onSuccess, onError }) {
|
|
3
3
|
const { showToast } = useToast();
|
|
4
4
|
const { mutate: updateConfig, status: updateStatus } = updateMutation;
|
|
5
5
|
const { mutate: deleteConfig, status: deleteStatus } = deleteMutation;
|
|
6
|
-
const isDeleting =
|
|
6
|
+
const isDeleting = 'pending' === updateStatus || 'pending' === deleteStatus;
|
|
7
7
|
const deleteRule = ()=>{
|
|
8
8
|
const remainingRules = rules.filter((rule)=>rule.ID !== ruleId);
|
|
9
9
|
const handleSuccess = ()=>{
|
|
10
10
|
showToast({
|
|
11
11
|
open: true,
|
|
12
12
|
message: successMessage,
|
|
13
|
-
status:
|
|
13
|
+
status: 'success'
|
|
14
14
|
});
|
|
15
15
|
onSuccess?.();
|
|
16
16
|
};
|
|
@@ -20,7 +20,7 @@ function useDeleteBucketConfigRule({ bucketName, ruleId, rules, updateMutation,
|
|
|
20
20
|
showToast({
|
|
21
21
|
open: true,
|
|
22
22
|
message: displayMessage,
|
|
23
|
-
status:
|
|
23
|
+
status: 'error'
|
|
24
24
|
});
|
|
25
25
|
onError?.(errorToReport);
|
|
26
26
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import { DeleteObjectsCommand, ListObjectVersionsCommand } from "@aws-sdk/client-s3";
|
|
1
2
|
import { useCallback, useState } from "react";
|
|
2
|
-
import {
|
|
3
|
+
import { useInvalidateQueries } from "../components/providers/DataBrowserProvider.js";
|
|
3
4
|
import { useS3Client } from "./useS3Client.js";
|
|
4
|
-
import { DeleteObjectsCommand, ListObjectVersionsCommand } from "@aws-sdk/client-s3";
|
|
5
5
|
const useEmptyBucket = (options = {})=>{
|
|
6
6
|
const { maxObjects = 20000, maxKeysPerList = 1000, bypassGovernanceRetention = true, onProgress, onSuccess, onError } = options;
|
|
7
7
|
const [isEmptying, setIsEmptying] = useState(false);
|
|
8
8
|
const [error, setError] = useState(null);
|
|
9
9
|
const [result, setResult] = useState(null);
|
|
10
10
|
const s3Client = useS3Client();
|
|
11
|
-
const
|
|
11
|
+
const invalidateQueries = useInvalidateQueries();
|
|
12
12
|
const emptyBucket = useCallback(async (bucketName)=>{
|
|
13
13
|
setIsEmptying(true);
|
|
14
14
|
setError(null);
|
|
@@ -50,7 +50,7 @@ const useEmptyBucket = (options = {})=>{
|
|
|
50
50
|
deletedCount += successCount;
|
|
51
51
|
totalAttempted += objectsToDelete.length;
|
|
52
52
|
if (deleteResponse.Errors) allErrors.push(...deleteResponse.Errors.map((error)=>({
|
|
53
|
-
key: error.Key ||
|
|
53
|
+
key: error.Key || 'unknown',
|
|
54
54
|
code: error.Code,
|
|
55
55
|
message: error.Message
|
|
56
56
|
})));
|
|
@@ -70,20 +70,20 @@ const useEmptyBucket = (options = {})=>{
|
|
|
70
70
|
limitReached
|
|
71
71
|
};
|
|
72
72
|
setResult(bucketResult);
|
|
73
|
-
|
|
73
|
+
invalidateQueries({
|
|
74
74
|
queryKey: [
|
|
75
|
-
|
|
75
|
+
'ListObjects'
|
|
76
76
|
]
|
|
77
77
|
});
|
|
78
|
-
|
|
78
|
+
invalidateQueries({
|
|
79
79
|
queryKey: [
|
|
80
|
-
|
|
80
|
+
'ListObjectVersions'
|
|
81
81
|
]
|
|
82
82
|
});
|
|
83
83
|
onSuccess?.(bucketResult);
|
|
84
84
|
return bucketResult;
|
|
85
85
|
} catch (err) {
|
|
86
|
-
const errorObj = err instanceof Error ? err : new Error(
|
|
86
|
+
const errorObj = err instanceof Error ? err : new Error('Failed to empty bucket');
|
|
87
87
|
setError(errorObj);
|
|
88
88
|
onError?.(errorObj);
|
|
89
89
|
return null;
|
|
@@ -92,13 +92,13 @@ const useEmptyBucket = (options = {})=>{
|
|
|
92
92
|
}
|
|
93
93
|
}, [
|
|
94
94
|
s3Client,
|
|
95
|
+
invalidateQueries,
|
|
95
96
|
maxObjects,
|
|
96
97
|
maxKeysPerList,
|
|
97
98
|
bypassGovernanceRetention,
|
|
98
99
|
onProgress,
|
|
99
100
|
onSuccess,
|
|
100
|
-
onError
|
|
101
|
-
queryClient
|
|
101
|
+
onError
|
|
102
102
|
]);
|
|
103
103
|
const reset = useCallback(()=>{
|
|
104
104
|
setIsEmptying(false);
|