@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.
Files changed (256) hide show
  1. package/dist/components/Editor.d.ts +12 -0
  2. package/dist/components/Editor.js +28 -0
  3. package/dist/components/__tests__/BucketCreate.test.d.ts +1 -0
  4. package/dist/components/__tests__/BucketCreate.test.js +408 -0
  5. package/dist/components/__tests__/BucketLifecycleFormPage.test.d.ts +1 -0
  6. package/dist/components/__tests__/BucketLifecycleFormPage.test.js +618 -0
  7. package/dist/components/__tests__/BucketLifecycleList.test.d.ts +1 -0
  8. package/dist/components/__tests__/BucketLifecycleList.test.js +325 -0
  9. package/dist/components/__tests__/BucketList.test.d.ts +1 -0
  10. package/dist/components/__tests__/BucketList.test.js +415 -0
  11. package/dist/components/__tests__/BucketNotificationCreatePage.test.d.ts +1 -0
  12. package/dist/components/__tests__/BucketNotificationCreatePage.test.js +316 -0
  13. package/dist/components/__tests__/BucketOverview.test.d.ts +1 -0
  14. package/dist/components/__tests__/BucketOverview.test.js +769 -0
  15. package/dist/components/__tests__/BucketPolicyPage.test.d.ts +1 -0
  16. package/dist/components/__tests__/BucketPolicyPage.test.js +268 -0
  17. package/dist/components/__tests__/BucketReplicationFormPage.test.d.ts +1 -0
  18. package/dist/components/__tests__/BucketReplicationFormPage.test.js +1757 -0
  19. package/dist/components/__tests__/BucketReplicationList.test.d.ts +1 -0
  20. package/dist/components/__tests__/BucketReplicationList.test.js +344 -0
  21. package/dist/components/__tests__/CreateFolderButton.test.d.ts +1 -0
  22. package/dist/components/__tests__/CreateFolderButton.test.js +147 -0
  23. package/dist/components/__tests__/DeleteBucketButton.test.d.ts +1 -0
  24. package/dist/components/__tests__/DeleteBucketButton.test.js +272 -0
  25. package/dist/components/__tests__/DeleteBucketConfigRuleButton.test.d.ts +1 -0
  26. package/dist/components/__tests__/DeleteBucketConfigRuleButton.test.js +196 -0
  27. package/dist/components/__tests__/DeleteObjectButton.test.d.ts +1 -0
  28. package/dist/components/__tests__/DeleteObjectButton.test.js +302 -0
  29. package/dist/components/__tests__/EmptyBucketButton.test.d.ts +1 -0
  30. package/dist/components/__tests__/EmptyBucketButton.test.js +302 -0
  31. package/dist/components/__tests__/MetadataSearch.test.d.ts +1 -0
  32. package/dist/components/__tests__/MetadataSearch.test.js +201 -0
  33. package/dist/components/__tests__/ObjectList.test.d.ts +1 -0
  34. package/dist/components/__tests__/ObjectList.test.js +283 -0
  35. package/dist/components/__tests__/UploadButton.test.d.ts +1 -0
  36. package/dist/components/__tests__/UploadButton.test.js +144 -0
  37. package/dist/components/buckets/BucketCreate.d.ts +49 -0
  38. package/dist/components/buckets/BucketCreate.js +237 -0
  39. package/dist/components/buckets/BucketDetails.d.ts +1 -0
  40. package/dist/components/buckets/BucketDetails.js +106 -0
  41. package/dist/components/buckets/BucketLifecycleFormPage.d.ts +15 -0
  42. package/dist/components/buckets/BucketLifecycleFormPage.js +1085 -0
  43. package/dist/components/buckets/BucketLifecycleList.d.ts +10 -0
  44. package/dist/components/buckets/BucketLifecycleList.js +270 -0
  45. package/dist/components/buckets/BucketList.d.ts +15 -0
  46. package/dist/components/buckets/BucketList.js +146 -0
  47. package/dist/components/buckets/BucketLocation.d.ts +3 -0
  48. package/dist/components/buckets/BucketLocation.js +16 -0
  49. package/dist/components/buckets/BucketOverview.d.ts +88 -0
  50. package/dist/components/buckets/BucketOverview.js +291 -0
  51. package/dist/components/buckets/BucketPage.d.ts +2 -0
  52. package/dist/components/buckets/BucketPage.js +47 -0
  53. package/dist/components/buckets/BucketPolicyButton.d.ts +7 -0
  54. package/dist/components/buckets/BucketPolicyButton.js +18 -0
  55. package/dist/components/buckets/BucketPolicyPage.d.ts +1 -0
  56. package/dist/components/buckets/BucketPolicyPage.js +236 -0
  57. package/dist/components/buckets/BucketReplicationFormPage.d.ts +1 -0
  58. package/dist/components/buckets/BucketReplicationFormPage.js +834 -0
  59. package/dist/components/buckets/BucketReplicationList.d.ts +11 -0
  60. package/dist/components/buckets/BucketReplicationList.js +189 -0
  61. package/dist/components/buckets/BucketVersioning.d.ts +4 -0
  62. package/dist/components/buckets/BucketVersioning.js +73 -0
  63. package/dist/components/buckets/DeleteBucketButton.d.ts +8 -0
  64. package/dist/components/buckets/DeleteBucketButton.js +78 -0
  65. package/dist/components/buckets/DeleteBucketConfigRuleButton.d.ts +18 -0
  66. package/dist/components/buckets/DeleteBucketConfigRuleButton.js +53 -0
  67. package/dist/components/buckets/EmptyBucketButton.d.ts +5 -0
  68. package/dist/components/buckets/EmptyBucketButton.js +232 -0
  69. package/dist/components/buckets/EmptyBucketSummary.d.ts +9 -0
  70. package/dist/components/buckets/EmptyBucketSummary.js +60 -0
  71. package/dist/components/buckets/EmptyBucketSummaryList.d.ts +13 -0
  72. package/dist/components/buckets/EmptyBucketSummaryList.js +140 -0
  73. package/dist/components/buckets/__tests__/BucketVersioning.test.d.ts +1 -0
  74. package/dist/components/buckets/__tests__/BucketVersioning.test.js +163 -0
  75. package/dist/components/buckets/notifications/BucketNotificationCreatePage.d.ts +1 -0
  76. package/dist/components/buckets/notifications/BucketNotificationCreatePage.js +234 -0
  77. package/dist/components/buckets/notifications/EventsSection.d.ts +1 -0
  78. package/dist/components/buckets/notifications/EventsSection.js +123 -0
  79. package/dist/components/buckets/notifications/events.d.ts +12 -0
  80. package/dist/components/buckets/notifications/events.js +27 -0
  81. package/dist/components/index.d.ts +21 -0
  82. package/dist/components/index.js +22 -0
  83. package/dist/components/layouts/ArrowNavigation.d.ts +4 -0
  84. package/dist/components/layouts/ArrowNavigation.js +16 -0
  85. package/dist/components/layouts/BrowserPageLayout.d.ts +12 -0
  86. package/dist/components/layouts/BrowserPageLayout.js +51 -0
  87. package/dist/components/objects/CreateFolderButton.d.ts +29 -0
  88. package/dist/components/objects/CreateFolderButton.js +118 -0
  89. package/dist/components/objects/DeleteObjectButton.d.ts +8 -0
  90. package/dist/components/objects/DeleteObjectButton.js +191 -0
  91. package/dist/components/objects/ObjectDetails/ObjectMetadata.d.ts +2 -0
  92. package/dist/components/objects/ObjectDetails/ObjectMetadata.js +356 -0
  93. package/dist/components/objects/ObjectDetails/ObjectSummary.d.ts +3 -0
  94. package/dist/components/objects/ObjectDetails/ObjectSummary.js +241 -0
  95. package/dist/components/objects/ObjectDetails/ObjectTags.d.ts +3 -0
  96. package/dist/components/objects/ObjectDetails/ObjectTags.js +272 -0
  97. package/dist/components/objects/ObjectDetails/index.d.ts +9 -0
  98. package/dist/components/objects/ObjectDetails/index.js +75 -0
  99. package/dist/components/objects/ObjectList.d.ts +40 -0
  100. package/dist/components/objects/ObjectList.js +453 -0
  101. package/dist/components/objects/ObjectLock/EditRetentionButton.d.ts +4 -0
  102. package/dist/components/objects/ObjectLock/EditRetentionButton.js +32 -0
  103. package/dist/components/objects/ObjectLock/ObjectLockRetentionSettings.d.ts +3 -0
  104. package/dist/components/objects/ObjectLock/ObjectLockRetentionSettings.js +211 -0
  105. package/dist/components/objects/ObjectLock/ObjectLockSettings.d.ts +9 -0
  106. package/dist/components/objects/ObjectLock/ObjectLockSettings.js +158 -0
  107. package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.d.ts +8 -0
  108. package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.js +39 -0
  109. package/dist/components/objects/ObjectLock/__tests__/EditRetentionButton.test.d.ts +1 -0
  110. package/dist/components/objects/ObjectLock/__tests__/EditRetentionButton.test.js +204 -0
  111. package/dist/components/objects/ObjectLock/__tests__/ObjectLockSettings.test.d.ts +1 -0
  112. package/dist/components/objects/ObjectLock/__tests__/ObjectLockSettings.test.js +374 -0
  113. package/dist/components/objects/ObjectPage.d.ts +1 -0
  114. package/dist/components/objects/ObjectPage.js +45 -0
  115. package/dist/components/objects/UploadButton.d.ts +34 -0
  116. package/dist/components/objects/UploadButton.js +229 -0
  117. package/dist/components/providers/DataBrowserProvider.d.ts +20 -0
  118. package/dist/components/providers/DataBrowserProvider.js +42 -0
  119. package/dist/components/search/MetadataSearch.d.ts +5 -0
  120. package/dist/components/search/MetadataSearch.js +162 -0
  121. package/dist/components/search/SearchHints.d.ts +8 -0
  122. package/dist/components/search/SearchHints.js +21 -0
  123. package/dist/components/ui/ArrayFieldActions.d.ts +36 -0
  124. package/dist/components/ui/ArrayFieldActions.js +43 -0
  125. package/dist/components/ui/ConfirmDeleteRuleModal.d.ts +16 -0
  126. package/dist/components/ui/ConfirmDeleteRuleModal.js +43 -0
  127. package/dist/components/ui/DeleteObjectModalContent.d.ts +5 -0
  128. package/dist/components/ui/DeleteObjectModalContent.js +71 -0
  129. package/dist/components/ui/FilterFormSection.d.ts +44 -0
  130. package/dist/components/ui/FilterFormSection.js +159 -0
  131. package/dist/components/ui/Search.elements.d.ts +17 -0
  132. package/dist/components/ui/Search.elements.js +59 -0
  133. package/dist/components/ui/Table.elements.d.ts +36 -0
  134. package/dist/components/ui/Table.elements.js +87 -0
  135. package/dist/config/factory.d.ts +63 -0
  136. package/dist/config/factory.js +74 -0
  137. package/dist/config/types.d.ts +46 -0
  138. package/dist/config/types.js +0 -0
  139. package/dist/hooks/__tests__/useISVBucketDetection.test.d.ts +1 -0
  140. package/dist/hooks/__tests__/useISVBucketDetection.test.js +188 -0
  141. package/dist/hooks/__tests__/useIsBucketEmpty.test.d.ts +1 -0
  142. package/dist/hooks/__tests__/useIsBucketEmpty.test.js +122 -0
  143. package/dist/hooks/bucketConfiguration.d.ts +168 -0
  144. package/dist/hooks/bucketConfiguration.js +67 -0
  145. package/dist/hooks/bucketOperations.d.ts +36 -0
  146. package/dist/hooks/bucketOperations.js +12 -0
  147. package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.d.ts +1 -0
  148. package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.js +276 -0
  149. package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.d.ts +1 -0
  150. package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.js +259 -0
  151. package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.d.ts +1 -0
  152. package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.js +166 -0
  153. package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.d.ts +1 -0
  154. package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.js +200 -0
  155. package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.d.ts +1 -0
  156. package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.js +179 -0
  157. package/dist/hooks/factories/index.d.ts +18 -0
  158. package/dist/hooks/factories/index.js +5 -0
  159. package/dist/hooks/factories/useCreateS3InfiniteQueryHook.d.ts +13 -0
  160. package/dist/hooks/factories/useCreateS3InfiniteQueryHook.js +76 -0
  161. package/dist/hooks/factories/useCreateS3LoginHook.d.ts +8 -0
  162. package/dist/hooks/factories/useCreateS3LoginHook.js +22 -0
  163. package/dist/hooks/factories/useCreateS3MutationHook.d.ts +5 -0
  164. package/dist/hooks/factories/useCreateS3MutationHook.js +50 -0
  165. package/dist/hooks/factories/useCreateS3QueryHook.d.ts +3 -0
  166. package/dist/hooks/factories/useCreateS3QueryHook.js +51 -0
  167. package/dist/hooks/index.d.ts +13 -0
  168. package/dist/hooks/index.js +13 -0
  169. package/dist/hooks/loginOperations.d.ts +21 -0
  170. package/dist/hooks/loginOperations.js +9 -0
  171. package/dist/hooks/objectOperations.d.ts +190 -0
  172. package/dist/hooks/objectOperations.js +67 -0
  173. package/dist/hooks/presignedOperations.d.ts +73 -0
  174. package/dist/hooks/presignedOperations.js +72 -0
  175. package/dist/hooks/useBatchObjectLegalHold.d.ts +11 -0
  176. package/dist/hooks/useBatchObjectLegalHold.js +45 -0
  177. package/dist/hooks/useDeleteBucketConfigRule.d.ts +26 -0
  178. package/dist/hooks/useDeleteBucketConfigRule.js +46 -0
  179. package/dist/hooks/useEmptyBucket.d.ts +27 -0
  180. package/dist/hooks/useEmptyBucket.js +116 -0
  181. package/dist/hooks/useISVBucketDetection.d.ts +15 -0
  182. package/dist/hooks/useISVBucketDetection.js +27 -0
  183. package/dist/hooks/useIsBucketEmpty.d.ts +7 -0
  184. package/dist/hooks/useIsBucketEmpty.js +36 -0
  185. package/dist/hooks/useLoginMutation.d.ts +21 -0
  186. package/dist/hooks/useLoginMutation.js +9 -0
  187. package/dist/hooks/useS3Client.d.ts +1 -0
  188. package/dist/hooks/useS3Client.js +13 -0
  189. package/dist/hooks/useTableRowSelection.d.ts +9 -0
  190. package/dist/hooks/useTableRowSelection.js +45 -0
  191. package/dist/index.d.ts +6 -0
  192. package/dist/index.js +6 -0
  193. package/dist/schemas/bucketPolicySchema.json +321 -0
  194. package/dist/test/msw/handlers/deleteBucket.d.ts +1 -0
  195. package/dist/test/msw/handlers/deleteBucket.js +14 -0
  196. package/dist/test/msw/handlers/getBucketAcl.d.ts +1 -0
  197. package/dist/test/msw/handlers/getBucketAcl.js +96 -0
  198. package/dist/test/msw/handlers/getBucketLocation.d.ts +1 -0
  199. package/dist/test/msw/handlers/getBucketLocation.js +23 -0
  200. package/dist/test/msw/handlers/getBucketPolicy.d.ts +11 -0
  201. package/dist/test/msw/handlers/getBucketPolicy.js +72 -0
  202. package/dist/test/msw/handlers/headObject.d.ts +1 -0
  203. package/dist/test/msw/handlers/headObject.js +17 -0
  204. package/dist/test/msw/handlers/listBuckets.d.ts +1 -0
  205. package/dist/test/msw/handlers/listBuckets.js +24 -0
  206. package/dist/test/msw/handlers/listObjectVersions.d.ts +1 -0
  207. package/dist/test/msw/handlers/listObjectVersions.js +83 -0
  208. package/dist/test/msw/handlers/listObjects.d.ts +1 -0
  209. package/dist/test/msw/handlers/listObjects.js +66 -0
  210. package/dist/test/msw/handlers/objectLegalHold.d.ts +1 -0
  211. package/dist/test/msw/handlers/objectLegalHold.js +24 -0
  212. package/dist/test/msw/handlers/objectRetention.d.ts +1 -0
  213. package/dist/test/msw/handlers/objectRetention.js +27 -0
  214. package/dist/test/msw/handlers/putBucketAcl.d.ts +1 -0
  215. package/dist/test/msw/handlers/putBucketAcl.js +18 -0
  216. package/dist/test/msw/handlers/putObject.d.ts +1 -0
  217. package/dist/test/msw/handlers/putObject.js +16 -0
  218. package/dist/test/msw/handlers.d.ts +4 -0
  219. package/dist/test/msw/handlers.js +109 -0
  220. package/dist/test/msw/index.d.ts +2 -0
  221. package/dist/test/msw/index.js +3 -0
  222. package/dist/test/msw/server.d.ts +4 -0
  223. package/dist/test/msw/server.js +20 -0
  224. package/dist/test/msw/utils.d.ts +2 -0
  225. package/dist/test/msw/utils.js +13 -0
  226. package/dist/test/setup.d.ts +1 -0
  227. package/dist/test/setup.js +90 -0
  228. package/dist/test/testUtils.d.ts +181 -0
  229. package/dist/test/testUtils.js +310 -0
  230. package/dist/test/utils/errorHandling.test.d.ts +1 -0
  231. package/dist/test/utils/errorHandling.test.js +423 -0
  232. package/dist/types/index.d.ts +51 -0
  233. package/dist/types/index.js +0 -0
  234. package/dist/utils/constants.d.ts +12 -0
  235. package/dist/utils/constants.js +9 -0
  236. package/dist/utils/deletion/index.d.ts +2 -0
  237. package/dist/utils/deletion/index.js +2 -0
  238. package/dist/utils/deletion/messages.d.ts +5 -0
  239. package/dist/utils/deletion/messages.js +29 -0
  240. package/dist/utils/deletion/types.d.ts +11 -0
  241. package/dist/utils/deletion/types.js +0 -0
  242. package/dist/utils/errorHandling.d.ts +63 -0
  243. package/dist/utils/errorHandling.js +84 -0
  244. package/dist/utils/hooks.d.ts +2 -0
  245. package/dist/utils/hooks.js +26 -0
  246. package/dist/utils/index.d.ts +4 -0
  247. package/dist/utils/index.js +4 -0
  248. package/dist/utils/proxyMiddleware.d.ts +18 -0
  249. package/dist/utils/proxyMiddleware.js +56 -0
  250. package/dist/utils/s3Client.d.ts +5 -0
  251. package/dist/utils/s3Client.js +36 -0
  252. package/dist/utils/s3RuleUtils.d.ts +53 -0
  253. package/dist/utils/s3RuleUtils.js +101 -0
  254. package/dist/utils/useFeatures.d.ts +1 -0
  255. package/dist/utils/useFeatures.js +7 -0
  256. package/package.json +84 -0
@@ -0,0 +1,232 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { Banner, Icon, Loader, Modal, Stack, Text, Tooltip, Wrap } from "@scality/core-ui";
3
+ import { Box, Button } from "@scality/core-ui/dist/next";
4
+ import { Input } from "@scality/core-ui/dist/components/inputv2/inputv2";
5
+ import { useMemo, useState } from "react";
6
+ import { useIsBucketEmpty } from "../../hooks/useIsBucketEmpty.js";
7
+ import { useEmptyBucket } from "../../hooks/useEmptyBucket.js";
8
+ import { useGetBucketObjectLockConfiguration } from "../../hooks/bucketConfiguration.js";
9
+ import styled_components from "styled-components";
10
+ import { EmptyBucketSummary } from "./EmptyBucketSummary.js";
11
+ const MAX_OBJECTS_TO_DELETE = 20000;
12
+ const CustomListItem = styled_components.li`
13
+ padding: 0.5rem;
14
+ `;
15
+ const emptyBucketInfosList = [
16
+ "Emptying a bucket removes all contents and cannot be reversed.",
17
+ "New objects added during the empty action may also be removed.",
18
+ "Adjust workflows linked to this bucket to avoid adding objects during the emptying action."
19
+ ];
20
+ const RetentionText = ()=>/*#__PURE__*/ jsx(Text, {
21
+ children: "If some of the objects you are trying to delete are locked in governance mode, confirming the deletion will effectively delete them as the governance retention will be bypassed."
22
+ });
23
+ const LifecycleText = ()=>/*#__PURE__*/ jsx(Text, {
24
+ children: "The action of emptying can erase a maximum of 20,000 objects. For buckets with a substantial number of objects, an expiration workflow (lifecycle rule) could provide an effective alternative to emptying the bucket."
25
+ });
26
+ const EmptyBucketButton = ({ bucketName })=>{
27
+ const [confirmText, setConfirmText] = useState("");
28
+ const [isEmptyModalOpen, setIsEmptyModalOpen] = useState(false);
29
+ const [showSummary, setShowSummary] = useState(false);
30
+ const { isEmpty, isLoading: isCheckingEmpty } = useIsBucketEmpty(bucketName);
31
+ const { data: objectLockData } = useGetBucketObjectLockConfiguration({
32
+ Bucket: bucketName
33
+ });
34
+ const isObjectLockEnabled = objectLockData?.ObjectLockConfiguration?.ObjectLockEnabled === "Enabled";
35
+ const { emptyBucket, isEmptying, error, result, reset } = useEmptyBucket({
36
+ maxObjects: MAX_OBJECTS_TO_DELETE,
37
+ bypassGovernanceRetention: true
38
+ });
39
+ const isConfirmed = confirmText === bucketName;
40
+ const deleteResultForSummary = useMemo(()=>{
41
+ if (!result) return;
42
+ return {
43
+ $metadata: {},
44
+ Deleted: Array.from({
45
+ length: result.deletedCount
46
+ }, (_, i)=>({
47
+ Key: `object-${i}`,
48
+ VersionId: void 0
49
+ })),
50
+ Errors: result.errors.map((error)=>({
51
+ Key: error.key,
52
+ Code: error.code,
53
+ Message: error.message
54
+ }))
55
+ };
56
+ }, [
57
+ result
58
+ ]);
59
+ const handleEmptyBucket = async ()=>{
60
+ const bucketResult = await emptyBucket(bucketName);
61
+ if (bucketResult) {
62
+ setIsEmptyModalOpen(false);
63
+ setShowSummary(true);
64
+ }
65
+ };
66
+ const handleCloseSummary = ()=>{
67
+ setShowSummary(false);
68
+ setConfirmText("");
69
+ reset();
70
+ };
71
+ return /*#__PURE__*/ jsxs(Fragment, {
72
+ children: [
73
+ /*#__PURE__*/ jsx(Tooltip, {
74
+ overlay: isCheckingEmpty ? "Checking if bucket is empty" : "Bucket is already empty",
75
+ overlayStyle: {
76
+ width: "9rem",
77
+ display: isEmpty ? void 0 : "none"
78
+ },
79
+ children: /*#__PURE__*/ jsx(Button, {
80
+ icon: /*#__PURE__*/ jsx(Icon, {
81
+ name: "Eraser"
82
+ }),
83
+ disabled: Boolean(isEmpty) || isCheckingEmpty,
84
+ variant: "danger",
85
+ onClick: ()=>setIsEmptyModalOpen(true),
86
+ label: "Empty Bucket",
87
+ style: {
88
+ marginRight: "1rem"
89
+ }
90
+ })
91
+ }),
92
+ /*#__PURE__*/ jsx(Modal, {
93
+ isOpen: isEmptyModalOpen,
94
+ title: `Empty Bucket '${bucketName}'?`,
95
+ close: ()=>{
96
+ if (!isEmptying) {
97
+ setIsEmptyModalOpen(false);
98
+ setConfirmText("");
99
+ reset();
100
+ }
101
+ },
102
+ footer: /*#__PURE__*/ jsxs(Wrap, {
103
+ children: [
104
+ isEmptying && /*#__PURE__*/ jsx(Text, {
105
+ variant: "Larger",
106
+ children: result?.deletedCount ? `${result?.deletedCount} deletion attempts...` : "Deletion in progress..."
107
+ }),
108
+ /*#__PURE__*/ jsx("p", {}),
109
+ /*#__PURE__*/ jsxs(Stack, {
110
+ children: [
111
+ /*#__PURE__*/ jsx(Button, {
112
+ variant: "outline",
113
+ onClick: ()=>{
114
+ setIsEmptyModalOpen(false);
115
+ setConfirmText("");
116
+ reset();
117
+ },
118
+ label: "Cancel",
119
+ disabled: isEmptying
120
+ }),
121
+ /*#__PURE__*/ jsx(Button, {
122
+ disabled: !isConfirmed || isEmptying,
123
+ variant: "danger",
124
+ onClick: handleEmptyBucket,
125
+ icon: isEmptying ? /*#__PURE__*/ jsx(Loader, {
126
+ size: "larger"
127
+ }) : /*#__PURE__*/ jsx(Icon, {
128
+ name: "Eraser"
129
+ }),
130
+ label: "Empty"
131
+ })
132
+ ]
133
+ })
134
+ ]
135
+ }),
136
+ children: /*#__PURE__*/ jsxs(Box, {
137
+ maxWidth: "35rem",
138
+ children: [
139
+ error && /*#__PURE__*/ jsxs(Fragment, {
140
+ children: [
141
+ /*#__PURE__*/ jsx(Banner, {
142
+ variant: "danger",
143
+ icon: /*#__PURE__*/ jsx(Icon, {
144
+ name: "Exclamation-circle",
145
+ color: "statusCritical"
146
+ }),
147
+ title: "Error",
148
+ children: error.message
149
+ }),
150
+ /*#__PURE__*/ jsx("br", {})
151
+ ]
152
+ }),
153
+ isObjectLockEnabled && /*#__PURE__*/ jsxs(Fragment, {
154
+ children: [
155
+ /*#__PURE__*/ jsx(Banner, {
156
+ icon: /*#__PURE__*/ jsx(Box, {
157
+ display: "flex",
158
+ alignItems: "center",
159
+ marginLeft: "0.571rem",
160
+ children: /*#__PURE__*/ jsx(Icon, {
161
+ name: "Exclamation-circle",
162
+ color: "statusWarning",
163
+ size: "lg"
164
+ })
165
+ }),
166
+ variant: "warning",
167
+ children: /*#__PURE__*/ jsx(RetentionText, {})
168
+ }),
169
+ /*#__PURE__*/ jsx("br", {})
170
+ ]
171
+ }),
172
+ /*#__PURE__*/ jsx("ul", {
173
+ style: {
174
+ padding: "2rem"
175
+ },
176
+ children: emptyBucketInfosList.map((listInfo, i)=>/*#__PURE__*/ jsx(CustomListItem, {
177
+ children: listInfo
178
+ }, i))
179
+ }),
180
+ /*#__PURE__*/ jsx(Banner, {
181
+ icon: /*#__PURE__*/ jsx("div", {
182
+ style: {
183
+ display: "flex",
184
+ alignItems: "center",
185
+ marginLeft: "0.571rem"
186
+ },
187
+ children: /*#__PURE__*/ jsx(Icon, {
188
+ name: "Info-circle",
189
+ size: "lg"
190
+ })
191
+ }),
192
+ variant: "base",
193
+ children: /*#__PURE__*/ jsx(LifecycleText, {})
194
+ }),
195
+ /*#__PURE__*/ jsx("br", {}),
196
+ /*#__PURE__*/ jsxs(Box, {
197
+ display: "flex",
198
+ alignItems: "center",
199
+ paddingTop: "1rem",
200
+ children: [
201
+ /*#__PURE__*/ jsx("label", {
202
+ style: {
203
+ float: "left",
204
+ marginRight: "1rem"
205
+ },
206
+ children: "Type the name of the bucket to delete all its content."
207
+ }),
208
+ /*#__PURE__*/ jsx(Input, {
209
+ id: "confirm-input",
210
+ "aria-label": "confirm",
211
+ autoFocus: isEmptyModalOpen,
212
+ placeholder: bucketName,
213
+ type: "text",
214
+ value: confirmText,
215
+ onChange: (e)=>setConfirmText(e.target.value),
216
+ disabled: isEmptying
217
+ })
218
+ ]
219
+ })
220
+ ]
221
+ })
222
+ }),
223
+ deleteResultForSummary && /*#__PURE__*/ jsx(EmptyBucketSummary, {
224
+ deleteResult: deleteResultForSummary,
225
+ close: handleCloseSummary,
226
+ open: showSummary,
227
+ isFetchNextPage: !result?.limitReached
228
+ })
229
+ ]
230
+ });
231
+ };
232
+ export { EmptyBucketButton };
@@ -0,0 +1,9 @@
1
+ import type { DeleteObjectsCommandOutput } from "@aws-sdk/client-s3";
2
+ interface EmptyBucketSummaryProps {
3
+ deleteResult: DeleteObjectsCommandOutput;
4
+ close: () => void;
5
+ open: boolean;
6
+ isFetchNextPage: boolean;
7
+ }
8
+ export declare const EmptyBucketSummary: ({ deleteResult, close, open, isFetchNextPage, }: EmptyBucketSummaryProps) => import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,60 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { Banner, Icon, Modal, Wrap } from "@scality/core-ui";
3
+ import { Button } from "@scality/core-ui/dist/next";
4
+ import { useMemo } from "react";
5
+ import { EmptyBucketSummaryList } from "./EmptyBucketSummaryList.js";
6
+ const useCreateDeleteSummaryData = (deleteResult)=>useMemo(()=>{
7
+ const deleteSummaryData = [
8
+ {
9
+ attempts: (deleteResult.Deleted?.length || 0) + (deleteResult.Errors?.length || 0),
10
+ deleted: deleteResult.Deleted?.length || 0,
11
+ errors: {
12
+ nbErrors: deleteResult.Errors?.length || 0,
13
+ messages: deleteResult.Errors?.map((error)=>error.Message || "") || []
14
+ }
15
+ }
16
+ ];
17
+ return deleteSummaryData;
18
+ }, [
19
+ deleteResult
20
+ ]);
21
+ const EmptyBucketSummary = ({ deleteResult, close, open, isFetchNextPage })=>{
22
+ const deleteSummaryData = useCreateDeleteSummaryData(deleteResult);
23
+ return /*#__PURE__*/ jsx(Modal, {
24
+ title: "Summary",
25
+ close: close,
26
+ isOpen: open,
27
+ footer: /*#__PURE__*/ jsxs(Wrap, {
28
+ children: [
29
+ /*#__PURE__*/ jsx("p", {}),
30
+ /*#__PURE__*/ jsx(Button, {
31
+ variant: "primary",
32
+ onClick: close,
33
+ label: "Close"
34
+ })
35
+ ]
36
+ }),
37
+ children: /*#__PURE__*/ jsxs("div", {
38
+ children: [
39
+ !isFetchNextPage && /*#__PURE__*/ jsxs(Fragment, {
40
+ children: [
41
+ /*#__PURE__*/ jsx(Banner, {
42
+ variant: "danger",
43
+ icon: /*#__PURE__*/ jsx(Icon, {
44
+ name: "Exclamation-circle",
45
+ color: "statusCritical"
46
+ }),
47
+ title: "Error",
48
+ children: "Your bucket contains too many objects. We can delete up to 20 000 objects."
49
+ }),
50
+ /*#__PURE__*/ jsx("br", {})
51
+ ]
52
+ }),
53
+ /*#__PURE__*/ jsx(EmptyBucketSummaryList, {
54
+ summaryData: deleteSummaryData
55
+ })
56
+ ]
57
+ })
58
+ });
59
+ };
60
+ export { EmptyBucketSummary };
@@ -0,0 +1,13 @@
1
+ interface DeleteSummaryData extends Record<string, unknown> {
2
+ attempts: number;
3
+ deleted: number;
4
+ errors: {
5
+ nbErrors: number;
6
+ messages: string[];
7
+ };
8
+ }
9
+ interface EmptyBucketSummaryListProps {
10
+ summaryData: DeleteSummaryData[];
11
+ }
12
+ export declare const EmptyBucketSummaryList: ({ summaryData, }: EmptyBucketSummaryListProps) => import("react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -0,0 +1,140 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { BasicText, Icon, IconHelp, Stack, Text } from "@scality/core-ui";
3
+ import { Table } from "@scality/core-ui/dist/components/tablev2/Tablev2.component";
4
+ import { useMemo } from "react";
5
+ const getUniqueErrorMessages = (errorMessages)=>{
6
+ const uniqueArray = errorMessages.reduce((acc, message)=>{
7
+ const existingItem = acc.find((item)=>item.message === message);
8
+ if (existingItem) existingItem.errorNumbers++;
9
+ else acc.push({
10
+ message,
11
+ errorNumbers: 1
12
+ });
13
+ return acc;
14
+ }, []);
15
+ return uniqueArray;
16
+ };
17
+ const ErrorsTable = ({ messages })=>{
18
+ const messagesColumns = [
19
+ {
20
+ Header: "Error Message",
21
+ accessor: "message",
22
+ cellStyle: {
23
+ minWidth: "8rem"
24
+ },
25
+ Cell ({ value }) {
26
+ return /*#__PURE__*/ jsx(Text, {
27
+ children: value
28
+ });
29
+ }
30
+ },
31
+ {
32
+ Header: "Number of errors",
33
+ accessor: "errorNumbers",
34
+ cellStyle: {
35
+ minWidth: "8rem"
36
+ },
37
+ Cell ({ value }) {
38
+ return /*#__PURE__*/ jsx(Text, {
39
+ children: value
40
+ });
41
+ }
42
+ }
43
+ ];
44
+ const list = getUniqueErrorMessages(messages);
45
+ const TABLE_HEIGHT = 5 * list.length;
46
+ return /*#__PURE__*/ jsx(IconHelp, {
47
+ placement: "top",
48
+ overlayStyle: {
49
+ width: "30rem"
50
+ },
51
+ tooltipMessage: /*#__PURE__*/ jsx("div", {
52
+ style: {
53
+ height: `${TABLE_HEIGHT}rem`
54
+ },
55
+ children: /*#__PURE__*/ jsx(Table, {
56
+ columns: messagesColumns,
57
+ data: list,
58
+ children: /*#__PURE__*/ jsx(Table.SingleSelectableContent, {
59
+ rowHeight: "h32",
60
+ separationLineVariant: "backgroundLevel3"
61
+ })
62
+ })
63
+ })
64
+ });
65
+ };
66
+ const SummaryCell = (value, isFailed = false, withIcon = false, messages)=>{
67
+ const text = 1 === value ? "1 object" : `${value} objects`;
68
+ if (withIcon) return /*#__PURE__*/ jsxs(Stack, {
69
+ children: [
70
+ /*#__PURE__*/ jsx(Icon, {
71
+ name: isFailed ? "Exclamation-circle" : "Check-circle",
72
+ color: isFailed ? "statusCritical" : "statusHealthy"
73
+ }),
74
+ /*#__PURE__*/ jsx(BasicText, {
75
+ children: text
76
+ }),
77
+ messages?.length ? /*#__PURE__*/ jsx(ErrorsTable, {
78
+ messages: messages
79
+ }) : null
80
+ ]
81
+ });
82
+ return /*#__PURE__*/ jsx(BasicText, {
83
+ children: text
84
+ });
85
+ };
86
+ const useCreateDeleteSummaryColumns = ()=>useMemo(()=>[
87
+ {
88
+ Header: "Total attempts",
89
+ accessor: "attempts",
90
+ cellStyle: {
91
+ minWidth: "12rem"
92
+ },
93
+ Cell ({ value }) {
94
+ return SummaryCell(value);
95
+ }
96
+ },
97
+ {
98
+ Header: "Successfully deleted",
99
+ accessor: "deleted",
100
+ cellStyle: {
101
+ minWidth: "12rem"
102
+ },
103
+ Cell ({ value }) {
104
+ return SummaryCell(value, false, true);
105
+ }
106
+ },
107
+ {
108
+ Header: "Deletion failed",
109
+ accessor: "errors",
110
+ cellStyle: {
111
+ minWidth: "12rem"
112
+ },
113
+ Cell ({ value }) {
114
+ return SummaryCell(value.nbErrors, true, true, value.messages);
115
+ }
116
+ }
117
+ ], []);
118
+ const EmptyBucketSummaryList = ({ summaryData })=>{
119
+ const summaryColumns = useCreateDeleteSummaryColumns();
120
+ return /*#__PURE__*/ jsx("div", {
121
+ style: {
122
+ height: "15rem"
123
+ },
124
+ children: /*#__PURE__*/ jsx(Table, {
125
+ columns: summaryColumns,
126
+ data: summaryData,
127
+ children: /*#__PURE__*/ jsx("div", {
128
+ style: {
129
+ height: "10rem",
130
+ paddingBottom: "5rem"
131
+ },
132
+ children: /*#__PURE__*/ jsx(Table.SingleSelectableContent, {
133
+ rowHeight: "h40",
134
+ separationLineVariant: "backgroundLevel1"
135
+ })
136
+ })
137
+ })
138
+ });
139
+ };
140
+ export { EmptyBucketSummaryList };
@@ -0,0 +1,163 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { fireEvent, render, screen } from "@testing-library/react";
3
+ import { useGetBucketObjectLockConfiguration, useGetBucketVersioning, useISVBucketStatus, useSetBucketVersioning } from "../../../hooks/index.js";
4
+ import { createMockMutationResult, createTestWrapper, findToggleByLabel } from "../../../test/testUtils.js";
5
+ import { BucketVersioning } from "../BucketVersioning.js";
6
+ import { BucketOverviewContext } from "../BucketOverview.js";
7
+ const mockShowToast = jest.fn();
8
+ jest.mock("@scality/core-ui", ()=>({
9
+ ...jest.requireActual("@scality/core-ui"),
10
+ useToast: ()=>({
11
+ showToast: mockShowToast
12
+ })
13
+ }));
14
+ jest.mock("../../../hooks");
15
+ const mockUseGetBucketVersioning = jest.mocked(useGetBucketVersioning);
16
+ const mockUseGetBucketObjectLockConfiguration = jest.mocked(useGetBucketObjectLockConfiguration);
17
+ const mockUseISVBucketStatus = jest.mocked(useISVBucketStatus);
18
+ const mockUseSetBucketVersioning = jest.mocked(useSetBucketVersioning);
19
+ const renderBucketVersioning = (props = {})=>{
20
+ const mockMutate = jest.fn();
21
+ mockUseSetBucketVersioning.mockReturnValue(createMockMutationResult(mockMutate));
22
+ const Wrapper = createTestWrapper();
23
+ return {
24
+ ...render(/*#__PURE__*/ jsx(Wrapper, {
25
+ children: /*#__PURE__*/ jsx(BucketOverviewContext.Provider, {
26
+ value: {
27
+ bucketName: "test-bucket"
28
+ },
29
+ children: /*#__PURE__*/ jsx(BucketVersioning, {
30
+ ...props
31
+ })
32
+ })
33
+ })),
34
+ mutate: mockMutate
35
+ };
36
+ };
37
+ const mockHookDefaults = ()=>{
38
+ mockUseGetBucketVersioning.mockReturnValue({
39
+ data: {
40
+ Status: "Enabled"
41
+ },
42
+ status: "success",
43
+ error: null
44
+ });
45
+ mockUseGetBucketObjectLockConfiguration.mockReturnValue({
46
+ data: {
47
+ ObjectLockConfiguration: {
48
+ ObjectLockEnabled: "Disabled"
49
+ }
50
+ },
51
+ status: "success",
52
+ error: null
53
+ });
54
+ mockUseISVBucketStatus.mockReturnValue({
55
+ isVeeamBucket: false,
56
+ isCommvaultBucket: false,
57
+ isISVManaged: false,
58
+ isvApplication: void 0,
59
+ isLoading: false,
60
+ bucketTagsStatus: "success"
61
+ });
62
+ };
63
+ describe("BucketVersioning", ()=>{
64
+ beforeEach(()=>{
65
+ jest.clearAllMocks();
66
+ mockHookDefaults();
67
+ });
68
+ it("renders toggle with Active label when versioning is enabled", ()=>{
69
+ renderBucketVersioning();
70
+ const toggle = findToggleByLabel("Active");
71
+ expect(toggle).toBeInTheDocument();
72
+ expect(toggle).toBeChecked();
73
+ });
74
+ it("renders toggle with Inactive label when versioning is suspended", ()=>{
75
+ mockUseGetBucketVersioning.mockReturnValue({
76
+ data: {
77
+ Status: "Suspended"
78
+ },
79
+ status: "success",
80
+ error: null
81
+ });
82
+ renderBucketVersioning();
83
+ const toggle = findToggleByLabel("Inactive");
84
+ expect(toggle).toBeInTheDocument();
85
+ expect(toggle).not.toBeChecked();
86
+ });
87
+ it("calls mutation with Suspended status when disabling versioning", ()=>{
88
+ const { mutate } = renderBucketVersioning();
89
+ const toggle = findToggleByLabel("Active");
90
+ fireEvent.click(toggle);
91
+ expect(mutate).toHaveBeenCalledWith({
92
+ Bucket: "test-bucket",
93
+ VersioningConfiguration: {
94
+ Status: "Suspended"
95
+ }
96
+ }, expect.any(Object));
97
+ });
98
+ it("calls mutation with Enabled status when enabling versioning", ()=>{
99
+ mockUseGetBucketVersioning.mockReturnValue({
100
+ data: {
101
+ Status: "Suspended"
102
+ },
103
+ status: "success",
104
+ error: null
105
+ });
106
+ const { mutate } = renderBucketVersioning();
107
+ const toggle = findToggleByLabel("Inactive");
108
+ fireEvent.click(toggle);
109
+ expect(mutate).toHaveBeenCalledWith({
110
+ Bucket: "test-bucket",
111
+ VersioningConfiguration: {
112
+ Status: "Enabled"
113
+ }
114
+ }, expect.any(Object));
115
+ });
116
+ it("disables toggle when versioning data is loading", ()=>{
117
+ mockUseGetBucketVersioning.mockReturnValue({
118
+ data: void 0,
119
+ status: "pending",
120
+ error: null
121
+ });
122
+ renderBucketVersioning();
123
+ const toggle = screen.getByRole("checkbox");
124
+ expect(toggle).toHaveAttribute("aria-disabled", "true");
125
+ });
126
+ it("renders static Enabled text when Object Lock is enabled", ()=>{
127
+ mockUseGetBucketObjectLockConfiguration.mockReturnValue({
128
+ data: {
129
+ ObjectLockConfiguration: {
130
+ ObjectLockEnabled: "Enabled"
131
+ }
132
+ },
133
+ status: "success"
134
+ });
135
+ renderBucketVersioning();
136
+ expect(screen.getByText("Enabled")).toBeInTheDocument();
137
+ expect(screen.getByText(/Versioning cannot be suspended because Object-lock is enabled/i)).toBeInTheDocument();
138
+ expect(screen.queryByRole("checkbox")).not.toBeInTheDocument();
139
+ });
140
+ it("disables toggle when bucket is managed by Veeam", ()=>{
141
+ mockUseISVBucketStatus.mockReturnValue({
142
+ isVeeamBucket: true,
143
+ isCommvaultBucket: false,
144
+ isISVManaged: true,
145
+ isvApplication: "Veeam",
146
+ isLoading: false,
147
+ bucketTagsStatus: "success"
148
+ });
149
+ renderBucketVersioning();
150
+ const toggle = screen.getByRole("checkbox");
151
+ expect(toggle).toHaveAttribute("aria-disabled", "true");
152
+ });
153
+ it("disables toggle when versioning query errors", ()=>{
154
+ mockUseGetBucketVersioning.mockReturnValue({
155
+ data: void 0,
156
+ status: "error",
157
+ error: new Error("Failed to fetch versioning")
158
+ });
159
+ renderBucketVersioning();
160
+ const toggle = screen.getByRole("checkbox");
161
+ expect(toggle).toHaveAttribute("aria-disabled", "true");
162
+ });
163
+ });
@@ -0,0 +1 @@
1
+ export declare function BucketNotificationCreatePage(): import("react/jsx-runtime").JSX.Element;