@scality/data-browser-library 1.0.0-preview.2

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 (176) hide show
  1. package/dist/components/Editor.d.ts +12 -0
  2. package/dist/components/Editor.js +28 -0
  3. package/dist/components/__tests__/BucketList.test.d.ts +1 -0
  4. package/dist/components/__tests__/BucketList.test.js +225 -0
  5. package/dist/components/__tests__/BucketOverview.test.d.ts +1 -0
  6. package/dist/components/__tests__/BucketOverview.test.js +479 -0
  7. package/dist/components/__tests__/BucketPolicyPage.test.d.ts +1 -0
  8. package/dist/components/__tests__/BucketPolicyPage.test.js +213 -0
  9. package/dist/components/__tests__/CreateFolderButton.test.d.ts +1 -0
  10. package/dist/components/__tests__/CreateFolderButton.test.js +147 -0
  11. package/dist/components/__tests__/DeleteBucketButton.test.d.ts +1 -0
  12. package/dist/components/__tests__/DeleteBucketButton.test.js +272 -0
  13. package/dist/components/__tests__/DeleteObjectButton.test.d.ts +1 -0
  14. package/dist/components/__tests__/DeleteObjectButton.test.js +302 -0
  15. package/dist/components/__tests__/MetadataSearch.test.d.ts +1 -0
  16. package/dist/components/__tests__/MetadataSearch.test.js +201 -0
  17. package/dist/components/__tests__/ObjectList.test.d.ts +1 -0
  18. package/dist/components/__tests__/ObjectList.test.js +283 -0
  19. package/dist/components/__tests__/UploadButton.test.d.ts +1 -0
  20. package/dist/components/__tests__/UploadButton.test.js +144 -0
  21. package/dist/components/buckets/BucketDetails.d.ts +1 -0
  22. package/dist/components/buckets/BucketDetails.js +51 -0
  23. package/dist/components/buckets/BucketList.d.ts +12 -0
  24. package/dist/components/buckets/BucketList.js +136 -0
  25. package/dist/components/buckets/BucketLocation.d.ts +3 -0
  26. package/dist/components/buckets/BucketLocation.js +16 -0
  27. package/dist/components/buckets/BucketOverview.d.ts +14 -0
  28. package/dist/components/buckets/BucketOverview.js +209 -0
  29. package/dist/components/buckets/BucketPage.d.ts +2 -0
  30. package/dist/components/buckets/BucketPage.js +47 -0
  31. package/dist/components/buckets/BucketPolicyButton.d.ts +7 -0
  32. package/dist/components/buckets/BucketPolicyButton.js +18 -0
  33. package/dist/components/buckets/BucketPolicyPage.d.ts +1 -0
  34. package/dist/components/buckets/BucketPolicyPage.js +205 -0
  35. package/dist/components/buckets/DeleteBucketButton.d.ts +8 -0
  36. package/dist/components/buckets/DeleteBucketButton.js +78 -0
  37. package/dist/components/index.d.ts +12 -0
  38. package/dist/components/index.js +13 -0
  39. package/dist/components/layouts/BrowserPageLayout.d.ts +9 -0
  40. package/dist/components/layouts/BrowserPageLayout.js +46 -0
  41. package/dist/components/objects/CreateFolderButton.d.ts +29 -0
  42. package/dist/components/objects/CreateFolderButton.js +118 -0
  43. package/dist/components/objects/DeleteObjectButton.d.ts +8 -0
  44. package/dist/components/objects/DeleteObjectButton.js +191 -0
  45. package/dist/components/objects/ObjectDetails/ObjectMetadata.d.ts +2 -0
  46. package/dist/components/objects/ObjectDetails/ObjectMetadata.js +323 -0
  47. package/dist/components/objects/ObjectDetails/ObjectSummary.d.ts +3 -0
  48. package/dist/components/objects/ObjectDetails/ObjectSummary.js +193 -0
  49. package/dist/components/objects/ObjectDetails/ObjectTags.d.ts +3 -0
  50. package/dist/components/objects/ObjectDetails/ObjectTags.js +300 -0
  51. package/dist/components/objects/ObjectDetails/index.d.ts +9 -0
  52. package/dist/components/objects/ObjectDetails/index.js +49 -0
  53. package/dist/components/objects/ObjectList.d.ts +40 -0
  54. package/dist/components/objects/ObjectList.js +407 -0
  55. package/dist/components/objects/ObjectPage.d.ts +1 -0
  56. package/dist/components/objects/ObjectPage.js +43 -0
  57. package/dist/components/objects/UploadButton.d.ts +34 -0
  58. package/dist/components/objects/UploadButton.js +229 -0
  59. package/dist/components/providers/DataBrowserProvider.d.ts +20 -0
  60. package/dist/components/providers/DataBrowserProvider.js +42 -0
  61. package/dist/components/search/MetadataSearch.d.ts +5 -0
  62. package/dist/components/search/MetadataSearch.js +162 -0
  63. package/dist/components/search/SearchHints.d.ts +8 -0
  64. package/dist/components/search/SearchHints.js +21 -0
  65. package/dist/components/ui/DeleteObjectModalContent.d.ts +5 -0
  66. package/dist/components/ui/DeleteObjectModalContent.js +71 -0
  67. package/dist/components/ui/Search.elements.d.ts +17 -0
  68. package/dist/components/ui/Search.elements.js +59 -0
  69. package/dist/components/ui/Table.elements.d.ts +36 -0
  70. package/dist/components/ui/Table.elements.js +87 -0
  71. package/dist/config/factory.d.ts +52 -0
  72. package/dist/config/factory.js +70 -0
  73. package/dist/config/types.d.ts +46 -0
  74. package/dist/config/types.js +0 -0
  75. package/dist/hooks/__tests__/useIsBucketEmpty.test.d.ts +1 -0
  76. package/dist/hooks/__tests__/useIsBucketEmpty.test.js +122 -0
  77. package/dist/hooks/bucketConfiguration.d.ts +147 -0
  78. package/dist/hooks/bucketConfiguration.js +59 -0
  79. package/dist/hooks/bucketOperations.d.ts +36 -0
  80. package/dist/hooks/bucketOperations.js +12 -0
  81. package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.d.ts +1 -0
  82. package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.js +276 -0
  83. package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.d.ts +1 -0
  84. package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.js +259 -0
  85. package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.d.ts +1 -0
  86. package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.js +166 -0
  87. package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.d.ts +1 -0
  88. package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.js +200 -0
  89. package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.d.ts +1 -0
  90. package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.js +136 -0
  91. package/dist/hooks/factories/index.d.ts +18 -0
  92. package/dist/hooks/factories/index.js +5 -0
  93. package/dist/hooks/factories/useCreateS3InfiniteQueryHook.d.ts +13 -0
  94. package/dist/hooks/factories/useCreateS3InfiniteQueryHook.js +76 -0
  95. package/dist/hooks/factories/useCreateS3LoginHook.d.ts +8 -0
  96. package/dist/hooks/factories/useCreateS3LoginHook.js +22 -0
  97. package/dist/hooks/factories/useCreateS3MutationHook.d.ts +5 -0
  98. package/dist/hooks/factories/useCreateS3MutationHook.js +50 -0
  99. package/dist/hooks/factories/useCreateS3QueryHook.d.ts +3 -0
  100. package/dist/hooks/factories/useCreateS3QueryHook.js +30 -0
  101. package/dist/hooks/index.d.ts +8 -0
  102. package/dist/hooks/index.js +8 -0
  103. package/dist/hooks/loginOperations.d.ts +21 -0
  104. package/dist/hooks/loginOperations.js +9 -0
  105. package/dist/hooks/objectOperations.d.ts +190 -0
  106. package/dist/hooks/objectOperations.js +66 -0
  107. package/dist/hooks/presignedOperations.d.ts +73 -0
  108. package/dist/hooks/presignedOperations.js +72 -0
  109. package/dist/hooks/useIsBucketEmpty.d.ts +7 -0
  110. package/dist/hooks/useIsBucketEmpty.js +36 -0
  111. package/dist/hooks/useLoginMutation.d.ts +21 -0
  112. package/dist/hooks/useLoginMutation.js +9 -0
  113. package/dist/hooks/useS3Client.d.ts +1 -0
  114. package/dist/hooks/useS3Client.js +13 -0
  115. package/dist/index.d.ts +6 -0
  116. package/dist/index.js +6 -0
  117. package/dist/schemas/bucketPolicySchema.json +321 -0
  118. package/dist/test/msw/handlers/deleteBucket.d.ts +1 -0
  119. package/dist/test/msw/handlers/deleteBucket.js +14 -0
  120. package/dist/test/msw/handlers/getBucketAcl.d.ts +1 -0
  121. package/dist/test/msw/handlers/getBucketAcl.js +96 -0
  122. package/dist/test/msw/handlers/getBucketLocation.d.ts +1 -0
  123. package/dist/test/msw/handlers/getBucketLocation.js +23 -0
  124. package/dist/test/msw/handlers/getBucketPolicy.d.ts +11 -0
  125. package/dist/test/msw/handlers/getBucketPolicy.js +72 -0
  126. package/dist/test/msw/handlers/headObject.d.ts +1 -0
  127. package/dist/test/msw/handlers/headObject.js +17 -0
  128. package/dist/test/msw/handlers/listBuckets.d.ts +1 -0
  129. package/dist/test/msw/handlers/listBuckets.js +24 -0
  130. package/dist/test/msw/handlers/listObjectVersions.d.ts +1 -0
  131. package/dist/test/msw/handlers/listObjectVersions.js +83 -0
  132. package/dist/test/msw/handlers/listObjects.d.ts +1 -0
  133. package/dist/test/msw/handlers/listObjects.js +66 -0
  134. package/dist/test/msw/handlers/objectLegalHold.d.ts +1 -0
  135. package/dist/test/msw/handlers/objectLegalHold.js +24 -0
  136. package/dist/test/msw/handlers/objectRetention.d.ts +1 -0
  137. package/dist/test/msw/handlers/objectRetention.js +27 -0
  138. package/dist/test/msw/handlers/putBucketAcl.d.ts +1 -0
  139. package/dist/test/msw/handlers/putBucketAcl.js +18 -0
  140. package/dist/test/msw/handlers/putObject.d.ts +1 -0
  141. package/dist/test/msw/handlers/putObject.js +16 -0
  142. package/dist/test/msw/handlers.d.ts +4 -0
  143. package/dist/test/msw/handlers.js +109 -0
  144. package/dist/test/msw/index.d.ts +2 -0
  145. package/dist/test/msw/index.js +3 -0
  146. package/dist/test/msw/server.d.ts +4 -0
  147. package/dist/test/msw/server.js +20 -0
  148. package/dist/test/msw/utils.d.ts +2 -0
  149. package/dist/test/msw/utils.js +13 -0
  150. package/dist/test/setup.d.ts +1 -0
  151. package/dist/test/setup.js +82 -0
  152. package/dist/test/testUtils.d.ts +82 -0
  153. package/dist/test/testUtils.js +236 -0
  154. package/dist/test/utils/errorHandling.test.d.ts +1 -0
  155. package/dist/test/utils/errorHandling.test.js +385 -0
  156. package/dist/types/index.d.ts +48 -0
  157. package/dist/types/index.js +0 -0
  158. package/dist/utils/deletion/index.d.ts +2 -0
  159. package/dist/utils/deletion/index.js +2 -0
  160. package/dist/utils/deletion/messages.d.ts +5 -0
  161. package/dist/utils/deletion/messages.js +29 -0
  162. package/dist/utils/deletion/types.d.ts +11 -0
  163. package/dist/utils/deletion/types.js +0 -0
  164. package/dist/utils/errorHandling.d.ts +54 -0
  165. package/dist/utils/errorHandling.js +79 -0
  166. package/dist/utils/hooks.d.ts +2 -0
  167. package/dist/utils/hooks.js +26 -0
  168. package/dist/utils/index.d.ts +2 -0
  169. package/dist/utils/index.js +2 -0
  170. package/dist/utils/proxyMiddleware.d.ts +18 -0
  171. package/dist/utils/proxyMiddleware.js +56 -0
  172. package/dist/utils/s3Client.d.ts +5 -0
  173. package/dist/utils/s3Client.js +35 -0
  174. package/dist/utils/useFeatures.d.ts +1 -0
  175. package/dist/utils/useFeatures.js +7 -0
  176. package/package.json +79 -0
@@ -0,0 +1,323 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useMemo, useState } from "react";
3
+ import { Icon, Loader, Text, spacing } from "@scality/core-ui";
4
+ import { Box, Button, Input, Select } from "@scality/core-ui/dist/next";
5
+ import { useCopyObject, useObjectMetadata } from "../../../hooks/index.js";
6
+ import { TableContainer } from "../../ui/Table.elements.js";
7
+ const METADATA_KEYS = [
8
+ {
9
+ key: "CacheControl",
10
+ label: "cache-control"
11
+ },
12
+ {
13
+ key: "ContentDisposition",
14
+ label: "content-disposition"
15
+ },
16
+ {
17
+ key: "ContentEncoding",
18
+ label: "content-encoding"
19
+ },
20
+ {
21
+ key: "ContentType",
22
+ label: "content-type"
23
+ },
24
+ {
25
+ key: "WebsiteRedirectLocation",
26
+ label: "website-redirect-location"
27
+ },
28
+ {
29
+ key: "x-amz-meta",
30
+ label: "x-amz-meta"
31
+ }
32
+ ];
33
+ const ObjectMetadata = ({ bucketName, objectKey, versionId })=>{
34
+ const { data: metadata, status: metadataStatus } = useObjectMetadata({
35
+ Bucket: bucketName,
36
+ Key: objectKey,
37
+ ...versionId && {
38
+ VersionId: versionId
39
+ }
40
+ });
41
+ const copyObjectMutation = useCopyObject();
42
+ const [metadataRows, setMetadataRows] = useState([]);
43
+ useEffect(()=>{
44
+ setMetadataRows([]);
45
+ copyObjectMutation.reset();
46
+ }, [
47
+ bucketName,
48
+ objectKey,
49
+ versionId
50
+ ]);
51
+ useEffect(()=>{
52
+ if (metadata && "success" === metadataStatus) {
53
+ const rows = [];
54
+ const standardKeys = [
55
+ "CacheControl",
56
+ "ContentDisposition",
57
+ "ContentEncoding",
58
+ "ContentType",
59
+ "WebsiteRedirectLocation"
60
+ ];
61
+ standardKeys.forEach((keyType)=>{
62
+ const value = metadata[keyType];
63
+ if (value) rows.push({
64
+ id: `init-${rows.length}`,
65
+ keyType,
66
+ customKey: "",
67
+ value
68
+ });
69
+ });
70
+ const userMetadata = metadata.Metadata || {};
71
+ Object.entries(userMetadata).forEach(([key, value])=>{
72
+ rows.push({
73
+ id: `init-${rows.length}`,
74
+ keyType: "x-amz-meta",
75
+ customKey: key,
76
+ value: value
77
+ });
78
+ });
79
+ setMetadataRows(rows);
80
+ }
81
+ }, [
82
+ metadata,
83
+ metadataStatus
84
+ ]);
85
+ const handleAddRow = useCallback(()=>{
86
+ setMetadataRows((prev)=>[
87
+ ...prev,
88
+ {
89
+ id: `new-${Date.now()}`,
90
+ keyType: "",
91
+ customKey: "",
92
+ value: ""
93
+ }
94
+ ]);
95
+ }, []);
96
+ const handleDeleteRow = useCallback((id)=>{
97
+ setMetadataRows((prev)=>prev.filter((row)=>row.id !== id));
98
+ }, []);
99
+ const handleRowChange = useCallback((id, field, value)=>{
100
+ setMetadataRows((prev)=>prev.map((row)=>row.id === id ? {
101
+ ...row,
102
+ [field]: value,
103
+ ..."keyType" === field && "x-amz-meta" !== value && {
104
+ customKey: ""
105
+ }
106
+ } : row));
107
+ }, []);
108
+ const validationErrors = useMemo(()=>{
109
+ const errors = [];
110
+ const seenKeys = new Set();
111
+ metadataRows.forEach((row, index)=>{
112
+ if (!row.keyType) return void errors.push(`Row ${index + 1}: Please select a metadata key`);
113
+ if ("x-amz-meta" === row.keyType && !row.customKey.trim()) return void errors.push(`Row ${index + 1}: Please provide a custom key name`);
114
+ if (!row.value.trim()) return void errors.push(`Row ${index + 1}: Please provide a value`);
115
+ const fullKey = "x-amz-meta" === row.keyType ? `x-amz-meta-${row.customKey}` : row.keyType;
116
+ if (seenKeys.has(fullKey)) errors.push(`Row ${index + 1}: Duplicate key "${"x-amz-meta" === row.keyType ? `x-amz-meta-${row.customKey}` : row.keyType}"`);
117
+ else seenKeys.add(fullKey);
118
+ });
119
+ return errors;
120
+ }, [
121
+ metadataRows
122
+ ]);
123
+ const canSave = metadataRows.length > 0 && 0 === validationErrors.length;
124
+ const getAvailableOptions = useCallback((currentRowId)=>{
125
+ const usedKeys = new Set(metadataRows.filter((row)=>row.id !== currentRowId && "x-amz-meta" !== row.keyType).map((row)=>row.keyType));
126
+ return METADATA_KEYS.filter((key)=>"x-amz-meta" === key.key || !usedKeys.has(key.key));
127
+ }, [
128
+ metadataRows
129
+ ]);
130
+ const handleSave = useCallback(async ()=>{
131
+ if (!canSave || !metadata) return;
132
+ try {
133
+ const encodedKey = encodeURIComponent(objectKey);
134
+ const copySource = versionId ? `${bucketName}/${encodedKey}?versionId=${versionId}` : `${bucketName}/${encodedKey}`;
135
+ const copyParams = {
136
+ Bucket: bucketName,
137
+ Key: objectKey,
138
+ CopySource: copySource,
139
+ MetadataDirective: "REPLACE",
140
+ Metadata: {}
141
+ };
142
+ metadataRows.forEach((row)=>{
143
+ if ("x-amz-meta" === row.keyType) copyParams.Metadata[row.customKey] = row.value;
144
+ else if (row.keyType) copyParams[row.keyType] = row.value;
145
+ });
146
+ if (!copyParams.ContentType && metadata.ContentType) copyParams.ContentType = metadata.ContentType;
147
+ await copyObjectMutation.mutateAsync(copyParams);
148
+ } catch (error) {
149
+ console.error("Failed to save metadata:", error);
150
+ }
151
+ }, [
152
+ canSave,
153
+ metadata,
154
+ bucketName,
155
+ objectKey,
156
+ metadataRows,
157
+ copyObjectMutation
158
+ ]);
159
+ if ("pending" === metadataStatus) return /*#__PURE__*/ jsx(TableContainer, {
160
+ children: /*#__PURE__*/ jsx(Box, {
161
+ display: "flex",
162
+ justifyContent: "center",
163
+ padding: spacing.r32,
164
+ children: /*#__PURE__*/ jsx(Loader, {})
165
+ })
166
+ });
167
+ if ("error" === metadataStatus) return /*#__PURE__*/ jsx(TableContainer, {
168
+ children: /*#__PURE__*/ jsx(Box, {
169
+ padding: spacing.r16,
170
+ children: /*#__PURE__*/ jsx(Text, {
171
+ color: "statusCritical",
172
+ children: "Error loading metadata"
173
+ })
174
+ })
175
+ });
176
+ return /*#__PURE__*/ jsxs(TableContainer, {
177
+ children: [
178
+ /*#__PURE__*/ jsxs(Box, {
179
+ display: "flex",
180
+ justifyContent: "space-between",
181
+ alignItems: "center",
182
+ padding: spacing.r16,
183
+ borderBottom: "1px solid",
184
+ borderColor: "backgroundLevel3",
185
+ children: [
186
+ /*#__PURE__*/ jsx(Text, {
187
+ isEmphazed: true,
188
+ children: "Edit Metadata"
189
+ }),
190
+ /*#__PURE__*/ jsxs(Box, {
191
+ display: "flex",
192
+ alignItems: "center",
193
+ gap: spacing.r8,
194
+ children: [
195
+ copyObjectMutation.isSuccess && /*#__PURE__*/ jsx(Text, {
196
+ color: "statusHealthy",
197
+ children: "Saved successfully"
198
+ }),
199
+ copyObjectMutation.isError && /*#__PURE__*/ jsx(Text, {
200
+ color: "statusCritical",
201
+ children: "Failed to save"
202
+ }),
203
+ /*#__PURE__*/ jsx(Button, {
204
+ variant: "primary",
205
+ label: "Save",
206
+ disabled: !canSave || copyObjectMutation.isPending,
207
+ onClick: handleSave,
208
+ icon: /*#__PURE__*/ jsx(Icon, {
209
+ name: "Save"
210
+ })
211
+ })
212
+ ]
213
+ })
214
+ ]
215
+ }),
216
+ validationErrors.length > 0 && /*#__PURE__*/ jsxs(Box, {
217
+ padding: spacing.r16,
218
+ backgroundColor: "backgroundLevel2",
219
+ borderLeft: "3px solid",
220
+ borderColor: "statusCritical",
221
+ children: [
222
+ /*#__PURE__*/ jsx(Text, {
223
+ color: "statusCritical",
224
+ isEmphazed: true,
225
+ children: "Validation Errors:"
226
+ }),
227
+ validationErrors.map((error, index)=>/*#__PURE__*/ jsx(Box, {
228
+ paddingLeft: spacing.r8,
229
+ children: /*#__PURE__*/ jsxs(Text, {
230
+ color: "statusCritical",
231
+ children: [
232
+ "• ",
233
+ error
234
+ ]
235
+ })
236
+ }, index))
237
+ ]
238
+ }),
239
+ /*#__PURE__*/ jsxs(Box, {
240
+ padding: spacing.r16,
241
+ display: "flex",
242
+ flexDirection: "column",
243
+ gap: spacing.r12,
244
+ flex: "1",
245
+ children: [
246
+ metadataRows.length > 0 && /*#__PURE__*/ jsxs(Box, {
247
+ display: "flex",
248
+ children: [
249
+ /*#__PURE__*/ jsx(Box, {
250
+ flex: "1",
251
+ children: /*#__PURE__*/ jsx(Text, {
252
+ color: "textSecondary",
253
+ isEmphazed: true,
254
+ children: "Key"
255
+ })
256
+ }),
257
+ /*#__PURE__*/ jsx(Box, {
258
+ flex: "1",
259
+ children: /*#__PURE__*/ jsx(Text, {
260
+ color: "textSecondary",
261
+ isEmphazed: true,
262
+ children: "Value"
263
+ })
264
+ })
265
+ ]
266
+ }),
267
+ metadataRows.map((row)=>/*#__PURE__*/ jsxs(Box, {
268
+ display: "flex",
269
+ gap: spacing.r8,
270
+ alignItems: "center",
271
+ children: [
272
+ /*#__PURE__*/ jsx(Select, {
273
+ id: `key-${row.id}`,
274
+ value: row.keyType,
275
+ onChange: (value)=>handleRowChange(row.id, "keyType", value),
276
+ placeholder: "Select key",
277
+ children: getAvailableOptions(row.id).map((key)=>/*#__PURE__*/ jsx(Select.Option, {
278
+ value: key.key,
279
+ children: key.label
280
+ }, key.key))
281
+ }),
282
+ "x-amz-meta" === row.keyType && /*#__PURE__*/ jsx(Input, {
283
+ id: `customKey-${row.id}`,
284
+ value: row.customKey,
285
+ onChange: (e)=>handleRowChange(row.id, "customKey", e.target.value),
286
+ placeholder: "custom-key"
287
+ }),
288
+ /*#__PURE__*/ jsx(Text, {
289
+ color: "textSecondary",
290
+ children: ":"
291
+ }),
292
+ /*#__PURE__*/ jsx(Input, {
293
+ id: `value-${row.id}`,
294
+ value: row.value,
295
+ onChange: (e)=>handleRowChange(row.id, "value", e.target.value),
296
+ placeholder: "Value"
297
+ }),
298
+ /*#__PURE__*/ jsx(Button, {
299
+ variant: "secondary",
300
+ icon: /*#__PURE__*/ jsx(Icon, {
301
+ name: "Delete"
302
+ }),
303
+ onClick: ()=>handleDeleteRow(row.id),
304
+ "aria-label": "Delete row"
305
+ })
306
+ ]
307
+ }, row.id)),
308
+ /*#__PURE__*/ jsx(Box, {
309
+ children: /*#__PURE__*/ jsx(Button, {
310
+ variant: "secondary",
311
+ icon: /*#__PURE__*/ jsx(Icon, {
312
+ name: "Create-add"
313
+ }),
314
+ label: "Add Metadata",
315
+ onClick: handleAddRow
316
+ })
317
+ })
318
+ ]
319
+ })
320
+ ]
321
+ });
322
+ };
323
+ export { ObjectMetadata };
@@ -0,0 +1,3 @@
1
+ import { ObjectCommonProps } from ".";
2
+ declare const ObjectSummary: ({ bucketName, objectKey, versionId, }: ObjectCommonProps) => import("react/jsx-runtime").JSX.Element;
3
+ export { ObjectSummary };
@@ -0,0 +1,193 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { ConstrainedText, FormattedDateTime, Loader, PrettyBytes, spacing } from "@scality/core-ui";
3
+ import { useObjectLegalHold, useObjectMetadata, useObjectRetention } from "../../../hooks/index.js";
4
+ import { Body, ExtraCell, Group, GroupContent, GroupName, GroupValues, Key, Row, Table, TableContainer, Value } from "../../ui/Table.elements.js";
5
+ import { CopyButton } from "@scality/core-ui/dist/components/buttonv2/CopyButton.component";
6
+ import { Box } from "@scality/core-ui/dist/next";
7
+ const ObjectSummary = ({ bucketName, objectKey, versionId })=>{
8
+ const { data: metadata, status: metadataStatus } = useObjectMetadata({
9
+ Bucket: bucketName,
10
+ Key: objectKey,
11
+ ...versionId && {
12
+ VersionId: versionId
13
+ }
14
+ });
15
+ const { data: legalHoldData, status: legalHoldStatus } = useObjectLegalHold({
16
+ Bucket: bucketName,
17
+ Key: objectKey,
18
+ ...versionId && {
19
+ VersionId: versionId
20
+ }
21
+ });
22
+ const { data: retentionData, status: retentionStatus } = useObjectRetention({
23
+ Bucket: bucketName,
24
+ Key: objectKey,
25
+ ...versionId && {
26
+ VersionId: versionId
27
+ }
28
+ });
29
+ return /*#__PURE__*/ jsx(TableContainer, {
30
+ children: /*#__PURE__*/ jsx(Table, {
31
+ children: /*#__PURE__*/ jsxs(Body, {
32
+ children: [
33
+ /*#__PURE__*/ jsxs(Group, {
34
+ children: [
35
+ /*#__PURE__*/ jsx(GroupName, {
36
+ children: "Information"
37
+ }),
38
+ /*#__PURE__*/ jsxs(GroupContent, {
39
+ children: [
40
+ /*#__PURE__*/ jsxs(Row, {
41
+ children: [
42
+ /*#__PURE__*/ jsx(Key, {
43
+ children: "Name"
44
+ }),
45
+ /*#__PURE__*/ jsx(Value, {
46
+ width: "15rem",
47
+ children: /*#__PURE__*/ jsx(ConstrainedText, {
48
+ text: objectKey,
49
+ lineClamp: 2
50
+ })
51
+ })
52
+ ]
53
+ }),
54
+ /*#__PURE__*/ jsxs(Row, {
55
+ children: [
56
+ /*#__PURE__*/ jsx(Key, {
57
+ children: "Version ID"
58
+ }),
59
+ /*#__PURE__*/ jsx(Value, {
60
+ children: "pending" === metadataStatus ? /*#__PURE__*/ jsx(Loader, {}) : "error" === metadataStatus ? "Error" : /*#__PURE__*/ jsxs(GroupValues, {
61
+ children: [
62
+ /*#__PURE__*/ jsx(Box, {
63
+ flex: "1",
64
+ minWidth: "0",
65
+ children: /*#__PURE__*/ jsx(ConstrainedText, {
66
+ text: metadata?.VersionId || versionId || "N/A",
67
+ lineClamp: 1
68
+ })
69
+ }),
70
+ /*#__PURE__*/ jsx(ExtraCell, {
71
+ marginLeft: spacing.f8,
72
+ children: /*#__PURE__*/ jsx(CopyButton, {
73
+ textToCopy: metadata?.VersionId || versionId || ""
74
+ })
75
+ })
76
+ ]
77
+ })
78
+ })
79
+ ]
80
+ }),
81
+ /*#__PURE__*/ jsxs(Row, {
82
+ children: [
83
+ /*#__PURE__*/ jsx(Key, {
84
+ children: "Size"
85
+ }),
86
+ /*#__PURE__*/ jsx(Value, {
87
+ children: "pending" === metadataStatus ? /*#__PURE__*/ jsx(Loader, {}) : "error" === metadataStatus ? "Error" : /*#__PURE__*/ jsx(PrettyBytes, {
88
+ bytes: metadata?.ContentLength || 0
89
+ })
90
+ })
91
+ ]
92
+ }),
93
+ /*#__PURE__*/ jsxs(Row, {
94
+ children: [
95
+ /*#__PURE__*/ jsx(Key, {
96
+ children: "Modified On"
97
+ }),
98
+ /*#__PURE__*/ jsx(Value, {
99
+ children: "pending" === metadataStatus ? /*#__PURE__*/ jsx(Loader, {}) : "error" === metadataStatus ? "Error" : metadata?.LastModified ? /*#__PURE__*/ jsx(FormattedDateTime, {
100
+ value: metadata.LastModified,
101
+ format: "date-time-second"
102
+ }) : "N/A"
103
+ })
104
+ ]
105
+ }),
106
+ /*#__PURE__*/ jsxs(Row, {
107
+ children: [
108
+ /*#__PURE__*/ jsx(Key, {
109
+ children: "ETag"
110
+ }),
111
+ /*#__PURE__*/ jsx(Value, {
112
+ children: "pending" === metadataStatus ? /*#__PURE__*/ jsx(Loader, {}) : "error" === metadataStatus ? "Error" : /*#__PURE__*/ jsxs(GroupValues, {
113
+ children: [
114
+ /*#__PURE__*/ jsx(Box, {
115
+ flex: "1",
116
+ minWidth: "0",
117
+ children: /*#__PURE__*/ jsx(ConstrainedText, {
118
+ text: metadata.ETag?.replace(/^"|"$/g, "") || "N/A",
119
+ lineClamp: 1
120
+ })
121
+ }),
122
+ /*#__PURE__*/ jsx(ExtraCell, {
123
+ marginLeft: spacing.f8,
124
+ children: /*#__PURE__*/ jsx(CopyButton, {
125
+ textToCopy: metadata.ETag?.replace(/^"|"$/g, "") || ""
126
+ })
127
+ })
128
+ ]
129
+ })
130
+ })
131
+ ]
132
+ }),
133
+ /*#__PURE__*/ jsxs(Row, {
134
+ children: [
135
+ /*#__PURE__*/ jsx(Key, {
136
+ children: "Location"
137
+ }),
138
+ /*#__PURE__*/ jsx(Value, {
139
+ children: "default"
140
+ })
141
+ ]
142
+ })
143
+ ]
144
+ })
145
+ ]
146
+ }),
147
+ /*#__PURE__*/ jsxs(Group, {
148
+ children: [
149
+ /*#__PURE__*/ jsx(GroupName, {
150
+ children: "Data protection"
151
+ }),
152
+ /*#__PURE__*/ jsxs(GroupContent, {
153
+ children: [
154
+ /*#__PURE__*/ jsxs(Row, {
155
+ children: [
156
+ /*#__PURE__*/ jsx(Key, {
157
+ children: "Lock"
158
+ }),
159
+ /*#__PURE__*/ jsx(Value, {
160
+ children: "pending" === retentionStatus ? /*#__PURE__*/ jsx(Loader, {}) : "error" === retentionStatus ? "No Retention" : retentionData?.Retention?.Mode ? /*#__PURE__*/ jsxs(Fragment, {
161
+ children: [
162
+ retentionData.Retention.Mode,
163
+ " until",
164
+ " ",
165
+ retentionData.Retention.RetainUntilDate ? /*#__PURE__*/ jsx(FormattedDateTime, {
166
+ format: "date-time-second",
167
+ value: new Date(retentionData.Retention.RetainUntilDate)
168
+ }) : "N/A"
169
+ ]
170
+ }) : "No Retention"
171
+ })
172
+ ]
173
+ }),
174
+ /*#__PURE__*/ jsxs(Row, {
175
+ children: [
176
+ /*#__PURE__*/ jsx(Key, {
177
+ children: "Legal Hold"
178
+ }),
179
+ /*#__PURE__*/ jsx(Value, {
180
+ children: "pending" === legalHoldStatus ? /*#__PURE__*/ jsx(Loader, {}) : "error" === legalHoldStatus ? "OFF" : legalHoldData?.LegalHold?.Status === "ON" ? "ON" : "OFF"
181
+ })
182
+ ]
183
+ })
184
+ ]
185
+ })
186
+ ]
187
+ })
188
+ ]
189
+ })
190
+ })
191
+ });
192
+ };
193
+ export { ObjectSummary };
@@ -0,0 +1,3 @@
1
+ import { ObjectCommonProps } from ".";
2
+ declare const ObjectTags: ({ bucketName, objectKey, versionId, }: ObjectCommonProps) => import("react/jsx-runtime").JSX.Element;
3
+ export { ObjectTags };