@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,1085 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { joiResolver } from "@hookform/resolvers/joi";
3
+ import { Form, FormGroup, FormSection, Icon, Loader, Stack, Text, Toggle, spacing, useToast } from "@scality/core-ui";
4
+ import { convertRemToPixels } from "@scality/core-ui/dist/components/tablev2/TableUtils";
5
+ import { Box, Button, Input, Select } from "@scality/core-ui/dist/next";
6
+ import joi from "joi";
7
+ import { useCallback, useEffect, useMemo, useRef } from "react";
8
+ import { Controller, FormProvider, useFieldArray, useForm } from "react-hook-form";
9
+ import { useNavigate, useParams } from "react-router-dom";
10
+ import { useGetBucketLifecycle, useSetBucketLifecycle } from "../../hooks/bucketConfiguration.js";
11
+ import { FilterFormSection, createFilterValidationSchema } from "../ui/FilterFormSection.js";
12
+ import { ArrayFieldActions } from "../ui/ArrayFieldActions.js";
13
+ import { AWS_RULE_LIMITS, STATUS_OPTIONS, buildS3Filter } from "../../utils/s3RuleUtils.js";
14
+ const storageClassOptions = [
15
+ {
16
+ value: "GLACIER",
17
+ label: "Glacier"
18
+ },
19
+ {
20
+ value: "DEEP_ARCHIVE",
21
+ label: "Glacier Deep Archive"
22
+ },
23
+ {
24
+ value: "STANDARD_IA",
25
+ label: "Standard-IA"
26
+ },
27
+ {
28
+ value: "ONEZONE_IA",
29
+ label: "One Zone-IA"
30
+ },
31
+ {
32
+ value: "INTELLIGENT_TIERING",
33
+ label: "Intelligent-Tiering"
34
+ },
35
+ {
36
+ value: "GLACIER_IR",
37
+ label: "Glacier Instant Retrieval"
38
+ }
39
+ ];
40
+ const STORAGE_CLASS_MIN_DAYS = {
41
+ GLACIER_IR: 0,
42
+ STANDARD_IA: 30,
43
+ ONEZONE_IA: 30,
44
+ INTELLIGENT_TIERING: 30,
45
+ GLACIER: 90,
46
+ DEEP_ARCHIVE: 180
47
+ };
48
+ const LIFECYCLE_LIMITS = {
49
+ NONCURRENT_TRANSITION_MIN_DAYS: 30,
50
+ ABORT_MPU_MIN_DAYS: 1
51
+ };
52
+ const schema = joi.object({
53
+ ruleId: joi.string().required().max(AWS_RULE_LIMITS.RULE_ID_MAX_LENGTH).messages({
54
+ "string.empty": "Rule ID is required",
55
+ "string.max": `Rule ID must not exceed ${AWS_RULE_LIMITS.RULE_ID_MAX_LENGTH} characters`
56
+ }),
57
+ status: joi.string().valid(...STATUS_OPTIONS.map((o)=>o.value)).required(),
58
+ ...createFilterValidationSchema(joi),
59
+ transitionsEnabled: joi.boolean(),
60
+ transitions: joi.when("transitionsEnabled", {
61
+ is: true,
62
+ then: joi.array().items(joi.object({
63
+ timeType: joi.string().valid("days", "date").required(),
64
+ days: joi.when("timeType", {
65
+ is: "days",
66
+ then: joi.number().integer().min(0).required().messages({
67
+ "number.base": "Days must be a number",
68
+ "number.min": "Days must be at least 0"
69
+ }),
70
+ otherwise: joi.any()
71
+ }),
72
+ date: joi.when("timeType", {
73
+ is: "date",
74
+ then: joi.string().required().messages({
75
+ "string.empty": "Date is required"
76
+ }),
77
+ otherwise: joi.any()
78
+ }),
79
+ storageClass: joi.string().valid(...storageClassOptions.map((o)=>o.value)).required().messages({
80
+ "string.empty": "Storage class is required"
81
+ })
82
+ }).custom((value, helpers)=>{
83
+ if ("days" === value.timeType && value.storageClass && value.days < STORAGE_CLASS_MIN_DAYS[value.storageClass]) return helpers.error("any.custom", {
84
+ message: `${value.storageClass} requires at least ${STORAGE_CLASS_MIN_DAYS[value.storageClass]} days`
85
+ });
86
+ return value;
87
+ })).min(1).messages({
88
+ "array.min": "At least one transition is required when enabled"
89
+ }),
90
+ otherwise: joi.any()
91
+ }),
92
+ expirationEnabled: joi.boolean(),
93
+ expirationType: joi.when("expirationEnabled", {
94
+ is: true,
95
+ then: joi.string().valid("days", "date").required(),
96
+ otherwise: joi.any()
97
+ }),
98
+ expirationDays: joi.when("expirationType", {
99
+ is: "days",
100
+ then: joi.number().integer().min(1).required().messages({
101
+ "number.base": "Days must be a number",
102
+ "number.min": "Days must be at least 1"
103
+ }),
104
+ otherwise: joi.any()
105
+ }),
106
+ expirationDate: joi.when("expirationType", {
107
+ is: "date",
108
+ then: joi.string().required().messages({
109
+ "string.empty": "Date is required"
110
+ }),
111
+ otherwise: joi.any()
112
+ }),
113
+ expiredObjectDeleteMarker: joi.boolean(),
114
+ noncurrentTransitionsEnabled: joi.boolean(),
115
+ noncurrentTransitions: joi.when("noncurrentTransitionsEnabled", {
116
+ is: true,
117
+ then: joi.array().items(joi.object({
118
+ noncurrentDays: joi.number().integer().min(LIFECYCLE_LIMITS.NONCURRENT_TRANSITION_MIN_DAYS).required().messages({
119
+ "number.base": "Noncurrent days must be a number",
120
+ "number.min": `Noncurrent days must be at least ${LIFECYCLE_LIMITS.NONCURRENT_TRANSITION_MIN_DAYS}`
121
+ }),
122
+ storageClass: joi.string().valid(...storageClassOptions.map((o)=>o.value)).required().messages({
123
+ "string.empty": "Storage class is required"
124
+ }),
125
+ newerNoncurrentVersions: joi.number().integer().min(0).optional().allow(null, "")
126
+ })).min(1).messages({
127
+ "array.min": "At least one noncurrent transition is required when enabled"
128
+ }),
129
+ otherwise: joi.any()
130
+ }),
131
+ noncurrentExpirationEnabled: joi.boolean(),
132
+ noncurrentExpirationDays: joi.when("noncurrentExpirationEnabled", {
133
+ is: true,
134
+ then: joi.number().integer().min(1).required().messages({
135
+ "number.base": "Noncurrent days must be a number",
136
+ "number.min": "Noncurrent days must be at least 1"
137
+ }),
138
+ otherwise: joi.any()
139
+ }),
140
+ noncurrentNewerVersions: joi.number().integer().min(0).optional().allow(null, ""),
141
+ abortMpuEnabled: joi.boolean(),
142
+ abortMpuDays: joi.when("abortMpuEnabled", {
143
+ is: true,
144
+ then: joi.number().integer().min(LIFECYCLE_LIMITS.ABORT_MPU_MIN_DAYS).required().messages({
145
+ "number.base": "Days must be a number",
146
+ "number.min": `Days must be at least ${LIFECYCLE_LIMITS.ABORT_MPU_MIN_DAYS}`
147
+ }),
148
+ otherwise: joi.any()
149
+ })
150
+ }).custom((value, helpers)=>{
151
+ const hasAtLeastOneAction = value.transitionsEnabled || value.expirationEnabled || value.expiredObjectDeleteMarker || value.noncurrentTransitionsEnabled || value.noncurrentExpirationEnabled || value.abortMpuEnabled;
152
+ if (!hasAtLeastOneAction) return helpers.error("any.custom", {
153
+ message: "At least one lifecycle action must be enabled (transition, expiration, or abort multipart upload)"
154
+ });
155
+ if (value.expirationEnabled && value.expiredObjectDeleteMarker) return helpers.error("any.custom", {
156
+ message: "Expired delete markers removal cannot be combined with Days/Date expiration on the same rule"
157
+ });
158
+ if (("tags" === value.filterType || "and" === value.filterType) && value.abortMpuEnabled) return helpers.error("any.custom", {
159
+ message: "Tag-based filter cannot be used with Abort Incomplete Multipart Upload"
160
+ });
161
+ return value;
162
+ });
163
+ const getArrayFieldError = (errors, fieldName, index, propertyName)=>{
164
+ const fieldErrors = errors?.[fieldName];
165
+ if (!fieldErrors?.[index]) return;
166
+ if (propertyName) return fieldErrors[index]?.[propertyName]?.message;
167
+ return fieldErrors[index]?.message;
168
+ };
169
+ const ruleToFormValues = (rule)=>{
170
+ const formValues = {
171
+ ruleId: rule.ID || "",
172
+ status: rule.Status || "Enabled",
173
+ filterType: "none",
174
+ prefix: "",
175
+ tags: [],
176
+ transitionsEnabled: false,
177
+ transitions: [],
178
+ expirationEnabled: false,
179
+ expirationType: "days",
180
+ expirationDays: 30,
181
+ expirationDate: "",
182
+ expiredObjectDeleteMarker: false,
183
+ noncurrentTransitionsEnabled: false,
184
+ noncurrentTransitions: [],
185
+ noncurrentExpirationEnabled: false,
186
+ noncurrentExpirationDays: 30,
187
+ noncurrentNewerVersions: 0,
188
+ abortMpuEnabled: false,
189
+ abortMpuDays: 7
190
+ };
191
+ if (void 0 !== rule.Prefix && "" !== rule.Prefix) {
192
+ formValues.filterType = "prefix";
193
+ formValues.prefix = rule.Prefix;
194
+ } else if (rule.Filter) {
195
+ if (rule.Filter.And) {
196
+ formValues.filterType = "and";
197
+ formValues.prefix = rule.Filter.And.Prefix || "";
198
+ formValues.tags = rule.Filter.And.Tags?.map((tag)=>({
199
+ key: tag.Key || "",
200
+ value: tag.Value || ""
201
+ })) || [];
202
+ } else if (void 0 !== rule.Filter.Prefix) {
203
+ formValues.filterType = "prefix";
204
+ formValues.prefix = rule.Filter.Prefix;
205
+ } else if (rule.Filter.Tag) {
206
+ formValues.filterType = "tags";
207
+ formValues.tags = [
208
+ {
209
+ key: rule.Filter.Tag.Key || "",
210
+ value: rule.Filter.Tag.Value || ""
211
+ }
212
+ ];
213
+ }
214
+ }
215
+ if (rule.Transitions && rule.Transitions.length > 0) {
216
+ formValues.transitionsEnabled = true;
217
+ formValues.transitions = rule.Transitions.map((t)=>({
218
+ timeType: void 0 !== t.Days ? "days" : "date",
219
+ days: t.Days || 30,
220
+ date: t.Date ? new Date(t.Date).toISOString().split("T")[0] : "",
221
+ storageClass: t.StorageClass || "GLACIER"
222
+ }));
223
+ }
224
+ if (rule.Expiration) {
225
+ if (rule.Expiration.Days) {
226
+ formValues.expirationEnabled = true;
227
+ formValues.expirationType = "days";
228
+ formValues.expirationDays = rule.Expiration.Days;
229
+ } else if (rule.Expiration.Date) {
230
+ formValues.expirationEnabled = true;
231
+ formValues.expirationType = "date";
232
+ formValues.expirationDate = new Date(rule.Expiration.Date).toISOString().split("T")[0];
233
+ }
234
+ if (rule.Expiration.ExpiredObjectDeleteMarker) formValues.expiredObjectDeleteMarker = true;
235
+ }
236
+ if (rule.NoncurrentVersionTransitions && rule.NoncurrentVersionTransitions.length > 0) {
237
+ formValues.noncurrentTransitionsEnabled = true;
238
+ formValues.noncurrentTransitions = rule.NoncurrentVersionTransitions.map((t)=>({
239
+ noncurrentDays: t.NoncurrentDays || 30,
240
+ storageClass: t.StorageClass || "GLACIER",
241
+ newerNoncurrentVersions: t.NewerNoncurrentVersions || 0
242
+ }));
243
+ }
244
+ if (rule.NoncurrentVersionExpiration) {
245
+ formValues.noncurrentExpirationEnabled = true;
246
+ formValues.noncurrentExpirationDays = rule.NoncurrentVersionExpiration.NoncurrentDays || 30;
247
+ formValues.noncurrentNewerVersions = rule.NoncurrentVersionExpiration.NewerNoncurrentVersions || 0;
248
+ }
249
+ if (rule.AbortIncompleteMultipartUpload) {
250
+ formValues.abortMpuEnabled = true;
251
+ formValues.abortMpuDays = rule.AbortIncompleteMultipartUpload.DaysAfterInitiation || 7;
252
+ }
253
+ return formValues;
254
+ };
255
+ const generateStorageClassHelpText = ()=>{
256
+ const hints = [];
257
+ storageClassOptions.forEach((option)=>{
258
+ const minDays = STORAGE_CLASS_MIN_DAYS[option.value];
259
+ if (minDays > 0) hints.push(`<li>${option.label}: min ${minDays} days</li>`);
260
+ });
261
+ return hints.length > 0 ? `Storage class requirements:<ul>${hints.join("")}</ul>` : void 0;
262
+ };
263
+ function BucketLifecycleFormPage() {
264
+ const { bucketName, ruleId } = useParams();
265
+ const navigate = useNavigate();
266
+ const { showToast } = useToast();
267
+ const isEditMode = !!ruleId;
268
+ const { data: lifecycleData, status: lifecycleStatus } = useGetBucketLifecycle({
269
+ Bucket: bucketName
270
+ });
271
+ const existingRule = useMemo(()=>{
272
+ if (!isEditMode || !lifecycleData?.Rules || !ruleId) return null;
273
+ return lifecycleData.Rules.find((rule)=>rule.ID === decodeURIComponent(ruleId)) || null;
274
+ }, [
275
+ isEditMode,
276
+ lifecycleData,
277
+ ruleId
278
+ ]);
279
+ const existingRuleIds = useMemo(()=>(lifecycleData?.Rules || []).map((rule)=>rule.ID).filter(Boolean).filter((id)=>!isEditMode || id !== existingRule?.ID), [
280
+ lifecycleData,
281
+ isEditMode,
282
+ existingRule
283
+ ]);
284
+ const dynamicSchema = useMemo(()=>schema.keys({
285
+ ruleId: joi.string().required().invalid(...existingRuleIds).messages({
286
+ "string.empty": "Rule ID is required",
287
+ "any.invalid": "A rule with this ID already exists"
288
+ })
289
+ }), [
290
+ existingRuleIds
291
+ ]);
292
+ const methods = useForm({
293
+ resolver: joiResolver(dynamicSchema),
294
+ mode: "onChange",
295
+ defaultValues: {
296
+ ruleId: "",
297
+ status: "Enabled",
298
+ filterType: "none",
299
+ prefix: "",
300
+ tags: [],
301
+ transitionsEnabled: false,
302
+ transitions: [],
303
+ expirationEnabled: false,
304
+ expirationType: "days",
305
+ expirationDays: 30,
306
+ expirationDate: "",
307
+ expiredObjectDeleteMarker: false,
308
+ noncurrentTransitionsEnabled: false,
309
+ noncurrentTransitions: [],
310
+ noncurrentExpirationEnabled: false,
311
+ noncurrentExpirationDays: 30,
312
+ noncurrentNewerVersions: 0,
313
+ abortMpuEnabled: false,
314
+ abortMpuDays: 7
315
+ }
316
+ });
317
+ const { handleSubmit, register, control, watch, reset, formState: { isValid, isDirty, errors } } = methods;
318
+ const { fields: transitionFields, append: appendTransition, remove: removeTransition } = useFieldArray({
319
+ control,
320
+ name: "transitions"
321
+ });
322
+ const { fields: noncurrentTransitionFields, append: appendNoncurrentTransition, remove: removeNoncurrentTransition } = useFieldArray({
323
+ control,
324
+ name: "noncurrentTransitions"
325
+ });
326
+ const { fields: tagFields, append: appendTag, remove: removeTag } = useFieldArray({
327
+ control,
328
+ name: "tags"
329
+ });
330
+ const filterType = watch("filterType");
331
+ const transitionsEnabled = watch("transitionsEnabled");
332
+ const expirationEnabled = watch("expirationEnabled");
333
+ const expirationType = watch("expirationType");
334
+ const expiredObjectDeleteMarker = watch("expiredObjectDeleteMarker");
335
+ const noncurrentTransitionsEnabled = watch("noncurrentTransitionsEnabled");
336
+ const noncurrentExpirationEnabled = watch("noncurrentExpirationEnabled");
337
+ const abortMpuEnabled = watch("abortMpuEnabled");
338
+ const { mutate: setLifecycle, isPending: isSaving } = useSetBucketLifecycle();
339
+ const transitionsHelpText = useMemo(()=>{
340
+ if (!transitionsEnabled || 0 === transitionFields.length) return;
341
+ return generateStorageClassHelpText();
342
+ }, [
343
+ transitionsEnabled,
344
+ transitionFields.length
345
+ ]);
346
+ const noncurrentTransitionsHelpText = useMemo(()=>{
347
+ if (!noncurrentTransitionsEnabled || 0 === noncurrentTransitionFields.length) return;
348
+ return generateStorageClassHelpText();
349
+ }, [
350
+ noncurrentTransitionsEnabled,
351
+ noncurrentTransitionFields.length
352
+ ]);
353
+ useEffect(()=>{
354
+ if (isEditMode && existingRule) {
355
+ const formValues = ruleToFormValues(existingRule);
356
+ reset(formValues);
357
+ }
358
+ }, [
359
+ isEditMode,
360
+ existingRule,
361
+ reset
362
+ ]);
363
+ const prevTransitionsEnabledRef = useRef(null);
364
+ const prevNoncurrentTransitionsEnabledRef = useRef(null);
365
+ useEffect(()=>{
366
+ const prevValue = prevTransitionsEnabledRef.current;
367
+ prevTransitionsEnabledRef.current = transitionsEnabled;
368
+ if (!isEditMode && null !== prevValue && !prevValue && transitionsEnabled && 0 === transitionFields.length) appendTransition({
369
+ timeType: "days",
370
+ days: 30,
371
+ date: "",
372
+ storageClass: "STANDARD_IA"
373
+ });
374
+ }, [
375
+ isEditMode,
376
+ transitionsEnabled,
377
+ transitionFields.length,
378
+ appendTransition
379
+ ]);
380
+ useEffect(()=>{
381
+ const prevValue = prevNoncurrentTransitionsEnabledRef.current;
382
+ prevNoncurrentTransitionsEnabledRef.current = noncurrentTransitionsEnabled;
383
+ if (!isEditMode && null !== prevValue && !prevValue && noncurrentTransitionsEnabled && 0 === noncurrentTransitionFields.length) appendNoncurrentTransition({
384
+ noncurrentDays: 30,
385
+ storageClass: "GLACIER",
386
+ newerNoncurrentVersions: 0
387
+ });
388
+ }, [
389
+ isEditMode,
390
+ noncurrentTransitionsEnabled,
391
+ noncurrentTransitionFields.length,
392
+ appendNoncurrentTransition
393
+ ]);
394
+ const prevFilterTypeRef = useRef();
395
+ useEffect(()=>{
396
+ const prevFilterType = prevFilterTypeRef.current;
397
+ prevFilterTypeRef.current = filterType;
398
+ if (("tags" === filterType || "and" === filterType) && 0 === tagFields.length) {
399
+ if (!isEditMode || void 0 !== prevFilterType && prevFilterType !== filterType) appendTag({
400
+ key: "",
401
+ value: ""
402
+ });
403
+ }
404
+ if (void 0 !== prevFilterType && prevFilterType !== filterType) {
405
+ if (("none" === filterType || "prefix" === filterType) && tagFields.length > 0) tagFields.forEach((_, index)=>{
406
+ removeTag(tagFields.length - 1 - index);
407
+ });
408
+ if ("none" === filterType) methods.setValue("prefix", "", {
409
+ shouldDirty: true
410
+ });
411
+ }
412
+ }, [
413
+ isEditMode,
414
+ filterType,
415
+ tagFields,
416
+ appendTag,
417
+ removeTag,
418
+ methods
419
+ ]);
420
+ const handleCancel = useCallback(()=>{
421
+ navigate(`/buckets/${bucketName}?tab=lifecycle`);
422
+ }, [
423
+ navigate,
424
+ bucketName
425
+ ]);
426
+ const onSubmit = useCallback((data)=>{
427
+ if (!bucketName) return;
428
+ const rule = {
429
+ ID: data.ruleId,
430
+ Status: data.status
431
+ };
432
+ rule.Filter = buildS3Filter(data);
433
+ if (data.transitionsEnabled && data.transitions.length > 0) rule.Transitions = data.transitions.map((transition)=>{
434
+ const t = {
435
+ StorageClass: transition.storageClass
436
+ };
437
+ if ("days" === transition.timeType) t.Days = transition.days;
438
+ else t.Date = new Date(transition.date);
439
+ return t;
440
+ });
441
+ if (data.expirationEnabled || data.expiredObjectDeleteMarker) {
442
+ rule.Expiration = {};
443
+ if (data.expirationEnabled) {
444
+ if ("days" === data.expirationType) rule.Expiration.Days = data.expirationDays;
445
+ else if ("date" === data.expirationType) rule.Expiration.Date = new Date(data.expirationDate);
446
+ }
447
+ if (data.expiredObjectDeleteMarker) rule.Expiration.ExpiredObjectDeleteMarker = true;
448
+ }
449
+ if (data.noncurrentTransitionsEnabled && data.noncurrentTransitions.length > 0) rule.NoncurrentVersionTransitions = data.noncurrentTransitions.map((transition)=>({
450
+ NoncurrentDays: transition.noncurrentDays,
451
+ StorageClass: transition.storageClass,
452
+ ...transition.newerNoncurrentVersions && transition.newerNoncurrentVersions > 0 && {
453
+ NewerNoncurrentVersions: transition.newerNoncurrentVersions
454
+ }
455
+ }));
456
+ if (data.noncurrentExpirationEnabled) rule.NoncurrentVersionExpiration = {
457
+ NoncurrentDays: data.noncurrentExpirationDays,
458
+ ...data.noncurrentNewerVersions && data.noncurrentNewerVersions > 0 && {
459
+ NewerNoncurrentVersions: data.noncurrentNewerVersions
460
+ }
461
+ };
462
+ if (data.abortMpuEnabled) rule.AbortIncompleteMultipartUpload = {
463
+ DaysAfterInitiation: data.abortMpuDays
464
+ };
465
+ const existingRules = lifecycleData?.Rules || [];
466
+ const updatedRules = isEditMode ? existingRules.map((r)=>r.ID === existingRule?.ID ? rule : r) : [
467
+ ...existingRules,
468
+ rule
469
+ ];
470
+ setLifecycle({
471
+ Bucket: bucketName,
472
+ LifecycleConfiguration: {
473
+ Rules: updatedRules
474
+ }
475
+ }, {
476
+ onSuccess: ()=>{
477
+ showToast({
478
+ open: true,
479
+ message: `Lifecycle rule ${isEditMode ? "updated" : "created"} successfully`,
480
+ status: "success"
481
+ });
482
+ navigate(`/buckets/${bucketName}?tab=lifecycle`);
483
+ },
484
+ onError: (error)=>{
485
+ const errorMessage = error instanceof Error ? error.message : `Failed to ${isEditMode ? "update" : "create"} lifecycle rule`;
486
+ showToast({
487
+ open: true,
488
+ message: errorMessage,
489
+ status: "error"
490
+ });
491
+ }
492
+ });
493
+ }, [
494
+ bucketName,
495
+ setLifecycle,
496
+ navigate,
497
+ showToast,
498
+ lifecycleData,
499
+ isEditMode,
500
+ existingRule
501
+ ]);
502
+ if ("pending" === lifecycleStatus) return /*#__PURE__*/ jsx(Loader, {
503
+ centered: true,
504
+ children: /*#__PURE__*/ jsx(Text, {
505
+ children: "Loading..."
506
+ })
507
+ });
508
+ if (isEditMode && !existingRule) return /*#__PURE__*/ jsx(Box, {
509
+ padding: spacing.r16,
510
+ children: /*#__PURE__*/ jsx(Text, {
511
+ color: "statusCritical",
512
+ children: "Rule not found"
513
+ })
514
+ });
515
+ return /*#__PURE__*/ jsx(FormProvider, {
516
+ ...methods,
517
+ children: /*#__PURE__*/ jsxs(Form, {
518
+ layout: {
519
+ kind: "page",
520
+ title: isEditMode ? "Edit Lifecycle Rule" : "Create Lifecycle Rule"
521
+ },
522
+ requireMode: "partial",
523
+ onSubmit: handleSubmit(onSubmit),
524
+ rightActions: /*#__PURE__*/ jsxs(Stack, {
525
+ gap: "r16",
526
+ children: [
527
+ /*#__PURE__*/ jsx(Button, {
528
+ id: "cancel-btn",
529
+ variant: "outline",
530
+ type: "button",
531
+ label: "Cancel",
532
+ onClick: handleCancel,
533
+ disabled: isSaving
534
+ }),
535
+ /*#__PURE__*/ jsx(Button, {
536
+ id: isEditMode ? "save-lifecycle-btn" : "create-lifecycle-btn",
537
+ type: "submit",
538
+ variant: "primary",
539
+ label: isEditMode ? "Save" : "Create",
540
+ icon: isEditMode ? /*#__PURE__*/ jsx(Icon, {
541
+ name: "Save"
542
+ }) : void 0,
543
+ disabled: isEditMode ? !isDirty || !isValid || isSaving : !isValid || isSaving
544
+ })
545
+ ]
546
+ }),
547
+ children: [
548
+ /*#__PURE__*/ jsxs(FormSection, {
549
+ title: {
550
+ name: "Rule Scope"
551
+ },
552
+ forceLabelWidth: convertRemToPixels(15),
553
+ children: [
554
+ /*#__PURE__*/ jsx(FormGroup, {
555
+ label: "Rule ID",
556
+ id: "ruleId",
557
+ direction: "horizontal",
558
+ error: errors?.ruleId?.message,
559
+ helpErrorPosition: "bottom",
560
+ required: true,
561
+ content: isEditMode ? /*#__PURE__*/ jsx(Text, {
562
+ children: watch("ruleId")
563
+ }) : /*#__PURE__*/ jsx(Input, {
564
+ id: "ruleId",
565
+ ...register("ruleId")
566
+ })
567
+ }),
568
+ /*#__PURE__*/ jsx(FormGroup, {
569
+ label: "Status",
570
+ id: "status",
571
+ direction: "horizontal",
572
+ error: errors?.status?.message,
573
+ helpErrorPosition: "bottom",
574
+ required: true,
575
+ content: /*#__PURE__*/ jsx(Controller, {
576
+ name: "status",
577
+ control: control,
578
+ render: ({ field })=>/*#__PURE__*/ jsx(Select, {
579
+ id: "status",
580
+ value: field.value,
581
+ onChange: field.onChange,
582
+ children: STATUS_OPTIONS.map((option)=>/*#__PURE__*/ jsx(Select.Option, {
583
+ value: option.value,
584
+ children: option.label
585
+ }, option.value))
586
+ })
587
+ })
588
+ })
589
+ ]
590
+ }),
591
+ /*#__PURE__*/ jsx(FilterFormSection, {
592
+ filterType: filterType,
593
+ onFilterTypeChange: (value)=>methods.setValue("filterType", value),
594
+ prefixRegister: register("prefix"),
595
+ tagFields: tagFields,
596
+ tagKeyRegister: (index)=>register(`tags.${index}.key`),
597
+ tagValueRegister: (index)=>register(`tags.${index}.value`),
598
+ getTagKeyValue: (index)=>watch(`tags.${index}.key`),
599
+ getTagValueValue: (index)=>watch(`tags.${index}.value`),
600
+ appendTag: appendTag,
601
+ removeTag: removeTag,
602
+ errors: errors
603
+ }),
604
+ /*#__PURE__*/ jsxs(FormSection, {
605
+ title: {
606
+ name: transitionsEnabled || expirationEnabled || noncurrentTransitionsEnabled || noncurrentExpirationEnabled || abortMpuEnabled ? "Lifecycle Rule" : "Lifecycle Rule (At least one action must be enabled)"
607
+ },
608
+ forceLabelWidth: convertRemToPixels(18),
609
+ children: [
610
+ /*#__PURE__*/ jsx(FormGroup, {
611
+ label: "Transition current version",
612
+ id: "transitionsEnabled",
613
+ direction: "horizontal",
614
+ labelHelpTooltip: transitionsHelpText,
615
+ content: /*#__PURE__*/ jsx(Controller, {
616
+ name: "transitionsEnabled",
617
+ control: control,
618
+ render: ({ field })=>/*#__PURE__*/ jsx(Toggle, {
619
+ toggle: field.value,
620
+ onChange: field.onChange,
621
+ label: field.value ? "Enabled" : "Disabled"
622
+ })
623
+ })
624
+ }),
625
+ transitionsEnabled ? /*#__PURE__*/ jsx(FormGroup, {
626
+ label: "",
627
+ id: "transitions",
628
+ direction: "vertical",
629
+ error: errors?.transitions?.message,
630
+ helpErrorPosition: "bottom",
631
+ content: /*#__PURE__*/ jsxs(Stack, {
632
+ direction: "vertical",
633
+ gap: "r16",
634
+ children: [
635
+ /*#__PURE__*/ jsxs(Stack, {
636
+ gap: "r40",
637
+ direction: "horizontal",
638
+ children: [
639
+ /*#__PURE__*/ jsx(Box, {
640
+ flex: "1/2",
641
+ children: /*#__PURE__*/ jsx(Text, {
642
+ color: "textSecondary",
643
+ children: "Time Type"
644
+ })
645
+ }),
646
+ /*#__PURE__*/ jsx(Box, {
647
+ flex: "1/2",
648
+ children: /*#__PURE__*/ jsx(Text, {
649
+ color: "textSecondary",
650
+ children: "Value"
651
+ })
652
+ }),
653
+ /*#__PURE__*/ jsx(Box, {
654
+ width: convertRemToPixels(4)
655
+ }),
656
+ /*#__PURE__*/ jsx(Box, {
657
+ flex: "1",
658
+ children: /*#__PURE__*/ jsx(Text, {
659
+ color: "textSecondary",
660
+ children: "Storage Class"
661
+ })
662
+ })
663
+ ]
664
+ }),
665
+ transitionFields.map((field, index)=>/*#__PURE__*/ jsxs(Stack, {
666
+ gap: "r20",
667
+ direction: "vertical",
668
+ children: [
669
+ /*#__PURE__*/ jsxs(Stack, {
670
+ gap: "r20",
671
+ children: [
672
+ /*#__PURE__*/ jsx(Box, {
673
+ flex: "1",
674
+ children: /*#__PURE__*/ jsx(Controller, {
675
+ name: `transitions.${index}.timeType`,
676
+ control: control,
677
+ render: ({ field })=>/*#__PURE__*/ jsxs(Select, {
678
+ id: `transition-time-type-${index}`,
679
+ value: field.value,
680
+ onChange: field.onChange,
681
+ size: "1/3",
682
+ children: [
683
+ /*#__PURE__*/ jsx(Select.Option, {
684
+ value: "days",
685
+ children: "Days"
686
+ }),
687
+ /*#__PURE__*/ jsx(Select.Option, {
688
+ value: "date",
689
+ children: "Date"
690
+ })
691
+ ]
692
+ })
693
+ })
694
+ }),
695
+ /*#__PURE__*/ jsx(Box, {
696
+ flex: "1",
697
+ children: "days" === watch(`transitions.${index}.timeType`) ? /*#__PURE__*/ jsx(Input, {
698
+ id: `transition-days-${index}`,
699
+ type: "number",
700
+ placeholder: "Days",
701
+ size: "1/2",
702
+ ...register(`transitions.${index}.days`, {
703
+ valueAsNumber: true
704
+ })
705
+ }) : /*#__PURE__*/ jsx(Input, {
706
+ id: `transition-date-${index}`,
707
+ type: "date",
708
+ size: "1/2",
709
+ ...register(`transitions.${index}.date`)
710
+ })
711
+ }),
712
+ /*#__PURE__*/ jsx(Box, {
713
+ flex: "1",
714
+ children: /*#__PURE__*/ jsx(Controller, {
715
+ name: `transitions.${index}.storageClass`,
716
+ control: control,
717
+ render: ({ field })=>/*#__PURE__*/ jsx(Select, {
718
+ id: `transition-storage-class-${index}`,
719
+ value: field.value,
720
+ onChange: field.onChange,
721
+ placeholder: "Storage Class",
722
+ size: "2/3",
723
+ children: storageClassOptions.map((option)=>/*#__PURE__*/ jsx(Select.Option, {
724
+ value: option.value,
725
+ children: option.label
726
+ }, option.value))
727
+ })
728
+ })
729
+ }),
730
+ /*#__PURE__*/ jsx(ArrayFieldActions, {
731
+ showAdd: index === transitionFields.length - 1,
732
+ onRemove: ()=>removeTransition(index),
733
+ onAdd: ()=>appendTransition({
734
+ timeType: "days",
735
+ days: 30,
736
+ date: "",
737
+ storageClass: "STANDARD_IA"
738
+ }),
739
+ canRemove: transitionFields.length > 1
740
+ })
741
+ ]
742
+ }),
743
+ getArrayFieldError(errors, "transitions", index) && /*#__PURE__*/ jsx(Text, {
744
+ color: "statusCritical",
745
+ children: getArrayFieldError(errors, "transitions", index)
746
+ }),
747
+ getArrayFieldError(errors, "transitions", index, "days") && /*#__PURE__*/ jsx(Text, {
748
+ color: "statusCritical",
749
+ children: getArrayFieldError(errors, "transitions", index, "days")
750
+ }),
751
+ getArrayFieldError(errors, "transitions", index, "storageClass") && /*#__PURE__*/ jsx(Text, {
752
+ color: "statusCritical",
753
+ children: getArrayFieldError(errors, "transitions", index, "storageClass")
754
+ }),
755
+ getArrayFieldError(errors, "transitions", index, "date") && /*#__PURE__*/ jsx(Text, {
756
+ color: "statusCritical",
757
+ children: getArrayFieldError(errors, "transitions", index, "date")
758
+ })
759
+ ]
760
+ }, field.id))
761
+ ]
762
+ })
763
+ }) : /*#__PURE__*/ jsx(Fragment, {}),
764
+ /*#__PURE__*/ jsx(FormGroup, {
765
+ label: "Expiration current version",
766
+ id: "expirationEnabled",
767
+ direction: "horizontal",
768
+ labelHelpTooltip: "Expire objects after a specified time. Cannot be combined with expired delete markers removal.",
769
+ content: /*#__PURE__*/ jsx(Controller, {
770
+ name: "expirationEnabled",
771
+ control: control,
772
+ render: ({ field })=>/*#__PURE__*/ jsx(Toggle, {
773
+ toggle: field.value,
774
+ onChange: (value)=>{
775
+ field.onChange(value);
776
+ if (value && expiredObjectDeleteMarker) methods.setValue("expiredObjectDeleteMarker", false, {
777
+ shouldDirty: true
778
+ });
779
+ },
780
+ label: field.value ? "Enabled" : "Disabled",
781
+ disabled: expiredObjectDeleteMarker
782
+ })
783
+ })
784
+ }),
785
+ expirationEnabled ? /*#__PURE__*/ jsxs(Fragment, {
786
+ children: [
787
+ /*#__PURE__*/ jsx(FormGroup, {
788
+ label: "Expiration type",
789
+ id: "expirationType",
790
+ direction: "horizontal",
791
+ content: /*#__PURE__*/ jsx(Controller, {
792
+ name: "expirationType",
793
+ control: control,
794
+ render: ({ field })=>/*#__PURE__*/ jsxs(Select, {
795
+ id: "expirationType",
796
+ value: field.value,
797
+ onChange: field.onChange,
798
+ children: [
799
+ /*#__PURE__*/ jsx(Select.Option, {
800
+ value: "days",
801
+ children: "Days"
802
+ }),
803
+ /*#__PURE__*/ jsx(Select.Option, {
804
+ value: "date",
805
+ children: "Date"
806
+ })
807
+ ]
808
+ })
809
+ })
810
+ }),
811
+ "days" === expirationType && /*#__PURE__*/ jsx(FormGroup, {
812
+ label: "Days",
813
+ id: "expirationDays",
814
+ direction: "horizontal",
815
+ error: errors?.expirationDays?.message,
816
+ helpErrorPosition: "bottom",
817
+ content: /*#__PURE__*/ jsx(Box, {
818
+ flex: "1",
819
+ children: /*#__PURE__*/ jsx(Input, {
820
+ type: "number",
821
+ id: "expirationDays",
822
+ ...register("expirationDays", {
823
+ valueAsNumber: true
824
+ })
825
+ })
826
+ })
827
+ }),
828
+ "date" === expirationType && /*#__PURE__*/ jsx(FormGroup, {
829
+ label: "Date",
830
+ id: "expirationDate",
831
+ direction: "horizontal",
832
+ error: errors?.expirationDate?.message,
833
+ helpErrorPosition: "bottom",
834
+ content: /*#__PURE__*/ jsx(Input, {
835
+ type: "date",
836
+ id: "expirationDate",
837
+ ...register("expirationDate")
838
+ })
839
+ })
840
+ ]
841
+ }) : /*#__PURE__*/ jsx(Fragment, {}),
842
+ /*#__PURE__*/ jsx(FormGroup, {
843
+ label: "Remove expired delete markers",
844
+ id: "expiredObjectDeleteMarker",
845
+ direction: "horizontal",
846
+ labelHelpTooltip: "Automatically remove expired object delete markers in versioned buckets. Cannot be combined with Days/Date expiration.",
847
+ content: /*#__PURE__*/ jsx(Controller, {
848
+ name: "expiredObjectDeleteMarker",
849
+ control: control,
850
+ render: ({ field })=>/*#__PURE__*/ jsx(Toggle, {
851
+ toggle: field.value,
852
+ onChange: (value)=>{
853
+ field.onChange(value);
854
+ if (value && expirationEnabled) methods.setValue("expirationEnabled", false, {
855
+ shouldDirty: true
856
+ });
857
+ },
858
+ label: field.value ? "Enabled" : "Disabled",
859
+ disabled: expirationEnabled
860
+ })
861
+ })
862
+ }),
863
+ /*#__PURE__*/ jsx(FormGroup, {
864
+ label: "Transition noncurrent version",
865
+ id: "noncurrentTransitionsEnabled",
866
+ direction: "horizontal",
867
+ content: /*#__PURE__*/ jsx(Controller, {
868
+ name: "noncurrentTransitionsEnabled",
869
+ control: control,
870
+ render: ({ field })=>/*#__PURE__*/ jsx(Toggle, {
871
+ toggle: field.value,
872
+ onChange: field.onChange,
873
+ label: field.value ? "Enabled" : "Disabled"
874
+ })
875
+ })
876
+ }),
877
+ noncurrentTransitionsEnabled ? /*#__PURE__*/ jsx(FormGroup, {
878
+ label: "",
879
+ id: "noncurrentTransitions",
880
+ direction: "vertical",
881
+ error: errors?.noncurrentTransitions?.message,
882
+ helpErrorPosition: "bottom",
883
+ labelHelpTooltip: noncurrentTransitionsHelpText,
884
+ content: /*#__PURE__*/ jsxs(Stack, {
885
+ direction: "vertical",
886
+ gap: "r16",
887
+ children: [
888
+ /*#__PURE__*/ jsxs(Stack, {
889
+ gap: "r40",
890
+ direction: "horizontal",
891
+ children: [
892
+ /*#__PURE__*/ jsx(Box, {
893
+ flex: "1/2",
894
+ children: /*#__PURE__*/ jsx(Text, {
895
+ color: "textSecondary",
896
+ children: "Noncurrent Days"
897
+ })
898
+ }),
899
+ /*#__PURE__*/ jsx(Box, {
900
+ flex: "1/2",
901
+ children: /*#__PURE__*/ jsx(Text, {
902
+ color: "textSecondary",
903
+ children: "Keep Versions"
904
+ })
905
+ }),
906
+ /*#__PURE__*/ jsx(Box, {
907
+ flex: "1",
908
+ children: /*#__PURE__*/ jsx(Text, {
909
+ color: "textSecondary",
910
+ children: "Storage Class"
911
+ })
912
+ })
913
+ ]
914
+ }),
915
+ noncurrentTransitionFields.map((field, index)=>/*#__PURE__*/ jsxs(Stack, {
916
+ gap: "r16",
917
+ direction: "vertical",
918
+ children: [
919
+ /*#__PURE__*/ jsxs(Stack, {
920
+ gap: "r16",
921
+ children: [
922
+ /*#__PURE__*/ jsx(Box, {
923
+ flex: "1",
924
+ children: /*#__PURE__*/ jsx(Input, {
925
+ id: `noncurrent-transition-days-${index}`,
926
+ type: "number",
927
+ placeholder: "Noncurrent days",
928
+ size: "1/3",
929
+ ...register(`noncurrentTransitions.${index}.noncurrentDays`, {
930
+ valueAsNumber: true
931
+ })
932
+ })
933
+ }),
934
+ /*#__PURE__*/ jsx(Box, {
935
+ width: convertRemToPixels(2)
936
+ }),
937
+ /*#__PURE__*/ jsx(Box, {
938
+ flex: "1",
939
+ children: /*#__PURE__*/ jsx(Input, {
940
+ id: `noncurrent-transition-keep-versions-${index}`,
941
+ type: "number",
942
+ placeholder: "Keep versions",
943
+ size: "1/3",
944
+ ...register(`noncurrentTransitions.${index}.newerNoncurrentVersions`, {
945
+ valueAsNumber: true
946
+ })
947
+ })
948
+ }),
949
+ /*#__PURE__*/ jsx(Box, {
950
+ width: convertRemToPixels(0.5)
951
+ }),
952
+ /*#__PURE__*/ jsx(Box, {
953
+ flex: "1",
954
+ children: /*#__PURE__*/ jsx(Controller, {
955
+ name: `noncurrentTransitions.${index}.storageClass`,
956
+ control: control,
957
+ render: ({ field })=>/*#__PURE__*/ jsx(Select, {
958
+ id: `noncurrent-transition-storage-class-${index}`,
959
+ value: field.value,
960
+ onChange: field.onChange,
961
+ placeholder: "Storage Class",
962
+ size: "2/3",
963
+ children: storageClassOptions.map((option)=>/*#__PURE__*/ jsx(Select.Option, {
964
+ value: option.value,
965
+ children: option.label
966
+ }, option.value))
967
+ })
968
+ })
969
+ }),
970
+ /*#__PURE__*/ jsx(ArrayFieldActions, {
971
+ showAdd: index === noncurrentTransitionFields.length - 1,
972
+ onRemove: ()=>removeNoncurrentTransition(index),
973
+ onAdd: ()=>appendNoncurrentTransition({
974
+ noncurrentDays: 30,
975
+ storageClass: "GLACIER",
976
+ newerNoncurrentVersions: 0
977
+ }),
978
+ canRemove: noncurrentTransitionFields.length > 1
979
+ })
980
+ ]
981
+ }),
982
+ getArrayFieldError(errors, "noncurrentTransitions", index, "noncurrentDays") && /*#__PURE__*/ jsx(Text, {
983
+ color: "statusCritical",
984
+ children: getArrayFieldError(errors, "noncurrentTransitions", index, "noncurrentDays")
985
+ }),
986
+ getArrayFieldError(errors, "noncurrentTransitions", index, "storageClass") && /*#__PURE__*/ jsx(Text, {
987
+ color: "statusCritical",
988
+ children: getArrayFieldError(errors, "noncurrentTransitions", index, "storageClass")
989
+ })
990
+ ]
991
+ }, field.id))
992
+ ]
993
+ })
994
+ }) : /*#__PURE__*/ jsx(Fragment, {}),
995
+ /*#__PURE__*/ jsx(FormGroup, {
996
+ label: "Expiration noncurrent version",
997
+ id: "noncurrentExpirationEnabled",
998
+ direction: "horizontal",
999
+ content: /*#__PURE__*/ jsx(Controller, {
1000
+ name: "noncurrentExpirationEnabled",
1001
+ control: control,
1002
+ render: ({ field })=>/*#__PURE__*/ jsx(Toggle, {
1003
+ toggle: field.value,
1004
+ onChange: field.onChange,
1005
+ label: field.value ? "Enabled" : "Disabled"
1006
+ })
1007
+ })
1008
+ }),
1009
+ noncurrentExpirationEnabled ? /*#__PURE__*/ jsxs(Fragment, {
1010
+ children: [
1011
+ /*#__PURE__*/ jsx(FormGroup, {
1012
+ label: "Noncurrent days",
1013
+ id: "noncurrentExpirationDays",
1014
+ direction: "horizontal",
1015
+ error: errors?.noncurrentExpirationDays?.message,
1016
+ helpErrorPosition: "bottom",
1017
+ content: /*#__PURE__*/ jsx(Box, {
1018
+ flex: "1",
1019
+ children: /*#__PURE__*/ jsx(Input, {
1020
+ type: "number",
1021
+ id: "noncurrentExpirationDays",
1022
+ ...register("noncurrentExpirationDays", {
1023
+ valueAsNumber: true
1024
+ })
1025
+ })
1026
+ })
1027
+ }),
1028
+ /*#__PURE__*/ jsx(FormGroup, {
1029
+ label: "Keep newer versions",
1030
+ id: "noncurrentNewerVersions",
1031
+ direction: "horizontal",
1032
+ content: /*#__PURE__*/ jsx(Box, {
1033
+ flex: "1",
1034
+ children: /*#__PURE__*/ jsx(Input, {
1035
+ type: "number",
1036
+ id: "noncurrentNewerVersions",
1037
+ placeholder: "0",
1038
+ ...register("noncurrentNewerVersions", {
1039
+ valueAsNumber: true
1040
+ })
1041
+ })
1042
+ })
1043
+ })
1044
+ ]
1045
+ }) : /*#__PURE__*/ jsx(Fragment, {}),
1046
+ /*#__PURE__*/ jsx(FormGroup, {
1047
+ label: "Expire incomplete multipart upload",
1048
+ id: "abortMpuEnabled",
1049
+ direction: "horizontal",
1050
+ error: ("tags" === filterType || "and" === filterType) && abortMpuEnabled ? "Tag-based filter cannot be used with Abort Incomplete Multipart Upload" : void 0,
1051
+ helpErrorPosition: "bottom",
1052
+ content: /*#__PURE__*/ jsx(Controller, {
1053
+ name: "abortMpuEnabled",
1054
+ control: control,
1055
+ render: ({ field })=>/*#__PURE__*/ jsx(Toggle, {
1056
+ toggle: field.value,
1057
+ onChange: field.onChange,
1058
+ label: field.value ? "Enabled" : "Disabled"
1059
+ })
1060
+ })
1061
+ }),
1062
+ abortMpuEnabled ? /*#__PURE__*/ jsx(FormGroup, {
1063
+ label: "Days after initiation",
1064
+ id: "abortMpuDays",
1065
+ direction: "horizontal",
1066
+ error: errors?.abortMpuDays?.message,
1067
+ helpErrorPosition: "bottom",
1068
+ content: /*#__PURE__*/ jsx(Box, {
1069
+ flex: "1",
1070
+ children: /*#__PURE__*/ jsx(Input, {
1071
+ type: "number",
1072
+ id: "abortMpuDays",
1073
+ ...register("abortMpuDays", {
1074
+ valueAsNumber: true
1075
+ })
1076
+ })
1077
+ })
1078
+ }) : /*#__PURE__*/ jsx(Fragment, {})
1079
+ ]
1080
+ })
1081
+ ]
1082
+ })
1083
+ });
1084
+ }
1085
+ export { BucketLifecycleFormPage };