@scality/data-browser-library 1.0.0-preview.11
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/Editor.d.ts +12 -0
- package/dist/components/Editor.js +28 -0
- package/dist/components/__tests__/BucketCreate.test.d.ts +1 -0
- package/dist/components/__tests__/BucketCreate.test.js +408 -0
- package/dist/components/__tests__/BucketLifecycleFormPage.test.d.ts +1 -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.d.ts +1 -0
- package/dist/components/__tests__/BucketList.test.js +415 -0
- package/dist/components/__tests__/BucketNotificationCreatePage.test.d.ts +1 -0
- package/dist/components/__tests__/BucketNotificationCreatePage.test.js +316 -0
- package/dist/components/__tests__/BucketOverview.test.d.ts +1 -0
- package/dist/components/__tests__/BucketOverview.test.js +769 -0
- package/dist/components/__tests__/BucketPolicyPage.test.d.ts +1 -0
- package/dist/components/__tests__/BucketPolicyPage.test.js +268 -0
- package/dist/components/__tests__/BucketReplicationFormPage.test.d.ts +1 -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.d.ts +1 -0
- package/dist/components/__tests__/CreateFolderButton.test.js +147 -0
- package/dist/components/__tests__/DeleteBucketButton.test.d.ts +1 -0
- package/dist/components/__tests__/DeleteBucketButton.test.js +272 -0
- 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.d.ts +1 -0
- package/dist/components/__tests__/DeleteObjectButton.test.js +302 -0
- 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.d.ts +1 -0
- package/dist/components/__tests__/MetadataSearch.test.js +201 -0
- package/dist/components/__tests__/ObjectList.test.d.ts +1 -0
- package/dist/components/__tests__/ObjectList.test.js +283 -0
- package/dist/components/__tests__/UploadButton.test.d.ts +1 -0
- package/dist/components/__tests__/UploadButton.test.js +144 -0
- package/dist/components/buckets/BucketCreate.d.ts +49 -0
- package/dist/components/buckets/BucketCreate.js +237 -0
- package/dist/components/buckets/BucketDetails.d.ts +1 -0
- package/dist/components/buckets/BucketDetails.js +106 -0
- package/dist/components/buckets/BucketLifecycleFormPage.d.ts +15 -0
- package/dist/components/buckets/BucketLifecycleFormPage.js +1085 -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 +15 -0
- package/dist/components/buckets/BucketList.js +146 -0
- package/dist/components/buckets/BucketLocation.d.ts +3 -0
- package/dist/components/buckets/BucketLocation.js +16 -0
- package/dist/components/buckets/BucketOverview.d.ts +88 -0
- package/dist/components/buckets/BucketOverview.js +291 -0
- package/dist/components/buckets/BucketPage.d.ts +2 -0
- package/dist/components/buckets/BucketPage.js +47 -0
- package/dist/components/buckets/BucketPolicyButton.d.ts +7 -0
- package/dist/components/buckets/BucketPolicyButton.js +18 -0
- package/dist/components/buckets/BucketPolicyPage.d.ts +1 -0
- package/dist/components/buckets/BucketPolicyPage.js +236 -0
- package/dist/components/buckets/BucketReplicationFormPage.d.ts +1 -0
- package/dist/components/buckets/BucketReplicationFormPage.js +834 -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 +73 -0
- package/dist/components/buckets/DeleteBucketButton.d.ts +8 -0
- package/dist/components/buckets/DeleteBucketButton.js +78 -0
- 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/BucketNotificationCreatePage.d.ts +1 -0
- package/dist/components/buckets/notifications/BucketNotificationCreatePage.js +234 -0
- package/dist/components/buckets/notifications/EventsSection.d.ts +1 -0
- package/dist/components/buckets/notifications/EventsSection.js +123 -0
- package/dist/components/buckets/notifications/events.d.ts +12 -0
- package/dist/components/buckets/notifications/events.js +27 -0
- package/dist/components/index.d.ts +21 -0
- package/dist/components/index.js +22 -0
- package/dist/components/layouts/ArrowNavigation.d.ts +4 -0
- package/dist/components/layouts/ArrowNavigation.js +16 -0
- package/dist/components/layouts/BrowserPageLayout.d.ts +12 -0
- package/dist/components/layouts/BrowserPageLayout.js +51 -0
- package/dist/components/objects/CreateFolderButton.d.ts +29 -0
- package/dist/components/objects/CreateFolderButton.js +118 -0
- package/dist/components/objects/DeleteObjectButton.d.ts +8 -0
- package/dist/components/objects/DeleteObjectButton.js +191 -0
- package/dist/components/objects/ObjectDetails/ObjectMetadata.d.ts +2 -0
- package/dist/components/objects/ObjectDetails/ObjectMetadata.js +356 -0
- package/dist/components/objects/ObjectDetails/ObjectSummary.d.ts +3 -0
- package/dist/components/objects/ObjectDetails/ObjectSummary.js +241 -0
- package/dist/components/objects/ObjectDetails/ObjectTags.d.ts +3 -0
- package/dist/components/objects/ObjectDetails/ObjectTags.js +272 -0
- package/dist/components/objects/ObjectDetails/index.d.ts +9 -0
- package/dist/components/objects/ObjectDetails/index.js +75 -0
- package/dist/components/objects/ObjectList.d.ts +40 -0
- package/dist/components/objects/ObjectList.js +453 -0
- 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 +158 -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.d.ts +1 -0
- package/dist/components/objects/ObjectPage.js +45 -0
- package/dist/components/objects/UploadButton.d.ts +34 -0
- package/dist/components/objects/UploadButton.js +229 -0
- package/dist/components/providers/DataBrowserProvider.d.ts +20 -0
- package/dist/components/providers/DataBrowserProvider.js +42 -0
- package/dist/components/search/MetadataSearch.d.ts +5 -0
- package/dist/components/search/MetadataSearch.js +162 -0
- package/dist/components/search/SearchHints.d.ts +8 -0
- package/dist/components/search/SearchHints.js +21 -0
- 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 +43 -0
- package/dist/components/ui/DeleteObjectModalContent.d.ts +5 -0
- package/dist/components/ui/DeleteObjectModalContent.js +71 -0
- 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 +17 -0
- package/dist/components/ui/Search.elements.js +59 -0
- package/dist/components/ui/Table.elements.d.ts +36 -0
- package/dist/components/ui/Table.elements.js +87 -0
- package/dist/config/factory.d.ts +63 -0
- package/dist/config/factory.js +74 -0
- package/dist/config/types.d.ts +46 -0
- package/dist/config/types.js +0 -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.d.ts +1 -0
- package/dist/hooks/__tests__/useIsBucketEmpty.test.js +122 -0
- package/dist/hooks/bucketConfiguration.d.ts +168 -0
- package/dist/hooks/bucketConfiguration.js +67 -0
- package/dist/hooks/bucketOperations.d.ts +36 -0
- package/dist/hooks/bucketOperations.js +12 -0
- package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.d.ts +1 -0
- package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.js +276 -0
- package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.d.ts +1 -0
- package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.js +259 -0
- package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.d.ts +1 -0
- package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.js +166 -0
- package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.d.ts +1 -0
- package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.js +200 -0
- package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.d.ts +1 -0
- package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.js +179 -0
- package/dist/hooks/factories/index.d.ts +18 -0
- package/dist/hooks/factories/index.js +5 -0
- package/dist/hooks/factories/useCreateS3InfiniteQueryHook.d.ts +13 -0
- package/dist/hooks/factories/useCreateS3InfiniteQueryHook.js +76 -0
- package/dist/hooks/factories/useCreateS3LoginHook.d.ts +8 -0
- package/dist/hooks/factories/useCreateS3LoginHook.js +22 -0
- package/dist/hooks/factories/useCreateS3MutationHook.d.ts +5 -0
- package/dist/hooks/factories/useCreateS3MutationHook.js +50 -0
- package/dist/hooks/factories/useCreateS3QueryHook.d.ts +3 -0
- package/dist/hooks/factories/useCreateS3QueryHook.js +51 -0
- package/dist/hooks/index.d.ts +13 -0
- package/dist/hooks/index.js +13 -0
- package/dist/hooks/loginOperations.d.ts +21 -0
- package/dist/hooks/loginOperations.js +9 -0
- package/dist/hooks/objectOperations.d.ts +190 -0
- package/dist/hooks/objectOperations.js +67 -0
- package/dist/hooks/presignedOperations.d.ts +73 -0
- package/dist/hooks/presignedOperations.js +72 -0
- package/dist/hooks/useBatchObjectLegalHold.d.ts +11 -0
- package/dist/hooks/useBatchObjectLegalHold.js +45 -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/useISVBucketDetection.d.ts +15 -0
- package/dist/hooks/useISVBucketDetection.js +27 -0
- package/dist/hooks/useIsBucketEmpty.d.ts +7 -0
- package/dist/hooks/useIsBucketEmpty.js +36 -0
- package/dist/hooks/useLoginMutation.d.ts +21 -0
- package/dist/hooks/useLoginMutation.js +9 -0
- package/dist/hooks/useS3Client.d.ts +1 -0
- package/dist/hooks/useS3Client.js +13 -0
- package/dist/hooks/useTableRowSelection.d.ts +9 -0
- package/dist/hooks/useTableRowSelection.js +45 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/schemas/bucketPolicySchema.json +321 -0
- package/dist/test/msw/handlers/deleteBucket.d.ts +1 -0
- package/dist/test/msw/handlers/deleteBucket.js +14 -0
- package/dist/test/msw/handlers/getBucketAcl.d.ts +1 -0
- package/dist/test/msw/handlers/getBucketAcl.js +96 -0
- package/dist/test/msw/handlers/getBucketLocation.d.ts +1 -0
- package/dist/test/msw/handlers/getBucketLocation.js +23 -0
- package/dist/test/msw/handlers/getBucketPolicy.d.ts +11 -0
- package/dist/test/msw/handlers/getBucketPolicy.js +72 -0
- package/dist/test/msw/handlers/headObject.d.ts +1 -0
- package/dist/test/msw/handlers/headObject.js +17 -0
- package/dist/test/msw/handlers/listBuckets.d.ts +1 -0
- package/dist/test/msw/handlers/listBuckets.js +24 -0
- package/dist/test/msw/handlers/listObjectVersions.d.ts +1 -0
- package/dist/test/msw/handlers/listObjectVersions.js +83 -0
- package/dist/test/msw/handlers/listObjects.d.ts +1 -0
- package/dist/test/msw/handlers/listObjects.js +66 -0
- package/dist/test/msw/handlers/objectLegalHold.d.ts +1 -0
- package/dist/test/msw/handlers/objectLegalHold.js +24 -0
- package/dist/test/msw/handlers/objectRetention.d.ts +1 -0
- package/dist/test/msw/handlers/objectRetention.js +27 -0
- package/dist/test/msw/handlers/putBucketAcl.d.ts +1 -0
- package/dist/test/msw/handlers/putBucketAcl.js +18 -0
- package/dist/test/msw/handlers/putObject.d.ts +1 -0
- package/dist/test/msw/handlers/putObject.js +16 -0
- package/dist/test/msw/handlers.d.ts +4 -0
- package/dist/test/msw/handlers.js +109 -0
- package/dist/test/msw/index.d.ts +2 -0
- package/dist/test/msw/index.js +3 -0
- package/dist/test/msw/server.d.ts +4 -0
- package/dist/test/msw/server.js +20 -0
- package/dist/test/msw/utils.d.ts +2 -0
- package/dist/test/msw/utils.js +13 -0
- package/dist/test/setup.d.ts +1 -0
- package/dist/test/setup.js +90 -0
- package/dist/test/testUtils.d.ts +181 -0
- package/dist/test/testUtils.js +310 -0
- package/dist/test/utils/errorHandling.test.d.ts +1 -0
- package/dist/test/utils/errorHandling.test.js +423 -0
- package/dist/types/index.d.ts +51 -0
- package/dist/types/index.js +0 -0
- package/dist/utils/constants.d.ts +12 -0
- package/dist/utils/constants.js +9 -0
- package/dist/utils/deletion/index.d.ts +2 -0
- package/dist/utils/deletion/index.js +2 -0
- package/dist/utils/deletion/messages.d.ts +5 -0
- package/dist/utils/deletion/messages.js +29 -0
- package/dist/utils/deletion/types.d.ts +11 -0
- package/dist/utils/deletion/types.js +0 -0
- package/dist/utils/errorHandling.d.ts +63 -0
- package/dist/utils/errorHandling.js +84 -0
- package/dist/utils/hooks.d.ts +2 -0
- package/dist/utils/hooks.js +26 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/proxyMiddleware.d.ts +18 -0
- package/dist/utils/proxyMiddleware.js +56 -0
- package/dist/utils/s3Client.d.ts +5 -0
- package/dist/utils/s3Client.js +36 -0
- package/dist/utils/s3RuleUtils.d.ts +53 -0
- package/dist/utils/s3RuleUtils.js +101 -0
- package/dist/utils/useFeatures.d.ts +1 -0
- package/dist/utils/useFeatures.js +7 -0
- package/package.json +84 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { joiResolver } from "@hookform/resolvers/joi";
|
|
3
|
+
import { Checkbox, Form, FormGroup, FormSection, Stack, useToast } from "@scality/core-ui";
|
|
4
|
+
import { Button, Input } from "@scality/core-ui/dist/next";
|
|
5
|
+
import { convertRemToPixels } from "@scality/core-ui/dist/utils";
|
|
6
|
+
import joi from "joi";
|
|
7
|
+
import { FormProvider, useForm } from "react-hook-form";
|
|
8
|
+
import { useNavigate } from "react-router";
|
|
9
|
+
import ObjectLockRetentionSettings from "../objects/ObjectLock/ObjectLockRetentionSettings.js";
|
|
10
|
+
import { objectLockRetentionSettingsValidationRules } from "../objects/ObjectLock/ObjectLockSettings.js";
|
|
11
|
+
import { useCreateBucket, useSetBucketObjectLockConfiguration, useSetBucketVersioning } from "../../hooks/index.js";
|
|
12
|
+
const bucketErrorMessage = "Bucket names can include only lowercase letters, numbers, dots (.), and hyphens (-)";
|
|
13
|
+
const bucketNameValidationSchema = joi.string().label("Bucket Name").required().min(3).max(63).pattern(/^[a-z0-9]([a-z0-9.-]*[a-z0-9])?$/, {
|
|
14
|
+
name: "bucketName",
|
|
15
|
+
invert: false
|
|
16
|
+
}).messages({
|
|
17
|
+
"string.pattern.name": bucketErrorMessage
|
|
18
|
+
}).custom((value, helpers)=>{
|
|
19
|
+
if (value.includes("..")) return helpers.message({
|
|
20
|
+
custom: "Bucket names cannot contain two adjacent periods"
|
|
21
|
+
});
|
|
22
|
+
if (/^(\d{1,3}\.){3}\d{1,3}$/.test(value)) return helpers.message({
|
|
23
|
+
custom: "Bucket names must not be formatted as an IP address"
|
|
24
|
+
});
|
|
25
|
+
const forbiddenPrefixes = [
|
|
26
|
+
"xn--",
|
|
27
|
+
"sthree-",
|
|
28
|
+
"amzn-s3-demo-"
|
|
29
|
+
];
|
|
30
|
+
if (forbiddenPrefixes.some((prefix)=>value.startsWith(prefix))) return helpers.message({
|
|
31
|
+
custom: `Bucket names must not start with ${forbiddenPrefixes.join(", ")}`
|
|
32
|
+
});
|
|
33
|
+
const forbiddenSuffixes = [
|
|
34
|
+
"-s3alias",
|
|
35
|
+
"--ol-s3",
|
|
36
|
+
"--x-s3",
|
|
37
|
+
".mrap"
|
|
38
|
+
];
|
|
39
|
+
if (forbiddenSuffixes.some((suffix)=>value.endsWith(suffix))) return helpers.message({
|
|
40
|
+
custom: `Bucket names must not end with ${forbiddenSuffixes.join(", ")}`
|
|
41
|
+
});
|
|
42
|
+
const existingBuckets = helpers.prefs.context?.existingBuckets;
|
|
43
|
+
if (Array.isArray(existingBuckets)) {
|
|
44
|
+
const isDuplicate = existingBuckets.some((bucketName)=>bucketName.toLowerCase() === value.toLowerCase());
|
|
45
|
+
if (isDuplicate) return helpers.message({
|
|
46
|
+
custom: "A bucket with this name already exists"
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
}, "AWS S3 bucket naming rules");
|
|
51
|
+
const baseBucketCreateSchema = joi.object({
|
|
52
|
+
name: bucketNameValidationSchema,
|
|
53
|
+
isVersioning: joi.boolean(),
|
|
54
|
+
...objectLockRetentionSettingsValidationRules
|
|
55
|
+
});
|
|
56
|
+
const BucketCreate = ({ subTitle, validationSchema, validationContext, defaultValues: customDefaultValues, children, onSubmit: onSubmitProp, onCancel: onCancelProp })=>{
|
|
57
|
+
const navigate = useNavigate();
|
|
58
|
+
const { showToast } = useToast();
|
|
59
|
+
const baseDefaultValues = {
|
|
60
|
+
name: "",
|
|
61
|
+
isVersioning: false,
|
|
62
|
+
isObjectLockEnabled: false,
|
|
63
|
+
isDefaultRetentionEnabled: false,
|
|
64
|
+
retentionMode: "GOVERNANCE",
|
|
65
|
+
retentionPeriod: 1,
|
|
66
|
+
retentionPeriodFrequencyChoice: "DAYS",
|
|
67
|
+
...customDefaultValues
|
|
68
|
+
};
|
|
69
|
+
const useFormMethods = useForm({
|
|
70
|
+
mode: "all",
|
|
71
|
+
resolver: joiResolver(validationSchema || baseBucketCreateSchema, {
|
|
72
|
+
context: validationContext || {}
|
|
73
|
+
}),
|
|
74
|
+
defaultValues: baseDefaultValues,
|
|
75
|
+
context: validationContext
|
|
76
|
+
});
|
|
77
|
+
const { register, handleSubmit, formState, watch } = useFormMethods;
|
|
78
|
+
const { isValid, errors } = formState;
|
|
79
|
+
const isObjectLockEnabled = watch("isObjectLockEnabled");
|
|
80
|
+
const { mutate: createBucket, isPending: isCreatingBucket } = useCreateBucket();
|
|
81
|
+
const { mutate: setBucketVersioning } = useSetBucketVersioning();
|
|
82
|
+
const { mutate: setObjectLockConfig } = useSetBucketObjectLockConfiguration();
|
|
83
|
+
const handleCancel = ()=>{
|
|
84
|
+
if (onCancelProp) onCancelProp();
|
|
85
|
+
else navigate("/buckets");
|
|
86
|
+
};
|
|
87
|
+
const handleSuccess = (bucketName)=>{
|
|
88
|
+
showToast({
|
|
89
|
+
open: true,
|
|
90
|
+
message: `Bucket "${bucketName}" created successfully`,
|
|
91
|
+
status: "success"
|
|
92
|
+
});
|
|
93
|
+
navigate(`/buckets/${bucketName}`);
|
|
94
|
+
};
|
|
95
|
+
const handleError = (error, operation)=>{
|
|
96
|
+
showToast({
|
|
97
|
+
open: true,
|
|
98
|
+
message: error instanceof Error ? error.message : `Failed to ${operation}`,
|
|
99
|
+
status: "error"
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
const onSubmit = (data)=>{
|
|
103
|
+
if (onSubmitProp) return void onSubmitProp(data);
|
|
104
|
+
const bucketName = data.name;
|
|
105
|
+
const needsExplicitVersioning = data.isVersioning && !data.isObjectLockEnabled;
|
|
106
|
+
const needsRetentionConfig = data.isObjectLockEnabled && data.isDefaultRetentionEnabled;
|
|
107
|
+
createBucket({
|
|
108
|
+
Bucket: bucketName,
|
|
109
|
+
ObjectLockEnabledForBucket: data.isObjectLockEnabled || void 0
|
|
110
|
+
}, {
|
|
111
|
+
onSuccess: ()=>{
|
|
112
|
+
if (needsExplicitVersioning) setBucketVersioning({
|
|
113
|
+
Bucket: bucketName,
|
|
114
|
+
VersioningConfiguration: {
|
|
115
|
+
Status: "Enabled"
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
118
|
+
onSuccess: ()=>handleSuccess(bucketName),
|
|
119
|
+
onError: (error)=>handleError(error, "enable versioning")
|
|
120
|
+
});
|
|
121
|
+
else if (needsRetentionConfig) {
|
|
122
|
+
const retentionConfig = {
|
|
123
|
+
Bucket: bucketName,
|
|
124
|
+
ObjectLockConfiguration: {
|
|
125
|
+
ObjectLockEnabled: "Enabled",
|
|
126
|
+
Rule: {
|
|
127
|
+
DefaultRetention: {
|
|
128
|
+
Mode: data.retentionMode,
|
|
129
|
+
Days: "DAYS" === data.retentionPeriodFrequencyChoice ? data.retentionPeriod : void 0,
|
|
130
|
+
Years: "YEARS" === data.retentionPeriodFrequencyChoice ? data.retentionPeriod : void 0
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
setObjectLockConfig(retentionConfig, {
|
|
136
|
+
onSuccess: ()=>handleSuccess(bucketName),
|
|
137
|
+
onError: (error)=>handleError(error, "configure object lock retention")
|
|
138
|
+
});
|
|
139
|
+
} else handleSuccess(bucketName);
|
|
140
|
+
},
|
|
141
|
+
onError: (error)=>handleError(error, "create bucket")
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
return /*#__PURE__*/ jsx(FormProvider, {
|
|
145
|
+
...useFormMethods,
|
|
146
|
+
children: /*#__PURE__*/ jsxs(Form, {
|
|
147
|
+
layout: {
|
|
148
|
+
kind: "page",
|
|
149
|
+
title: "Create a New Bucket",
|
|
150
|
+
subTitle
|
|
151
|
+
},
|
|
152
|
+
requireMode: "partial",
|
|
153
|
+
onSubmit: handleSubmit(onSubmit),
|
|
154
|
+
rightActions: /*#__PURE__*/ jsxs(Stack, {
|
|
155
|
+
gap: "r16",
|
|
156
|
+
children: [
|
|
157
|
+
/*#__PURE__*/ jsx(Button, {
|
|
158
|
+
id: "cancel-btn",
|
|
159
|
+
variant: "outline",
|
|
160
|
+
onClick: handleCancel,
|
|
161
|
+
type: "button",
|
|
162
|
+
label: "Cancel"
|
|
163
|
+
}),
|
|
164
|
+
/*#__PURE__*/ jsx(Button, {
|
|
165
|
+
disabled: !isValid,
|
|
166
|
+
isLoading: isCreatingBucket,
|
|
167
|
+
id: "create-bucket-btn",
|
|
168
|
+
type: "submit",
|
|
169
|
+
variant: "primary",
|
|
170
|
+
label: "Create"
|
|
171
|
+
})
|
|
172
|
+
]
|
|
173
|
+
}),
|
|
174
|
+
children: [
|
|
175
|
+
/*#__PURE__*/ jsx(FormSection, {
|
|
176
|
+
forceLabelWidth: convertRemToPixels(17.5),
|
|
177
|
+
children: /*#__PURE__*/ jsxs(Fragment, {
|
|
178
|
+
children: [
|
|
179
|
+
/*#__PURE__*/ jsx(FormGroup, {
|
|
180
|
+
id: "name",
|
|
181
|
+
label: "Bucket Name",
|
|
182
|
+
required: true,
|
|
183
|
+
direction: "horizontal",
|
|
184
|
+
content: /*#__PURE__*/ jsx(Input, {
|
|
185
|
+
id: "name",
|
|
186
|
+
autoFocus: true,
|
|
187
|
+
...register("name")
|
|
188
|
+
}),
|
|
189
|
+
labelHelpTooltip: /*#__PURE__*/ jsxs("ul", {
|
|
190
|
+
children: [
|
|
191
|
+
/*#__PURE__*/ jsx("li", {
|
|
192
|
+
children: "Must be unique"
|
|
193
|
+
}),
|
|
194
|
+
/*#__PURE__*/ jsx("li", {
|
|
195
|
+
children: "Cannot be modified after creation"
|
|
196
|
+
}),
|
|
197
|
+
/*#__PURE__*/ jsx("li", {
|
|
198
|
+
children: bucketErrorMessage
|
|
199
|
+
})
|
|
200
|
+
]
|
|
201
|
+
}),
|
|
202
|
+
helpErrorPosition: "bottom",
|
|
203
|
+
error: errors.name ? errors.name?.type === "string.pattern.base" ? bucketErrorMessage : errors.name?.message : void 0
|
|
204
|
+
}),
|
|
205
|
+
children,
|
|
206
|
+
/*#__PURE__*/ jsx(FormGroup, {
|
|
207
|
+
id: "isVersioning",
|
|
208
|
+
label: "Versioning",
|
|
209
|
+
disabled: isObjectLockEnabled,
|
|
210
|
+
labelHelpTooltip: /*#__PURE__*/ jsxs("ul", {
|
|
211
|
+
children: [
|
|
212
|
+
/*#__PURE__*/ jsx("li", {
|
|
213
|
+
children: "Versioning keeps multiple versions of each objects in your bucket. You can restore deleted or overwritten objects as a result of unintended user actions or application failures."
|
|
214
|
+
}),
|
|
215
|
+
/*#__PURE__*/ jsx("li", {
|
|
216
|
+
children: "It's possible to enable and suspend versioning at the bucket level after the bucket creation."
|
|
217
|
+
})
|
|
218
|
+
]
|
|
219
|
+
}),
|
|
220
|
+
help: isObjectLockEnabled ? "Automatically activated when Object-lock is Enabled" : void 0,
|
|
221
|
+
helpErrorPosition: "bottom",
|
|
222
|
+
content: /*#__PURE__*/ jsx(Checkbox, {
|
|
223
|
+
id: "isVersioning",
|
|
224
|
+
disabled: isObjectLockEnabled,
|
|
225
|
+
...register("isVersioning")
|
|
226
|
+
})
|
|
227
|
+
})
|
|
228
|
+
]
|
|
229
|
+
})
|
|
230
|
+
}),
|
|
231
|
+
/*#__PURE__*/ jsx(ObjectLockRetentionSettings, {})
|
|
232
|
+
]
|
|
233
|
+
})
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
const buckets_BucketCreate = BucketCreate;
|
|
237
|
+
export { BucketCreate, baseBucketCreateSchema, bucketErrorMessage, bucketNameValidationSchema, buckets_BucketCreate as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function BucketDetails(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryParams } from "../../utils/hooks.js";
|
|
3
|
+
import { useNavigate, useParams } from "react-router-dom";
|
|
4
|
+
import { Tabs } from "@scality/core-ui/dist/next";
|
|
5
|
+
import { BucketOverview } from "./BucketOverview.js";
|
|
6
|
+
import { DeleteBucketButton } from "./DeleteBucketButton.js";
|
|
7
|
+
import { EmptyBucketButton } from "./EmptyBucketButton.js";
|
|
8
|
+
import { BucketLifecycleList } from "./BucketLifecycleList.js";
|
|
9
|
+
import { BucketReplicationList } from "./BucketReplicationList.js";
|
|
10
|
+
import { useGetBucketLifecycle, useGetBucketReplication } from "../../hooks/bucketConfiguration.js";
|
|
11
|
+
import { isNotFoundError } from "../../utils/errorHandling.js";
|
|
12
|
+
import { BucketVersioning } from "./BucketVersioning.js";
|
|
13
|
+
function BucketDetails() {
|
|
14
|
+
const query = useQueryParams();
|
|
15
|
+
const queryObject = Object.fromEntries(query.entries());
|
|
16
|
+
const { bucketName } = useParams();
|
|
17
|
+
const navigate = useNavigate();
|
|
18
|
+
const { data: lifecycleData, status: lifecycleStatus, error: lifecycleError } = useGetBucketLifecycle({
|
|
19
|
+
Bucket: bucketName
|
|
20
|
+
});
|
|
21
|
+
const { data: replicationData, status: replicationStatus, error: replicationError } = useGetBucketReplication({
|
|
22
|
+
Bucket: bucketName
|
|
23
|
+
});
|
|
24
|
+
const lifecycleRules = lifecycleData?.Rules || [];
|
|
25
|
+
const replicationRules = replicationData?.ReplicationConfiguration?.Rules || [];
|
|
26
|
+
const replicationRole = replicationData?.ReplicationConfiguration?.Role || "";
|
|
27
|
+
const effectiveLifecycleStatus = isNotFoundError(lifecycleError) ? "success" : "pending" === lifecycleStatus ? "loading" : "error" === lifecycleStatus ? "error" : "success";
|
|
28
|
+
const effectiveReplicationStatus = isNotFoundError(replicationError) ? "success" : "pending" === replicationStatus ? "loading" : "error" === replicationStatus ? "error" : "success";
|
|
29
|
+
if (!bucketName) return /*#__PURE__*/ jsx("div", {
|
|
30
|
+
children: "No bucket selected"
|
|
31
|
+
});
|
|
32
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
33
|
+
children: /*#__PURE__*/ jsxs(Tabs, {
|
|
34
|
+
children: [
|
|
35
|
+
/*#__PURE__*/ jsx(Tabs.Tab, {
|
|
36
|
+
label: "Overview",
|
|
37
|
+
path: "",
|
|
38
|
+
query: {
|
|
39
|
+
...queryObject,
|
|
40
|
+
tab: ""
|
|
41
|
+
},
|
|
42
|
+
children: /*#__PURE__*/ jsxs(BucketOverview, {
|
|
43
|
+
bucketName: bucketName,
|
|
44
|
+
children: [
|
|
45
|
+
/*#__PURE__*/ jsx(BucketOverview.Actions, {
|
|
46
|
+
renderDeleteButton: ()=>/*#__PURE__*/ jsx(DeleteBucketButton, {
|
|
47
|
+
bucketName: bucketName
|
|
48
|
+
}),
|
|
49
|
+
renderEmptyButton: ()=>/*#__PURE__*/ jsx(EmptyBucketButton, {
|
|
50
|
+
bucketName: bucketName
|
|
51
|
+
})
|
|
52
|
+
}),
|
|
53
|
+
/*#__PURE__*/ jsxs(BucketOverview.Sections, {
|
|
54
|
+
children: [
|
|
55
|
+
/*#__PURE__*/ jsx(BucketOverview.GeneralSection, {
|
|
56
|
+
renderVersioning: ()=>/*#__PURE__*/ jsx(BucketVersioning, {})
|
|
57
|
+
}),
|
|
58
|
+
/*#__PURE__*/ jsx(BucketOverview.DataProtectionSection, {}),
|
|
59
|
+
/*#__PURE__*/ jsx(BucketOverview.PermissionsSection, {
|
|
60
|
+
onEditPolicy: ()=>{
|
|
61
|
+
navigate(`/buckets/${bucketName}/policy`);
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
]
|
|
65
|
+
})
|
|
66
|
+
]
|
|
67
|
+
})
|
|
68
|
+
}),
|
|
69
|
+
/*#__PURE__*/ jsx(Tabs.Tab, {
|
|
70
|
+
label: "Lifecycle",
|
|
71
|
+
path: "",
|
|
72
|
+
query: {
|
|
73
|
+
...queryObject,
|
|
74
|
+
tab: "lifecycle"
|
|
75
|
+
},
|
|
76
|
+
withoutPadding: true,
|
|
77
|
+
children: /*#__PURE__*/ jsx(BucketLifecycleList, {
|
|
78
|
+
bucketName: bucketName,
|
|
79
|
+
lifecycleRules: lifecycleRules,
|
|
80
|
+
lifecycleStatus: effectiveLifecycleStatus,
|
|
81
|
+
onCreateRule: ()=>navigate(`/buckets/${bucketName}/lifecycle/create`),
|
|
82
|
+
onEditRule: (ruleId)=>navigate(`/buckets/${bucketName}/lifecycle/edit/${encodeURIComponent(ruleId)}`)
|
|
83
|
+
})
|
|
84
|
+
}),
|
|
85
|
+
/*#__PURE__*/ jsx(Tabs.Tab, {
|
|
86
|
+
label: "Replication",
|
|
87
|
+
path: "",
|
|
88
|
+
query: {
|
|
89
|
+
...queryObject,
|
|
90
|
+
tab: "replication"
|
|
91
|
+
},
|
|
92
|
+
withoutPadding: true,
|
|
93
|
+
children: /*#__PURE__*/ jsx(BucketReplicationList, {
|
|
94
|
+
bucketName: bucketName,
|
|
95
|
+
replicationRules: replicationRules,
|
|
96
|
+
replicationRole: replicationRole,
|
|
97
|
+
replicationStatus: effectiveReplicationStatus,
|
|
98
|
+
onCreateRule: ()=>navigate(`/buckets/${bucketName}/replication/create`),
|
|
99
|
+
onEditRule: (ruleId)=>navigate(`/buckets/${bucketName}/replication/edit/${encodeURIComponent(ruleId)}`)
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
]
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
export { BucketDetails };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BucketLifecycleFormPage - Form for creating and editing S3 bucket lifecycle rules
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - Create new or edit existing lifecycle rules
|
|
6
|
+
* - Support for all AWS S3 lifecycle actions (transitions, expirations, etc.)
|
|
7
|
+
* - Comprehensive validation based on AWS S3 requirements
|
|
8
|
+
* - Filter options: prefix, tags, or combination
|
|
9
|
+
* - Current and noncurrent version management
|
|
10
|
+
* - Abort incomplete multipart upload configuration
|
|
11
|
+
*
|
|
12
|
+
* AWS S3 Lifecycle Documentation:
|
|
13
|
+
* https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketLifecycleConfiguration.html
|
|
14
|
+
*/
|
|
15
|
+
export declare function BucketLifecycleFormPage(): import("react/jsx-runtime").JSX.Element;
|