@scality/data-browser-library 1.0.0-preview.8 → 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.d.ts +1 -0
- package/dist/components/__tests__/BucketCreate.test.js +574 -0
- 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 +14 -0
- package/dist/components/__tests__/BucketLifecycleFormPage.test.js +618 -0
- package/dist/components/__tests__/BucketLifecycleList.test.d.ts +1 -0
- package/dist/components/__tests__/BucketLifecycleList.test.js +325 -0
- package/dist/components/__tests__/BucketList.test.js +495 -81
- 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 +484 -179
- package/dist/components/__tests__/BucketPolicyPage.test.js +151 -99
- package/dist/components/__tests__/BucketReplicationFormPage.test.d.ts +16 -0
- package/dist/components/__tests__/BucketReplicationFormPage.test.js +1757 -0
- package/dist/components/__tests__/BucketReplicationList.test.d.ts +1 -0
- package/dist/components/__tests__/BucketReplicationList.test.js +344 -0
- package/dist/components/__tests__/CreateFolderButton.test.js +56 -56
- package/dist/components/__tests__/DeleteBucketButton.test.js +64 -64
- package/dist/components/__tests__/DeleteBucketConfigRuleButton.test.d.ts +1 -0
- package/dist/components/__tests__/DeleteBucketConfigRuleButton.test.js +196 -0
- package/dist/components/__tests__/DeleteObjectButton.test.js +64 -64
- package/dist/components/__tests__/EmptyBucketButton.test.d.ts +1 -0
- package/dist/components/__tests__/EmptyBucketButton.test.js +302 -0
- 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 +50 -0
- package/dist/components/buckets/BucketCreate.js +279 -0
- package/dist/components/buckets/BucketDetails.d.ts +42 -0
- package/dist/components/buckets/BucketDetails.js +256 -40
- package/dist/components/buckets/BucketLifecycleFormPage.d.ts +15 -0
- package/dist/components/buckets/BucketLifecycleFormPage.js +1086 -0
- package/dist/components/buckets/BucketLifecycleList.d.ts +10 -0
- package/dist/components/buckets/BucketLifecycleList.js +270 -0
- package/dist/components/buckets/BucketList.d.ts +6 -4
- package/dist/components/buckets/BucketList.js +161 -94
- package/dist/components/buckets/BucketLocation.js +4 -4
- package/dist/components/buckets/BucketOverview.d.ts +86 -5
- package/dist/components/buckets/BucketOverview.js +481 -192
- package/dist/components/buckets/BucketPage.js +44 -22
- package/dist/components/buckets/BucketPolicyPage.js +155 -127
- package/dist/components/buckets/BucketReplicationFormPage.d.ts +1 -0
- package/dist/components/buckets/BucketReplicationFormPage.js +835 -0
- package/dist/components/buckets/BucketReplicationList.d.ts +11 -0
- package/dist/components/buckets/BucketReplicationList.js +189 -0
- 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 +18 -0
- package/dist/components/buckets/DeleteBucketConfigRuleButton.js +53 -0
- package/dist/components/buckets/EmptyBucketButton.d.ts +5 -0
- package/dist/components/buckets/EmptyBucketButton.js +232 -0
- package/dist/components/buckets/EmptyBucketSummary.d.ts +9 -0
- package/dist/components/buckets/EmptyBucketSummary.js +60 -0
- package/dist/components/buckets/EmptyBucketSummaryList.d.ts +13 -0
- package/dist/components/buckets/EmptyBucketSummaryList.js +140 -0
- 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 -13
- package/dist/components/index.js +20 -6
- 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.d.ts +4 -0
- package/dist/components/objects/ObjectLock/EditRetentionButton.js +32 -0
- package/dist/components/objects/ObjectLock/ObjectLockRetentionSettings.d.ts +3 -0
- package/dist/components/objects/ObjectLock/ObjectLockRetentionSettings.js +211 -0
- package/dist/components/objects/ObjectLock/ObjectLockSettings.d.ts +9 -0
- package/dist/components/objects/ObjectLock/ObjectLockSettings.js +159 -0
- package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.d.ts +8 -0
- package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.js +39 -0
- package/dist/components/objects/ObjectLock/__tests__/EditRetentionButton.test.d.ts +1 -0
- package/dist/components/objects/ObjectLock/__tests__/EditRetentionButton.test.js +204 -0
- package/dist/components/objects/ObjectLock/__tests__/ObjectLockSettings.test.d.ts +1 -0
- package/dist/components/objects/ObjectLock/__tests__/ObjectLockSettings.test.js +374 -0
- 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.d.ts +36 -0
- package/dist/components/ui/ArrayFieldActions.js +43 -0
- package/dist/components/ui/ConfirmDeleteRuleModal.d.ts +16 -0
- package/dist/components/ui/ConfirmDeleteRuleModal.js +48 -0
- package/dist/components/ui/DeleteObjectModalContent.d.ts +1 -1
- package/dist/components/ui/DeleteObjectModalContent.js +12 -12
- package/dist/components/ui/FilterFormSection.d.ts +44 -0
- package/dist/components/ui/FilterFormSection.js +159 -0
- 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 +14 -49
- package/dist/config/factory.js +23 -68
- 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.d.ts +1 -0
- package/dist/hooks/__tests__/useISVBucketDetection.test.js +188 -0
- 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 +95 -52
- 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 +29 -3
- package/dist/hooks/index.d.ts +19 -8
- package/dist/hooks/index.js +16 -5
- 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 +26 -0
- package/dist/hooks/useDeleteBucketConfigRule.js +46 -0
- package/dist/hooks/useEmptyBucket.d.ts +27 -0
- package/dist/hooks/useEmptyBucket.js +116 -0
- package/dist/hooks/useFeatures.d.ts +7 -0
- package/dist/hooks/useFeatures.js +8 -0
- package/dist/hooks/useISVBucketDetection.d.ts +15 -0
- package/dist/hooks/useISVBucketDetection.js +27 -0
- 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/hooks/useTableRowSelection.d.ts +9 -0
- package/dist/hooks/useTableRowSelection.js +45 -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 +170 -36
- package/dist/test/testUtils.js +229 -116
- package/dist/test/utils/errorHandling.test.js +146 -108
- 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 +22 -0
- package/dist/utils/constants.js +19 -0
- 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 +12 -3
- package/dist/utils/errorHandling.js +12 -7
- package/dist/utils/hooks.js +8 -8
- package/dist/utils/index.d.ts +5 -2
- package/dist/utils/index.js +5 -1
- 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 +53 -0
- package/dist/utils/s3RuleUtils.js +101 -0
- 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
|
@@ -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 };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { UseMutationResult } from '@tanstack/react-query';
|
|
2
|
+
interface BucketCommandInput {
|
|
3
|
+
Bucket: string | undefined;
|
|
4
|
+
}
|
|
5
|
+
interface UseDeleteBucketConfigRuleOptions<TRule extends {
|
|
6
|
+
ID?: string;
|
|
7
|
+
}, TUpdateInput extends BucketCommandInput, TUpdateOutput, TDeleteInput extends BucketCommandInput, TDeleteOutput, TError = unknown> {
|
|
8
|
+
bucketName: string;
|
|
9
|
+
ruleId: string;
|
|
10
|
+
rules: TRule[];
|
|
11
|
+
updateMutation: UseMutationResult<TUpdateOutput, TError, TUpdateInput, unknown>;
|
|
12
|
+
deleteMutation: UseMutationResult<TDeleteOutput, TError, TDeleteInput, unknown>;
|
|
13
|
+
buildUpdateInput: (remainingRules: TRule[]) => Omit<TUpdateInput, 'Bucket'>;
|
|
14
|
+
successMessage?: string;
|
|
15
|
+
errorMessage?: string;
|
|
16
|
+
onSuccess?: () => void;
|
|
17
|
+
onError?: (error: Error) => void;
|
|
18
|
+
}
|
|
19
|
+
interface UseDeleteBucketConfigRuleReturn {
|
|
20
|
+
isDeleting: boolean;
|
|
21
|
+
deleteRule: () => void;
|
|
22
|
+
}
|
|
23
|
+
export declare function useDeleteBucketConfigRule<TRule extends {
|
|
24
|
+
ID?: string;
|
|
25
|
+
}, TUpdateInput extends BucketCommandInput = BucketCommandInput, TUpdateOutput = unknown, TDeleteInput extends BucketCommandInput = BucketCommandInput, TDeleteOutput = unknown, TError = unknown>({ bucketName, ruleId, rules, updateMutation, deleteMutation, buildUpdateInput, successMessage, errorMessage, onSuccess, onError, }: UseDeleteBucketConfigRuleOptions<TRule, TUpdateInput, TUpdateOutput, TDeleteInput, TDeleteOutput, TError>): UseDeleteBucketConfigRuleReturn;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useToast } from "@scality/core-ui";
|
|
2
|
+
function useDeleteBucketConfigRule({ bucketName, ruleId, rules, updateMutation, deleteMutation, buildUpdateInput, successMessage = 'Rule deleted successfully', errorMessage = 'Failed to delete rule', onSuccess, onError }) {
|
|
3
|
+
const { showToast } = useToast();
|
|
4
|
+
const { mutate: updateConfig, status: updateStatus } = updateMutation;
|
|
5
|
+
const { mutate: deleteConfig, status: deleteStatus } = deleteMutation;
|
|
6
|
+
const isDeleting = 'pending' === updateStatus || 'pending' === deleteStatus;
|
|
7
|
+
const deleteRule = ()=>{
|
|
8
|
+
const remainingRules = rules.filter((rule)=>rule.ID !== ruleId);
|
|
9
|
+
const handleSuccess = ()=>{
|
|
10
|
+
showToast({
|
|
11
|
+
open: true,
|
|
12
|
+
message: successMessage,
|
|
13
|
+
status: 'success'
|
|
14
|
+
});
|
|
15
|
+
onSuccess?.();
|
|
16
|
+
};
|
|
17
|
+
const handleError = (error)=>{
|
|
18
|
+
const displayMessage = error instanceof Error && error.message ? error.message : errorMessage;
|
|
19
|
+
const errorToReport = error instanceof Error ? error : new Error(displayMessage);
|
|
20
|
+
showToast({
|
|
21
|
+
open: true,
|
|
22
|
+
message: displayMessage,
|
|
23
|
+
status: 'error'
|
|
24
|
+
});
|
|
25
|
+
onError?.(errorToReport);
|
|
26
|
+
};
|
|
27
|
+
if (0 === remainingRules.length) deleteConfig({
|
|
28
|
+
Bucket: bucketName
|
|
29
|
+
}, {
|
|
30
|
+
onSuccess: handleSuccess,
|
|
31
|
+
onError: handleError
|
|
32
|
+
});
|
|
33
|
+
else updateConfig({
|
|
34
|
+
Bucket: bucketName,
|
|
35
|
+
...buildUpdateInput(remainingRules)
|
|
36
|
+
}, {
|
|
37
|
+
onSuccess: handleSuccess,
|
|
38
|
+
onError: handleError
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
isDeleting,
|
|
43
|
+
deleteRule
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export { useDeleteBucketConfigRule };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface EmptyBucketResult {
|
|
2
|
+
success: boolean;
|
|
3
|
+
deletedCount: number;
|
|
4
|
+
errors: Array<{
|
|
5
|
+
key: string;
|
|
6
|
+
code?: string;
|
|
7
|
+
message?: string;
|
|
8
|
+
}>;
|
|
9
|
+
limitReached: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface UseEmptyBucketOptions {
|
|
12
|
+
maxObjects?: number;
|
|
13
|
+
maxKeysPerList?: number;
|
|
14
|
+
bypassGovernanceRetention?: boolean;
|
|
15
|
+
onProgress?: (deletedCount: number, totalAttempted: number) => void;
|
|
16
|
+
onSuccess?: (result: EmptyBucketResult) => void;
|
|
17
|
+
onError?: (error: Error) => void;
|
|
18
|
+
}
|
|
19
|
+
interface UseEmptyBucketReturn {
|
|
20
|
+
emptyBucket: (bucketName: string) => Promise<EmptyBucketResult | null>;
|
|
21
|
+
isEmptying: boolean;
|
|
22
|
+
error: Error | null;
|
|
23
|
+
result: EmptyBucketResult | null;
|
|
24
|
+
reset: () => void;
|
|
25
|
+
}
|
|
26
|
+
export declare const useEmptyBucket: (options?: UseEmptyBucketOptions) => UseEmptyBucketReturn;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { DeleteObjectsCommand, ListObjectVersionsCommand } from "@aws-sdk/client-s3";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
import { useInvalidateQueries } from "../components/providers/DataBrowserProvider.js";
|
|
4
|
+
import { useS3Client } from "./useS3Client.js";
|
|
5
|
+
const useEmptyBucket = (options = {})=>{
|
|
6
|
+
const { maxObjects = 20000, maxKeysPerList = 1000, bypassGovernanceRetention = true, onProgress, onSuccess, onError } = options;
|
|
7
|
+
const [isEmptying, setIsEmptying] = useState(false);
|
|
8
|
+
const [error, setError] = useState(null);
|
|
9
|
+
const [result, setResult] = useState(null);
|
|
10
|
+
const s3Client = useS3Client();
|
|
11
|
+
const invalidateQueries = useInvalidateQueries();
|
|
12
|
+
const emptyBucket = useCallback(async (bucketName)=>{
|
|
13
|
+
setIsEmptying(true);
|
|
14
|
+
setError(null);
|
|
15
|
+
setResult(null);
|
|
16
|
+
try {
|
|
17
|
+
let deletedCount = 0;
|
|
18
|
+
let totalAttempted = 0;
|
|
19
|
+
let keyMarker;
|
|
20
|
+
let versionIdMarker;
|
|
21
|
+
const allErrors = [];
|
|
22
|
+
let limitReached = false;
|
|
23
|
+
while(totalAttempted < maxObjects){
|
|
24
|
+
const listCommand = new ListObjectVersionsCommand({
|
|
25
|
+
Bucket: bucketName,
|
|
26
|
+
MaxKeys: maxKeysPerList,
|
|
27
|
+
KeyMarker: keyMarker,
|
|
28
|
+
VersionIdMarker: versionIdMarker
|
|
29
|
+
});
|
|
30
|
+
const listResponse = await s3Client.send(listCommand);
|
|
31
|
+
const objectsToDelete = [];
|
|
32
|
+
if (listResponse.Versions) objectsToDelete.push(...listResponse.Versions.filter((v)=>v.Key).map((v)=>({
|
|
33
|
+
Key: v.Key,
|
|
34
|
+
VersionId: v.VersionId
|
|
35
|
+
})));
|
|
36
|
+
if (listResponse.DeleteMarkers) objectsToDelete.push(...listResponse.DeleteMarkers.filter((dm)=>dm.Key).map((dm)=>({
|
|
37
|
+
Key: dm.Key,
|
|
38
|
+
VersionId: dm.VersionId
|
|
39
|
+
})));
|
|
40
|
+
if (0 === objectsToDelete.length) break;
|
|
41
|
+
const deleteCommand = new DeleteObjectsCommand({
|
|
42
|
+
Bucket: bucketName,
|
|
43
|
+
Delete: {
|
|
44
|
+
Objects: objectsToDelete
|
|
45
|
+
},
|
|
46
|
+
BypassGovernanceRetention: bypassGovernanceRetention
|
|
47
|
+
});
|
|
48
|
+
const deleteResponse = await s3Client.send(deleteCommand);
|
|
49
|
+
const successCount = deleteResponse.Deleted?.length || 0;
|
|
50
|
+
deletedCount += successCount;
|
|
51
|
+
totalAttempted += objectsToDelete.length;
|
|
52
|
+
if (deleteResponse.Errors) allErrors.push(...deleteResponse.Errors.map((error)=>({
|
|
53
|
+
key: error.Key || 'unknown',
|
|
54
|
+
code: error.Code,
|
|
55
|
+
message: error.Message
|
|
56
|
+
})));
|
|
57
|
+
onProgress?.(deletedCount, totalAttempted);
|
|
58
|
+
if (!listResponse.IsTruncated) break;
|
|
59
|
+
if (totalAttempted >= maxObjects) {
|
|
60
|
+
limitReached = true;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
keyMarker = listResponse.NextKeyMarker;
|
|
64
|
+
versionIdMarker = listResponse.NextVersionIdMarker;
|
|
65
|
+
}
|
|
66
|
+
const bucketResult = {
|
|
67
|
+
success: 0 === allErrors.length,
|
|
68
|
+
deletedCount,
|
|
69
|
+
errors: allErrors,
|
|
70
|
+
limitReached
|
|
71
|
+
};
|
|
72
|
+
setResult(bucketResult);
|
|
73
|
+
invalidateQueries({
|
|
74
|
+
queryKey: [
|
|
75
|
+
'ListObjects'
|
|
76
|
+
]
|
|
77
|
+
});
|
|
78
|
+
invalidateQueries({
|
|
79
|
+
queryKey: [
|
|
80
|
+
'ListObjectVersions'
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
onSuccess?.(bucketResult);
|
|
84
|
+
return bucketResult;
|
|
85
|
+
} catch (err) {
|
|
86
|
+
const errorObj = err instanceof Error ? err : new Error('Failed to empty bucket');
|
|
87
|
+
setError(errorObj);
|
|
88
|
+
onError?.(errorObj);
|
|
89
|
+
return null;
|
|
90
|
+
} finally{
|
|
91
|
+
setIsEmptying(false);
|
|
92
|
+
}
|
|
93
|
+
}, [
|
|
94
|
+
s3Client,
|
|
95
|
+
invalidateQueries,
|
|
96
|
+
maxObjects,
|
|
97
|
+
maxKeysPerList,
|
|
98
|
+
bypassGovernanceRetention,
|
|
99
|
+
onProgress,
|
|
100
|
+
onSuccess,
|
|
101
|
+
onError
|
|
102
|
+
]);
|
|
103
|
+
const reset = useCallback(()=>{
|
|
104
|
+
setIsEmptying(false);
|
|
105
|
+
setError(null);
|
|
106
|
+
setResult(null);
|
|
107
|
+
}, []);
|
|
108
|
+
return {
|
|
109
|
+
emptyBucket,
|
|
110
|
+
isEmptying,
|
|
111
|
+
error,
|
|
112
|
+
result,
|
|
113
|
+
reset
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
export { useEmptyBucket };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to check if a feature is enabled in the S3 configuration.
|
|
3
|
+
*
|
|
4
|
+
* @param feature - The feature name to check
|
|
5
|
+
* @returns true if enabled, false if disabled, undefined if config not available
|
|
6
|
+
*/
|
|
7
|
+
export declare function useFeatures(feature: string): boolean | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useDataBrowserContext } from "../components/providers/DataBrowserProvider.js";
|
|
2
|
+
function useFeatures(feature) {
|
|
3
|
+
const { getS3Config } = useDataBrowserContext();
|
|
4
|
+
if (!getS3Config) return;
|
|
5
|
+
const config = getS3Config();
|
|
6
|
+
return config.features?.includes(feature) ?? false;
|
|
7
|
+
}
|
|
8
|
+
export { useFeatures };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to detect if a bucket is managed by any ISV (Veeam or Commvault)
|
|
3
|
+
* Returns comprehensive information about ISV bucket status
|
|
4
|
+
*
|
|
5
|
+
* This hook fetches bucket tags once and derives all ISV-related states from it,
|
|
6
|
+
* avoiding multiple API calls for the same data.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useISVBucketStatus: (bucketName: string) => {
|
|
9
|
+
isVeeamBucket: boolean;
|
|
10
|
+
isCommvaultBucket: boolean;
|
|
11
|
+
isISVManaged: boolean;
|
|
12
|
+
isvApplication: string | undefined;
|
|
13
|
+
isLoading: boolean | undefined;
|
|
14
|
+
bucketTagsStatus: "error" | "success" | "pending";
|
|
15
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BUCKET_TAG_APPLICATION, BUCKET_TAG_VEEAM_APPLICATION, COMMVAULT_APPLICATION, VEEAM_BACKUP_REPLICATION, VEEAM_OFFICE_365, VEEAM_OFFICE_365_V8, VEEAM_VBO_APPLICATION } from "../utils/constants.js";
|
|
2
|
+
import { useGetBucketTagging } from "./bucketConfiguration.js";
|
|
3
|
+
import { useFeatures } from "./useFeatures.js";
|
|
4
|
+
const useISVBucketStatus = (bucketName)=>{
|
|
5
|
+
const isISVFeatureEnabled = useFeatures('ISV');
|
|
6
|
+
const { data: bucketTags, status: bucketTagsStatus } = useGetBucketTagging({
|
|
7
|
+
Bucket: bucketName
|
|
8
|
+
}, {
|
|
9
|
+
enabled: true === isISVFeatureEnabled
|
|
10
|
+
});
|
|
11
|
+
const veeamTagApplication = bucketTags?.TagSet?.find((tag)=>tag.Key === BUCKET_TAG_VEEAM_APPLICATION)?.Value;
|
|
12
|
+
const ISVApplicationTag = bucketTags?.TagSet?.find((tag)=>tag.Key === BUCKET_TAG_APPLICATION)?.Value;
|
|
13
|
+
const isVeeamBucket = veeamTagApplication === VEEAM_BACKUP_REPLICATION || veeamTagApplication === VEEAM_OFFICE_365 || veeamTagApplication === VEEAM_OFFICE_365_V8;
|
|
14
|
+
const isISVBucketTagAsVeeam = ISVApplicationTag === VEEAM_BACKUP_REPLICATION || ISVApplicationTag === VEEAM_VBO_APPLICATION;
|
|
15
|
+
const isCommvaultBucket = ISVApplicationTag === COMMVAULT_APPLICATION;
|
|
16
|
+
const isVeeam = isVeeamBucket || isISVBucketTagAsVeeam;
|
|
17
|
+
const isISVManaged = isVeeam || isCommvaultBucket;
|
|
18
|
+
return {
|
|
19
|
+
isVeeamBucket: isVeeam,
|
|
20
|
+
isCommvaultBucket,
|
|
21
|
+
isISVManaged,
|
|
22
|
+
isvApplication: isCommvaultBucket ? 'Commvault' : isVeeam ? 'Veeam' : void 0,
|
|
23
|
+
isLoading: isISVFeatureEnabled && 'pending' === bucketTagsStatus,
|
|
24
|
+
bucketTagsStatus
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export { useISVBucketStatus };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
2
|
import { useListObjects } from "./objectOperations.js";
|
|
3
|
-
const isInfiniteData = (data)=>null != data &&
|
|
3
|
+
const isInfiniteData = (data)=>null != data && 'object' == typeof data && 'pages' in data && Array.isArray(data.pages);
|
|
4
4
|
const useIsBucketEmpty = (bucketName)=>{
|
|
5
5
|
const { data, status, error } = useListObjects({
|
|
6
6
|
Bucket: bucketName,
|
|
7
7
|
MaxKeys: 1,
|
|
8
|
-
Delimiter:
|
|
8
|
+
Delimiter: '/'
|
|
9
9
|
}, {
|
|
10
10
|
enabled: !!bucketName
|
|
11
11
|
});
|
|
12
12
|
const isEmpty = useMemo(()=>{
|
|
13
|
-
if (
|
|
13
|
+
if ('pending' === status || !data) return null;
|
|
14
14
|
if (!isInfiniteData(data)) return null;
|
|
15
15
|
for (const page of data.pages){
|
|
16
16
|
if (page?.Contents && page.Contents.length > 0) {
|
|
@@ -29,7 +29,7 @@ const useIsBucketEmpty = (bucketName)=>{
|
|
|
29
29
|
]);
|
|
30
30
|
return {
|
|
31
31
|
isEmpty,
|
|
32
|
-
isLoading:
|
|
32
|
+
isLoading: 'pending' === status,
|
|
33
33
|
error: error instanceof Error ? error : null
|
|
34
34
|
};
|
|
35
35
|
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Limited Access Flow Orchestrator
|
|
3
|
+
*
|
|
4
|
+
* This module centralizes all logic related to handling users with limited S3 permissions
|
|
5
|
+
* (specifically users who lack ListBuckets permission but have access to specific buckets).
|
|
6
|
+
*
|
|
7
|
+
* It provides a clean abstraction that:
|
|
8
|
+
* - Encapsulates storage key patterns
|
|
9
|
+
* - Manages the limited access flag
|
|
10
|
+
* - Provides navigation logic
|
|
11
|
+
* - Coordinates between authentication, storage, and routing
|
|
12
|
+
*/
|
|
13
|
+
import type { LoginConfig } from './loginOperations';
|
|
14
|
+
export interface UseLimitedAccessFlowOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Callback invoked when a user successfully authenticates with limited access.
|
|
17
|
+
* This should be used to persist the config and transition the app state.
|
|
18
|
+
*/
|
|
19
|
+
onLimitedAccessGranted: (config: LoginConfig) => void;
|
|
20
|
+
}
|
|
21
|
+
export interface LimitedAccessFlowHandlers {
|
|
22
|
+
/**
|
|
23
|
+
* Activates the limited access flow for a given S3 configuration.
|
|
24
|
+
* Sets the necessary flags and navigates to the bucket accessor form.
|
|
25
|
+
*/
|
|
26
|
+
activateLimitedAccessFlow: (config: LoginConfig) => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Hook that orchestrates the limited access flow.
|
|
30
|
+
*
|
|
31
|
+
* This hook provides methods to activate and check the limited access mode
|
|
32
|
+
* for users who lack ListBuckets permission.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* const { activateLimitedAccessFlow } = useLimitedAccessFlow({
|
|
37
|
+
* onLimitedAccessGranted: (config) => {
|
|
38
|
+
* setAppConfig(config);
|
|
39
|
+
* }
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* // In login error handler:
|
|
43
|
+
* if (error.name === 'AccessDenied') {
|
|
44
|
+
* activateLimitedAccessFlow(variables);
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare const useLimitedAccessFlow: (options: UseLimitedAccessFlowOptions) => LimitedAccessFlowHandlers;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useNavigate } from "react-router";
|
|
3
|
+
import { computeS3ConfigIdentifier } from "../utils/s3ConfigIdentifier.js";
|
|
4
|
+
import { setLimitedAccessFlag } from "./useAccessibleBuckets.js";
|
|
5
|
+
const useLimitedAccessFlow = (options)=>{
|
|
6
|
+
const navigate = useNavigate();
|
|
7
|
+
const { onLimitedAccessGranted } = options;
|
|
8
|
+
const activateLimitedAccessFlow = useCallback((config)=>{
|
|
9
|
+
const s3ConfigIdentifier = computeS3ConfigIdentifier(config);
|
|
10
|
+
setLimitedAccessFlag(s3ConfigIdentifier, true);
|
|
11
|
+
onLimitedAccessGranted(config);
|
|
12
|
+
navigate('/buckets/-/access', {
|
|
13
|
+
replace: true
|
|
14
|
+
});
|
|
15
|
+
}, [
|
|
16
|
+
navigate,
|
|
17
|
+
onLimitedAccessGranted
|
|
18
|
+
]);
|
|
19
|
+
return {
|
|
20
|
+
activateLimitedAccessFlow
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export { useLimitedAccessFlow };
|
|
@@ -2,12 +2,13 @@ import { useMemo } from "react";
|
|
|
2
2
|
import { useDataBrowserContext } from "../components/providers/DataBrowserProvider.js";
|
|
3
3
|
import { createS3Client } from "../utils/s3Client.js";
|
|
4
4
|
const useS3Client = ()=>{
|
|
5
|
-
const { getS3Config } = useDataBrowserContext();
|
|
5
|
+
const { s3ConfigIdentifier, getS3Config } = useDataBrowserContext();
|
|
6
|
+
if (!getS3Config) throw new Error('useS3Client: S3 config not available. Ensure DataBrowserProvider has getS3Config prop set.');
|
|
6
7
|
return useMemo(()=>{
|
|
7
8
|
const config = getS3Config();
|
|
8
9
|
return createS3Client(config);
|
|
9
10
|
}, [
|
|
10
|
-
|
|
11
|
+
s3ConfigIdentifier
|
|
11
12
|
]);
|
|
12
13
|
};
|
|
13
14
|
export { useS3Client };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook that handles navigation and query cleanup when S3 config changes.
|
|
3
|
+
* Must be used inside both DataBrowserProvider and DataBrowserUICustomizationProvider.
|
|
4
|
+
*
|
|
5
|
+
* When the S3 config identifier changes:
|
|
6
|
+
* - Navigates to the buckets page first (to trigger component unmounting)
|
|
7
|
+
* - Clears all queries associated with the previous config (after navigation)
|
|
8
|
+
*
|
|
9
|
+
* @internal This hook is designed for internal use within DataBrowserUI only.
|
|
10
|
+
*/
|
|
11
|
+
export declare const useS3ConfigSwitch: () => void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
import { useNavigate } from "react-router";
|
|
4
|
+
import { useDataBrowserContext } from "../components/providers/DataBrowserProvider.js";
|
|
5
|
+
import { useDataBrowserUICustomization } from "../contexts/DataBrowserUICustomizationContext.js";
|
|
6
|
+
import { normalizePath } from "./useDataBrowserNavigate.js";
|
|
7
|
+
const useS3ConfigSwitch = ()=>{
|
|
8
|
+
const { s3ConfigIdentifier } = useDataBrowserContext();
|
|
9
|
+
const { basePath = '' } = useDataBrowserUICustomization();
|
|
10
|
+
const queryClient = useQueryClient();
|
|
11
|
+
const navigate = useNavigate();
|
|
12
|
+
const prevConfigIdRef = useRef();
|
|
13
|
+
useEffect(()=>{
|
|
14
|
+
if (void 0 !== prevConfigIdRef.current && prevConfigIdRef.current !== s3ConfigIdentifier) {
|
|
15
|
+
const previousConfigId = prevConfigIdRef.current;
|
|
16
|
+
const bucketsPath = normalizePath(basePath, '/buckets');
|
|
17
|
+
navigate(bucketsPath, {
|
|
18
|
+
replace: true
|
|
19
|
+
});
|
|
20
|
+
queueMicrotask(()=>{
|
|
21
|
+
queryClient.removeQueries({
|
|
22
|
+
queryKey: [
|
|
23
|
+
previousConfigId
|
|
24
|
+
],
|
|
25
|
+
exact: false
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
prevConfigIdRef.current = s3ConfigIdentifier;
|
|
30
|
+
}, [
|
|
31
|
+
s3ConfigIdentifier,
|
|
32
|
+
navigate,
|
|
33
|
+
basePath,
|
|
34
|
+
queryClient
|
|
35
|
+
]);
|
|
36
|
+
};
|
|
37
|
+
export { useS3ConfigSwitch };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { S3EventType } from '../config/types';
|
|
2
|
+
/**
|
|
3
|
+
* Hook to get supported notification events from the DataBrowser configuration
|
|
4
|
+
* If no supported events are configured, returns undefined (meaning all events are supported)
|
|
5
|
+
*/
|
|
6
|
+
export declare function useSupportedNotificationEvents(): S3EventType[] | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useDataBrowserContext } from "../components/providers/DataBrowserProvider.js";
|
|
2
|
+
function useSupportedNotificationEvents() {
|
|
3
|
+
const { getS3Config } = useDataBrowserContext();
|
|
4
|
+
if (!getS3Config) return;
|
|
5
|
+
const config = getS3Config();
|
|
6
|
+
return config?.s3Capabilities?.supportedNotificationEvents;
|
|
7
|
+
}
|
|
8
|
+
export { useSupportedNotificationEvents };
|