@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,211 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Checkbox, FormGroup, FormSection, Stack, Text } from "@scality/core-ui";
|
|
3
|
+
import { convertRemToPixels } from "@scality/core-ui/dist/components/tablev2/TableUtils";
|
|
4
|
+
import { Controller, useFormContext } from "react-hook-form";
|
|
5
|
+
import { Input, Select } from "@scality/core-ui/dist/next";
|
|
6
|
+
function ObjectLockRetentionSettings({ isEditRetentionSettings = false }) {
|
|
7
|
+
const { control, register, watch, formState: { errors }, setValue } = useFormContext();
|
|
8
|
+
const isDefaultRetentionEnabled = watch("isDefaultRetentionEnabled");
|
|
9
|
+
const isObjectLockEnabled = watch("isObjectLockEnabled");
|
|
10
|
+
const matchVersioning = (checked)=>{
|
|
11
|
+
if (checked) setValue("isVersioning", true);
|
|
12
|
+
};
|
|
13
|
+
return /*#__PURE__*/ jsxs(FormSection, {
|
|
14
|
+
title: isEditRetentionSettings ? void 0 : {
|
|
15
|
+
name: "Object-lock"
|
|
16
|
+
},
|
|
17
|
+
forceLabelWidth: convertRemToPixels(17.5),
|
|
18
|
+
children: [
|
|
19
|
+
/*#__PURE__*/ jsx(FormGroup, {
|
|
20
|
+
id: "isObjectLockEnabled",
|
|
21
|
+
label: "Object-lock",
|
|
22
|
+
content: /*#__PURE__*/ jsx(Checkbox, {
|
|
23
|
+
id: "isObjectLockEnabled",
|
|
24
|
+
label: isObjectLockEnabled ? "Enabled" : "Disabled",
|
|
25
|
+
disabled: isEditRetentionSettings && isObjectLockEnabled,
|
|
26
|
+
...register("isObjectLockEnabled", {
|
|
27
|
+
onChange (e) {
|
|
28
|
+
matchVersioning(e.target.checked);
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
}),
|
|
32
|
+
labelHelpTooltip: /*#__PURE__*/ jsxs("ul", {
|
|
33
|
+
children: [
|
|
34
|
+
/*#__PURE__*/ jsx("li", {
|
|
35
|
+
children: "Permanently allows objects in this bucket to be locked"
|
|
36
|
+
}),
|
|
37
|
+
/*#__PURE__*/ jsx("li", {
|
|
38
|
+
children: "Object-lock option cannot be removed after bucket creation, but you will be able to disable the retention itself on edition."
|
|
39
|
+
}),
|
|
40
|
+
/*#__PURE__*/ jsx("li", {
|
|
41
|
+
children: "Once the bucket is created, you might be blocked from deleting the objects and the bucket."
|
|
42
|
+
}),
|
|
43
|
+
/*#__PURE__*/ jsx("li", {
|
|
44
|
+
children: "Enabling Object-lock automatically activates Versioning for the bucket, and you won’t be able to suspend Versioning."
|
|
45
|
+
})
|
|
46
|
+
]
|
|
47
|
+
}),
|
|
48
|
+
helpErrorPosition: "bottom",
|
|
49
|
+
disabled: isEditRetentionSettings
|
|
50
|
+
}),
|
|
51
|
+
isObjectLockEnabled && /*#__PURE__*/ jsxs(Fragment, {
|
|
52
|
+
children: [
|
|
53
|
+
/*#__PURE__*/ jsx(FormGroup, {
|
|
54
|
+
id: "isDefaultRetentionEnabled",
|
|
55
|
+
label: "Default Retention",
|
|
56
|
+
helpErrorPosition: "bottom",
|
|
57
|
+
labelHelpTooltip: isEditRetentionSettings ? /*#__PURE__*/ jsxs("ul", {
|
|
58
|
+
children: [
|
|
59
|
+
/*#__PURE__*/ jsx("li", {
|
|
60
|
+
children: "These settings apply only to new objects placed into the bucket without any specific object-lock parameters."
|
|
61
|
+
}),
|
|
62
|
+
/*#__PURE__*/ jsx("li", {
|
|
63
|
+
children: "Automatically protect objects put into this bucket from being deleted or overwritten."
|
|
64
|
+
}),
|
|
65
|
+
/*#__PURE__*/ jsx("li", {
|
|
66
|
+
children: "If objects are uploaded into the bucket with their own Retention settings, these will override the Default Retention setting placed on the bucket."
|
|
67
|
+
})
|
|
68
|
+
]
|
|
69
|
+
}) : /*#__PURE__*/ jsxs("ul", {
|
|
70
|
+
children: [
|
|
71
|
+
/*#__PURE__*/ jsx("li", {
|
|
72
|
+
children: "Automatically protect objects put into this bucket from being deleted or overwritten."
|
|
73
|
+
}),
|
|
74
|
+
/*#__PURE__*/ jsx("li", {
|
|
75
|
+
children: "These settings apply only to new objects placed into the bucket without any specific object-lock parameters."
|
|
76
|
+
}),
|
|
77
|
+
/*#__PURE__*/ jsx("li", {
|
|
78
|
+
children: "You can activate this option after the bucket creation."
|
|
79
|
+
}),
|
|
80
|
+
/*#__PURE__*/ jsx("li", {
|
|
81
|
+
children: "If objects are uploaded into the bucket with their own Retention settings, these will override the Default Retention setting placed on the bucket."
|
|
82
|
+
})
|
|
83
|
+
]
|
|
84
|
+
}),
|
|
85
|
+
content: /*#__PURE__*/ jsx(Checkbox, {
|
|
86
|
+
id: "isDefaultRetentionEnabled",
|
|
87
|
+
label: isDefaultRetentionEnabled ? "Active" : "Inactive",
|
|
88
|
+
...register("isDefaultRetentionEnabled")
|
|
89
|
+
})
|
|
90
|
+
}),
|
|
91
|
+
/*#__PURE__*/ jsx(FormGroup, {
|
|
92
|
+
id: "objectlockMode",
|
|
93
|
+
label: "Retention mode",
|
|
94
|
+
direction: "vertical",
|
|
95
|
+
disabled: !isDefaultRetentionEnabled,
|
|
96
|
+
helpErrorPosition: "bottom",
|
|
97
|
+
content: /*#__PURE__*/ jsx("div", {
|
|
98
|
+
style: {
|
|
99
|
+
opacity: isDefaultRetentionEnabled ? 1 : 0.5
|
|
100
|
+
},
|
|
101
|
+
children: /*#__PURE__*/ jsxs(Stack, {
|
|
102
|
+
direction: "vertical",
|
|
103
|
+
children: [
|
|
104
|
+
/*#__PURE__*/ jsxs(Stack, {
|
|
105
|
+
direction: "vertical",
|
|
106
|
+
children: [
|
|
107
|
+
/*#__PURE__*/ jsxs(Stack, {
|
|
108
|
+
children: [
|
|
109
|
+
/*#__PURE__*/ jsx("input", {
|
|
110
|
+
id: "locktype-governance",
|
|
111
|
+
type: "radio",
|
|
112
|
+
value: "GOVERNANCE",
|
|
113
|
+
disabled: !isDefaultRetentionEnabled,
|
|
114
|
+
...register("retentionMode")
|
|
115
|
+
}),
|
|
116
|
+
/*#__PURE__*/ jsx("label", {
|
|
117
|
+
htmlFor: "locktype-governance",
|
|
118
|
+
children: "Governance"
|
|
119
|
+
})
|
|
120
|
+
]
|
|
121
|
+
}),
|
|
122
|
+
/*#__PURE__*/ jsx(Text, {
|
|
123
|
+
color: "textSecondary",
|
|
124
|
+
isEmphazed: true,
|
|
125
|
+
variant: "Smaller",
|
|
126
|
+
children: "A user with a specific IAM permissions can overwrite/delete protected object versions during the retention period."
|
|
127
|
+
})
|
|
128
|
+
]
|
|
129
|
+
}),
|
|
130
|
+
/*#__PURE__*/ jsxs(Stack, {
|
|
131
|
+
children: [
|
|
132
|
+
/*#__PURE__*/ jsx("input", {
|
|
133
|
+
id: "locktype-compliance",
|
|
134
|
+
type: "radio",
|
|
135
|
+
value: "COMPLIANCE",
|
|
136
|
+
disabled: !isDefaultRetentionEnabled,
|
|
137
|
+
...register("retentionMode")
|
|
138
|
+
}),
|
|
139
|
+
/*#__PURE__*/ jsx("label", {
|
|
140
|
+
htmlFor: "locktype-compliance",
|
|
141
|
+
children: "Compliance"
|
|
142
|
+
})
|
|
143
|
+
]
|
|
144
|
+
}),
|
|
145
|
+
/*#__PURE__*/ jsx(Text, {
|
|
146
|
+
color: "textSecondary",
|
|
147
|
+
isEmphazed: true,
|
|
148
|
+
variant: "Smaller",
|
|
149
|
+
children: "No one can overwrite protected object versions during the retention period."
|
|
150
|
+
})
|
|
151
|
+
]
|
|
152
|
+
})
|
|
153
|
+
})
|
|
154
|
+
}),
|
|
155
|
+
/*#__PURE__*/ jsx(FormGroup, {
|
|
156
|
+
id: "retentionPeriod",
|
|
157
|
+
label: "Retention period",
|
|
158
|
+
direction: "horizontal",
|
|
159
|
+
helpErrorPosition: "bottom",
|
|
160
|
+
help: "Must be a positive whole number.",
|
|
161
|
+
error: errors.retentionPeriod?.message,
|
|
162
|
+
disabled: !isDefaultRetentionEnabled,
|
|
163
|
+
content: /*#__PURE__*/ jsxs(Stack, {
|
|
164
|
+
direction: "horizontal",
|
|
165
|
+
children: [
|
|
166
|
+
/*#__PURE__*/ jsx(Controller, {
|
|
167
|
+
control: control,
|
|
168
|
+
name: "retentionPeriod",
|
|
169
|
+
render: ({ field: { onChange, value: retentionPeriod } })=>/*#__PURE__*/ jsx(Input, {
|
|
170
|
+
id: "retentionPeriod",
|
|
171
|
+
name: "retentionPeriod",
|
|
172
|
+
value: retentionPeriod,
|
|
173
|
+
onChange: (e)=>onChange(e.target.valueAsNumber),
|
|
174
|
+
type: "number",
|
|
175
|
+
step: "1",
|
|
176
|
+
min: "1",
|
|
177
|
+
size: "2/3"
|
|
178
|
+
})
|
|
179
|
+
}),
|
|
180
|
+
/*#__PURE__*/ jsx(Controller, {
|
|
181
|
+
control: control,
|
|
182
|
+
name: "retentionPeriodFrequencyChoice",
|
|
183
|
+
defaultValue: "DAYS",
|
|
184
|
+
render: ({ field: { onChange, value: retentionPeriodFrequencyChoice } })=>/*#__PURE__*/ jsxs(Select, {
|
|
185
|
+
id: "retentionPeriodFrequencyChoice",
|
|
186
|
+
onChange: onChange,
|
|
187
|
+
placeholder: "retentionPeriodFrequencyChoice",
|
|
188
|
+
value: retentionPeriodFrequencyChoice,
|
|
189
|
+
disabled: !isDefaultRetentionEnabled,
|
|
190
|
+
size: "1/3",
|
|
191
|
+
children: [
|
|
192
|
+
/*#__PURE__*/ jsx(Select.Option, {
|
|
193
|
+
value: "DAYS",
|
|
194
|
+
children: "Days"
|
|
195
|
+
}),
|
|
196
|
+
/*#__PURE__*/ jsx(Select.Option, {
|
|
197
|
+
value: "YEARS",
|
|
198
|
+
children: "Years"
|
|
199
|
+
})
|
|
200
|
+
]
|
|
201
|
+
})
|
|
202
|
+
})
|
|
203
|
+
]
|
|
204
|
+
})
|
|
205
|
+
})
|
|
206
|
+
]
|
|
207
|
+
})
|
|
208
|
+
]
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
export { ObjectLockRetentionSettings as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Joi from "joi";
|
|
2
|
+
export declare const objectLockRetentionSettingsValidationRules: {
|
|
3
|
+
isObjectLockEnabled: Joi.BooleanSchema<boolean>;
|
|
4
|
+
isDefaultRetentionEnabled: Joi.BooleanSchema<boolean>;
|
|
5
|
+
retentionMode: Joi.AlternativesSchema<any>;
|
|
6
|
+
retentionPeriod: Joi.AlternativesSchema<any>;
|
|
7
|
+
retentionPeriodFrequencyChoice: Joi.AlternativesSchema<any>;
|
|
8
|
+
};
|
|
9
|
+
export declare function ObjectLockSettings(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
import { useNavigate, useParams } from "react-router-dom";
|
|
4
|
+
import { FormProvider, useForm } from "react-hook-form";
|
|
5
|
+
import { joiResolver } from "@hookform/resolvers/joi";
|
|
6
|
+
import joi from "joi";
|
|
7
|
+
import { Form, Icon, Loader, Stack, Text, useToast } from "@scality/core-ui";
|
|
8
|
+
import { Button } from "@scality/core-ui/dist/next";
|
|
9
|
+
import { useGetBucketObjectLockConfiguration, useSetBucketObjectLockConfiguration } from "../../../hooks/index.js";
|
|
10
|
+
import ObjectLockRetentionSettings from "./ObjectLockRetentionSettings.js";
|
|
11
|
+
const objectLockRetentionSettingsValidationRules = {
|
|
12
|
+
isObjectLockEnabled: joi.boolean(),
|
|
13
|
+
isDefaultRetentionEnabled: joi.boolean().default(false),
|
|
14
|
+
retentionMode: joi.when("isDefaultRetentionEnabled", {
|
|
15
|
+
is: joi.equal(true),
|
|
16
|
+
then: joi.string().valid("GOVERNANCE", "COMPLIANCE").required(),
|
|
17
|
+
otherwise: joi.any()
|
|
18
|
+
}),
|
|
19
|
+
retentionPeriod: joi.when("isDefaultRetentionEnabled", {
|
|
20
|
+
is: joi.equal(true),
|
|
21
|
+
then: joi.number().integer().min(1).required(),
|
|
22
|
+
otherwise: joi.any()
|
|
23
|
+
}),
|
|
24
|
+
retentionPeriodFrequencyChoice: joi.when("isDefaultRetentionEnabled", {
|
|
25
|
+
is: joi.equal(true),
|
|
26
|
+
then: joi.string().valid("DAYS", "YEARS").required(),
|
|
27
|
+
otherwise: joi.any()
|
|
28
|
+
})
|
|
29
|
+
};
|
|
30
|
+
const schema = joi.object(objectLockRetentionSettingsValidationRules);
|
|
31
|
+
function ObjectLockSettings() {
|
|
32
|
+
const { bucketName } = useParams();
|
|
33
|
+
const navigate = useNavigate();
|
|
34
|
+
const { showToast } = useToast();
|
|
35
|
+
const { data: objectLockData, status: objectLockStatus } = useGetBucketObjectLockConfiguration({
|
|
36
|
+
Bucket: bucketName
|
|
37
|
+
});
|
|
38
|
+
const setBucketObjectLockMutation = useSetBucketObjectLockConfiguration();
|
|
39
|
+
const isObjectLockEnabled = objectLockData?.ObjectLockConfiguration?.ObjectLockEnabled === "Enabled";
|
|
40
|
+
const defaultRetention = objectLockData?.ObjectLockConfiguration?.Rule?.DefaultRetention;
|
|
41
|
+
const useFormMethods = useForm({
|
|
42
|
+
mode: "all",
|
|
43
|
+
resolver: joiResolver(schema),
|
|
44
|
+
defaultValues: {
|
|
45
|
+
isObjectLockEnabled: isObjectLockEnabled,
|
|
46
|
+
isDefaultRetentionEnabled: !!defaultRetention,
|
|
47
|
+
retentionMode: defaultRetention?.Mode || "GOVERNANCE",
|
|
48
|
+
retentionPeriod: defaultRetention?.Days || defaultRetention?.Years || 1,
|
|
49
|
+
retentionPeriodFrequencyChoice: defaultRetention ? defaultRetention?.Days ? "DAYS" : "YEARS" : "DAYS"
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const { watch, setValue, handleSubmit, formState: { isValid } } = useFormMethods;
|
|
53
|
+
const isObjectLockEnabledValue = watch("isObjectLockEnabled");
|
|
54
|
+
const isFormInitialized = useRef(false);
|
|
55
|
+
useEffect(()=>{
|
|
56
|
+
if ("success" === objectLockStatus && objectLockData && !isFormInitialized.current) {
|
|
57
|
+
const isEnabled = objectLockData.ObjectLockConfiguration?.ObjectLockEnabled === "Enabled";
|
|
58
|
+
const defaultRet = objectLockData.ObjectLockConfiguration?.Rule?.DefaultRetention;
|
|
59
|
+
setValue("isObjectLockEnabled", isEnabled);
|
|
60
|
+
setValue("isDefaultRetentionEnabled", !!defaultRet);
|
|
61
|
+
if (defaultRet) {
|
|
62
|
+
setValue("retentionMode", defaultRet.Mode);
|
|
63
|
+
setValue("retentionPeriod", defaultRet.Days || defaultRet.Years || 1);
|
|
64
|
+
setValue("retentionPeriodFrequencyChoice", defaultRet.Days ? "DAYS" : "YEARS");
|
|
65
|
+
}
|
|
66
|
+
isFormInitialized.current = true;
|
|
67
|
+
}
|
|
68
|
+
}, [
|
|
69
|
+
objectLockData,
|
|
70
|
+
objectLockStatus,
|
|
71
|
+
setValue
|
|
72
|
+
]);
|
|
73
|
+
const handleCancel = ()=>{
|
|
74
|
+
navigate(`/buckets/${bucketName}`);
|
|
75
|
+
};
|
|
76
|
+
const onSubmit = (data)=>{
|
|
77
|
+
setBucketObjectLockMutation.mutate({
|
|
78
|
+
Bucket: bucketName,
|
|
79
|
+
ObjectLockConfiguration: data.isObjectLockEnabled ? {
|
|
80
|
+
ObjectLockEnabled: "Enabled",
|
|
81
|
+
...data.isDefaultRetentionEnabled && {
|
|
82
|
+
Rule: {
|
|
83
|
+
DefaultRetention: {
|
|
84
|
+
Mode: data.retentionMode,
|
|
85
|
+
..."DAYS" === data.retentionPeriodFrequencyChoice ? {
|
|
86
|
+
Days: data.retentionPeriod
|
|
87
|
+
} : {
|
|
88
|
+
Years: data.retentionPeriod
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
} : void 0
|
|
94
|
+
}, {
|
|
95
|
+
onSuccess: ()=>{
|
|
96
|
+
showToast({
|
|
97
|
+
open: true,
|
|
98
|
+
message: "Object Lock settings saved successfully",
|
|
99
|
+
status: "success"
|
|
100
|
+
});
|
|
101
|
+
navigate(`/buckets/${bucketName}`);
|
|
102
|
+
},
|
|
103
|
+
onError: (error)=>{
|
|
104
|
+
const errorMessage = error instanceof Error ? error.message : "Failed to save Object Lock settings";
|
|
105
|
+
showToast({
|
|
106
|
+
open: true,
|
|
107
|
+
message: errorMessage,
|
|
108
|
+
status: "error"
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
if ("pending" === objectLockStatus) return /*#__PURE__*/ jsx(Loader, {
|
|
114
|
+
centered: true,
|
|
115
|
+
children: /*#__PURE__*/ jsx(Text, {
|
|
116
|
+
children: "Loading retention settings..."
|
|
117
|
+
})
|
|
118
|
+
});
|
|
119
|
+
return /*#__PURE__*/ jsx(FormProvider, {
|
|
120
|
+
...useFormMethods,
|
|
121
|
+
children: /*#__PURE__*/ jsx(Form, {
|
|
122
|
+
onSubmit: handleSubmit(onSubmit),
|
|
123
|
+
requireMode: "partial",
|
|
124
|
+
layout: {
|
|
125
|
+
kind: "page",
|
|
126
|
+
title: "Object-lock settings"
|
|
127
|
+
},
|
|
128
|
+
rightActions: /*#__PURE__*/ jsxs(Stack, {
|
|
129
|
+
gap: "r16",
|
|
130
|
+
children: [
|
|
131
|
+
/*#__PURE__*/ jsx(Button, {
|
|
132
|
+
id: "cancel-btn",
|
|
133
|
+
variant: "outline",
|
|
134
|
+
onClick: handleCancel,
|
|
135
|
+
type: "button",
|
|
136
|
+
label: "Cancel",
|
|
137
|
+
disabled: setBucketObjectLockMutation.isPending
|
|
138
|
+
}),
|
|
139
|
+
/*#__PURE__*/ jsx(Button, {
|
|
140
|
+
disabled: !isValid || !isObjectLockEnabledValue || setBucketObjectLockMutation.isPending,
|
|
141
|
+
id: "edit-retention-setting-btn",
|
|
142
|
+
type: "submit",
|
|
143
|
+
variant: "primary",
|
|
144
|
+
label: "Save",
|
|
145
|
+
icon: /*#__PURE__*/ jsx(Icon, {
|
|
146
|
+
name: "Save"
|
|
147
|
+
}),
|
|
148
|
+
isLoading: setBucketObjectLockMutation.isPending
|
|
149
|
+
})
|
|
150
|
+
]
|
|
151
|
+
}),
|
|
152
|
+
children: /*#__PURE__*/ jsx(ObjectLockRetentionSettings, {
|
|
153
|
+
isEditRetentionSettings: true
|
|
154
|
+
})
|
|
155
|
+
})
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
export { ObjectLockSettings, objectLockRetentionSettingsValidationRules };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GetObjectRetentionCommandOutput } from "@aws-sdk/client-s3";
|
|
2
|
+
export declare function getDefaultRetention(retentionData: GetObjectRetentionCommandOutput | null | undefined): {
|
|
3
|
+
isDefaultRetentionEnabled: boolean;
|
|
4
|
+
defaultRetentionUntilDate: Date;
|
|
5
|
+
defaultRetentionMode: import("@aws-sdk/client-s3").ObjectLockRetentionMode;
|
|
6
|
+
};
|
|
7
|
+
export declare function getDefaultMinRetainUntilDate(d: Date | null | undefined, mode: string): string;
|
|
8
|
+
export declare function getRetainUntilDateHint(dateString: string): string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function getDefaultRetention(retentionData) {
|
|
2
|
+
const isDefaultRetentionEnabled = retentionData?.Retention !== void 0 && null !== retentionData.Retention;
|
|
3
|
+
const defaultRetentionUntilDate = retentionData?.Retention?.RetainUntilDate ? new Date(retentionData.Retention.RetainUntilDate) : new Date();
|
|
4
|
+
const defaultRetentionMode = retentionData?.Retention?.Mode || "GOVERNANCE";
|
|
5
|
+
return {
|
|
6
|
+
isDefaultRetentionEnabled,
|
|
7
|
+
defaultRetentionUntilDate,
|
|
8
|
+
defaultRetentionMode
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function getDefaultMinRetainUntilDate(d, mode) {
|
|
12
|
+
const tomorrow = new Date();
|
|
13
|
+
tomorrow.setDate(tomorrow.getDate() + 1);
|
|
14
|
+
const futureDate = formatDateForInput(tomorrow);
|
|
15
|
+
if (!d) return futureDate;
|
|
16
|
+
const previousRetainUntilDate = "GOVERNANCE" === mode ? formatDateForInput(d) : formatDateForInput(addDays(d, 1));
|
|
17
|
+
return previousRetainUntilDate > futureDate ? previousRetainUntilDate : futureDate;
|
|
18
|
+
}
|
|
19
|
+
function formatDateForInput(date) {
|
|
20
|
+
const year = date.getFullYear();
|
|
21
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
22
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
23
|
+
return `${year}-${month}-${day}`;
|
|
24
|
+
}
|
|
25
|
+
function addDays(date, days) {
|
|
26
|
+
const result = new Date(date);
|
|
27
|
+
result.setDate(result.getDate() + days);
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
function getRetainUntilDateHint(dateString) {
|
|
31
|
+
const now = new Date();
|
|
32
|
+
const retainUntilDate = new Date(dateString);
|
|
33
|
+
const diffInMs = retainUntilDate.getTime() - now.getTime();
|
|
34
|
+
const diffInDays = Math.floor(diffInMs / 86400000);
|
|
35
|
+
if (diffInDays < 1) return "(within 24 hours from now)";
|
|
36
|
+
if (1 === diffInDays) return "(1 day from now)";
|
|
37
|
+
return `(${diffInDays} days from now)`;
|
|
38
|
+
}
|
|
39
|
+
export { getDefaultMinRetainUntilDate, getDefaultRetention, getRetainUntilDateHint };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
3
|
+
import { MemoryRouter, useNavigate } from "react-router-dom";
|
|
4
|
+
import { createTestWrapper } from "../../../../test/testUtils.js";
|
|
5
|
+
import { EditRetentionButton } from "../EditRetentionButton.js";
|
|
6
|
+
import { useISVBucketStatus } from "../../../../hooks/index.js";
|
|
7
|
+
jest.mock("../../../../hooks");
|
|
8
|
+
jest.mock("react-router-dom", ()=>({
|
|
9
|
+
...jest.requireActual("react-router-dom"),
|
|
10
|
+
useNavigate: jest.fn()
|
|
11
|
+
}));
|
|
12
|
+
const mockUseISVBucketStatus = jest.mocked(useISVBucketStatus);
|
|
13
|
+
const mockUseNavigate = jest.mocked(useNavigate);
|
|
14
|
+
const renderEditRetentionButton = (props = {})=>{
|
|
15
|
+
const Wrapper = createTestWrapper();
|
|
16
|
+
const mockNavigate = jest.fn();
|
|
17
|
+
mockUseNavigate.mockReturnValue(mockNavigate);
|
|
18
|
+
const result = render(/*#__PURE__*/ jsx(MemoryRouter, {
|
|
19
|
+
children: /*#__PURE__*/ jsx(Wrapper, {
|
|
20
|
+
children: /*#__PURE__*/ jsx(EditRetentionButton, {
|
|
21
|
+
bucketName: "test-bucket",
|
|
22
|
+
...props
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
}));
|
|
26
|
+
return {
|
|
27
|
+
...result,
|
|
28
|
+
navigate: mockNavigate
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
beforeEach(()=>{
|
|
32
|
+
jest.clearAllMocks();
|
|
33
|
+
mockUseISVBucketStatus.mockReturnValue({
|
|
34
|
+
isVeeamBucket: false,
|
|
35
|
+
isCommvaultBucket: false,
|
|
36
|
+
isISVManaged: false,
|
|
37
|
+
isvApplication: void 0,
|
|
38
|
+
isLoading: false,
|
|
39
|
+
bucketTagsStatus: "success"
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
it("renders edit button", ()=>{
|
|
43
|
+
renderEditRetentionButton();
|
|
44
|
+
const editButton = screen.getByRole("button", {
|
|
45
|
+
name: /edit default retention/i
|
|
46
|
+
});
|
|
47
|
+
expect(editButton).toBeInTheDocument();
|
|
48
|
+
});
|
|
49
|
+
it("navigates to object lock settings page when clicked", ()=>{
|
|
50
|
+
const { navigate } = renderEditRetentionButton();
|
|
51
|
+
const editButton = screen.getByRole("button", {
|
|
52
|
+
name: /edit default retention/i
|
|
53
|
+
});
|
|
54
|
+
fireEvent.click(editButton);
|
|
55
|
+
expect(navigate).toHaveBeenCalledWith("/buckets/test-bucket/objects/object-lock-settings");
|
|
56
|
+
});
|
|
57
|
+
it("navigates with correct bucket name", ()=>{
|
|
58
|
+
const { navigate } = renderEditRetentionButton();
|
|
59
|
+
const editButton = screen.getByRole("button", {
|
|
60
|
+
name: /edit default retention/i
|
|
61
|
+
});
|
|
62
|
+
fireEvent.click(editButton);
|
|
63
|
+
expect(navigate).toHaveBeenCalledWith("/buckets/test-bucket/objects/object-lock-settings");
|
|
64
|
+
});
|
|
65
|
+
it("is enabled for regular buckets without ISV tags", ()=>{
|
|
66
|
+
renderEditRetentionButton();
|
|
67
|
+
const editButton = screen.getByRole("button", {
|
|
68
|
+
name: /edit default retention/i
|
|
69
|
+
});
|
|
70
|
+
expect(editButton).not.toBeDisabled();
|
|
71
|
+
});
|
|
72
|
+
it("is disabled for Veeam Backup & Replication buckets", ()=>{
|
|
73
|
+
mockUseISVBucketStatus.mockReturnValue({
|
|
74
|
+
isVeeamBucket: true,
|
|
75
|
+
isCommvaultBucket: false,
|
|
76
|
+
isISVManaged: true,
|
|
77
|
+
isvApplication: "Veeam",
|
|
78
|
+
isLoading: false,
|
|
79
|
+
bucketTagsStatus: "success"
|
|
80
|
+
});
|
|
81
|
+
renderEditRetentionButton();
|
|
82
|
+
const editButton = screen.getByRole("button", {
|
|
83
|
+
name: /edit default retention/i
|
|
84
|
+
});
|
|
85
|
+
expect(editButton).toBeDisabled();
|
|
86
|
+
});
|
|
87
|
+
it("is disabled for Veeam Office 365 v6/v7 buckets", ()=>{
|
|
88
|
+
mockUseISVBucketStatus.mockReturnValue({
|
|
89
|
+
isVeeamBucket: true,
|
|
90
|
+
isCommvaultBucket: false,
|
|
91
|
+
isISVManaged: true,
|
|
92
|
+
isvApplication: "Veeam",
|
|
93
|
+
isLoading: false,
|
|
94
|
+
bucketTagsStatus: "success"
|
|
95
|
+
});
|
|
96
|
+
renderEditRetentionButton();
|
|
97
|
+
const editButton = screen.getByRole("button", {
|
|
98
|
+
name: /edit default retention/i
|
|
99
|
+
});
|
|
100
|
+
expect(editButton).toBeDisabled();
|
|
101
|
+
});
|
|
102
|
+
it("is disabled for Veeam Office 365 v8+ buckets", ()=>{
|
|
103
|
+
mockUseISVBucketStatus.mockReturnValue({
|
|
104
|
+
isVeeamBucket: true,
|
|
105
|
+
isCommvaultBucket: false,
|
|
106
|
+
isISVManaged: true,
|
|
107
|
+
isvApplication: "Veeam",
|
|
108
|
+
isLoading: false,
|
|
109
|
+
bucketTagsStatus: "success"
|
|
110
|
+
});
|
|
111
|
+
renderEditRetentionButton();
|
|
112
|
+
const editButton = screen.getByRole("button", {
|
|
113
|
+
name: /edit default retention/i
|
|
114
|
+
});
|
|
115
|
+
expect(editButton).toBeDisabled();
|
|
116
|
+
});
|
|
117
|
+
it("is disabled for Commvault buckets", ()=>{
|
|
118
|
+
mockUseISVBucketStatus.mockReturnValue({
|
|
119
|
+
isVeeamBucket: false,
|
|
120
|
+
isCommvaultBucket: true,
|
|
121
|
+
isISVManaged: true,
|
|
122
|
+
isvApplication: "Commvault",
|
|
123
|
+
isLoading: false,
|
|
124
|
+
bucketTagsStatus: "success"
|
|
125
|
+
});
|
|
126
|
+
renderEditRetentionButton();
|
|
127
|
+
const editButton = screen.getByRole("button", {
|
|
128
|
+
name: /edit default retention/i
|
|
129
|
+
});
|
|
130
|
+
expect(editButton).toBeDisabled();
|
|
131
|
+
});
|
|
132
|
+
it("is disabled for ISV buckets tagged as Veeam Backup for Microsoft 365", ()=>{
|
|
133
|
+
mockUseISVBucketStatus.mockReturnValue({
|
|
134
|
+
isVeeamBucket: true,
|
|
135
|
+
isCommvaultBucket: false,
|
|
136
|
+
isISVManaged: true,
|
|
137
|
+
isvApplication: "Veeam",
|
|
138
|
+
isLoading: false,
|
|
139
|
+
bucketTagsStatus: "success"
|
|
140
|
+
});
|
|
141
|
+
renderEditRetentionButton();
|
|
142
|
+
const editButton = screen.getByRole("button", {
|
|
143
|
+
name: /edit default retention/i
|
|
144
|
+
});
|
|
145
|
+
expect(editButton).toBeDisabled();
|
|
146
|
+
});
|
|
147
|
+
it("is disabled for ISV buckets tagged as Veeam Backup & Replication", ()=>{
|
|
148
|
+
mockUseISVBucketStatus.mockReturnValue({
|
|
149
|
+
isVeeamBucket: true,
|
|
150
|
+
isCommvaultBucket: false,
|
|
151
|
+
isISVManaged: true,
|
|
152
|
+
isvApplication: "Veeam",
|
|
153
|
+
isLoading: false,
|
|
154
|
+
bucketTagsStatus: "success"
|
|
155
|
+
});
|
|
156
|
+
renderEditRetentionButton();
|
|
157
|
+
const editButton = screen.getByRole("button", {
|
|
158
|
+
name: /edit default retention/i
|
|
159
|
+
});
|
|
160
|
+
expect(editButton).toBeDisabled();
|
|
161
|
+
});
|
|
162
|
+
it("handles missing bucket tags gracefully", ()=>{
|
|
163
|
+
renderEditRetentionButton();
|
|
164
|
+
const editButton = screen.getByRole("button", {
|
|
165
|
+
name: /edit default retention/i
|
|
166
|
+
});
|
|
167
|
+
expect(editButton).not.toBeDisabled();
|
|
168
|
+
});
|
|
169
|
+
it("handles empty TagSet gracefully", ()=>{
|
|
170
|
+
renderEditRetentionButton();
|
|
171
|
+
const editButton = screen.getByRole("button", {
|
|
172
|
+
name: /edit default retention/i
|
|
173
|
+
});
|
|
174
|
+
expect(editButton).not.toBeDisabled();
|
|
175
|
+
});
|
|
176
|
+
it("is enabled for buckets with non-ISV tags", ()=>{
|
|
177
|
+
renderEditRetentionButton();
|
|
178
|
+
const editButton = screen.getByRole("button", {
|
|
179
|
+
name: /edit default retention/i
|
|
180
|
+
});
|
|
181
|
+
expect(editButton).not.toBeDisabled();
|
|
182
|
+
});
|
|
183
|
+
it("handles bucket tagging query error gracefully", ()=>{
|
|
184
|
+
renderEditRetentionButton();
|
|
185
|
+
const editButton = screen.getByRole("button", {
|
|
186
|
+
name: /edit default retention/i
|
|
187
|
+
});
|
|
188
|
+
expect(editButton).not.toBeDisabled();
|
|
189
|
+
});
|
|
190
|
+
it("shows loading state when fetching bucket tags", ()=>{
|
|
191
|
+
mockUseISVBucketStatus.mockReturnValue({
|
|
192
|
+
isVeeamBucket: false,
|
|
193
|
+
isCommvaultBucket: false,
|
|
194
|
+
isISVManaged: false,
|
|
195
|
+
isvApplication: void 0,
|
|
196
|
+
isLoading: true,
|
|
197
|
+
bucketTagsStatus: "pending"
|
|
198
|
+
});
|
|
199
|
+
renderEditRetentionButton();
|
|
200
|
+
const editButton = screen.getByRole("button", {
|
|
201
|
+
name: /edit default retention/i
|
|
202
|
+
});
|
|
203
|
+
expect(editButton).toBeInTheDocument();
|
|
204
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|