@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,300 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from "react";
3
+ import { Icon, Loader, Text, spacing } from "@scality/core-ui";
4
+ import { Box, Button, Input } from "@scality/core-ui/dist/next";
5
+ import { Controller, useFieldArray, useForm } from "react-hook-form";
6
+ import { useDeleteObjectTagging, useObjectTagging, useSetObjectTagging } from "../../../hooks/index.js";
7
+ const MAX_TAGS_PER_OBJECT = 10;
8
+ const MAX_TAG_KEY_LENGTH = 128;
9
+ const MAX_TAG_VALUE_LENGTH = 256;
10
+ const ObjectTags = ({ bucketName, objectKey, versionId })=>{
11
+ const getVersionParams = ()=>versionId ? {
12
+ VersionId: versionId
13
+ } : {};
14
+ const { data: tagsData, status: tagsStatus } = useObjectTagging({
15
+ Bucket: bucketName,
16
+ Key: objectKey,
17
+ ...getVersionParams()
18
+ });
19
+ const setTaggingMutation = useSetObjectTagging();
20
+ const deleteTaggingMutation = useDeleteObjectTagging();
21
+ const [isInitialized, setIsInitialized] = useState(false);
22
+ const [lastUsedMutation, setLastUsedMutation] = useState(null);
23
+ const { control, handleSubmit, setValue, formState: { errors, isValid, isSubmitting } } = useForm({
24
+ mode: "onChange",
25
+ defaultValues: {
26
+ tags: []
27
+ }
28
+ });
29
+ const { fields, append, remove } = useFieldArray({
30
+ control,
31
+ name: "tags"
32
+ });
33
+ useEffect(()=>{
34
+ setIsInitialized(false);
35
+ setLastUsedMutation(null);
36
+ setTaggingMutation.reset();
37
+ deleteTaggingMutation.reset();
38
+ }, [
39
+ bucketName,
40
+ objectKey,
41
+ versionId
42
+ ]);
43
+ useEffect(()=>{
44
+ if (tagsData && "success" === tagsStatus && !isInitialized) {
45
+ const tags = tagsData.TagSet || [];
46
+ const rows = tags.map((tag)=>({
47
+ key: tag.Key || "",
48
+ value: tag.Value || ""
49
+ }));
50
+ setValue("tags", rows);
51
+ setIsInitialized(true);
52
+ }
53
+ }, [
54
+ tagsData,
55
+ tagsStatus,
56
+ setValue,
57
+ isInitialized
58
+ ]);
59
+ const onSubmit = async (data)=>{
60
+ try {
61
+ if (0 === data.tags.length) {
62
+ setLastUsedMutation("delete");
63
+ await deleteTaggingMutation.mutateAsync({
64
+ Bucket: bucketName,
65
+ Key: objectKey,
66
+ ...getVersionParams()
67
+ });
68
+ } else {
69
+ setLastUsedMutation("set");
70
+ await setTaggingMutation.mutateAsync({
71
+ Bucket: bucketName,
72
+ Key: objectKey,
73
+ ...getVersionParams(),
74
+ Tagging: {
75
+ TagSet: data.tags.map((row)=>({
76
+ Key: row.key.trim(),
77
+ Value: row.value.trim()
78
+ }))
79
+ }
80
+ });
81
+ }
82
+ } catch (error) {
83
+ console.error("Failed to save tags:", error);
84
+ }
85
+ };
86
+ if ("pending" === tagsStatus) return /*#__PURE__*/ jsx(Box, {
87
+ display: "flex",
88
+ justifyContent: "center",
89
+ padding: spacing.r32,
90
+ children: /*#__PURE__*/ jsx(Loader, {})
91
+ });
92
+ if ("error" === tagsStatus) return /*#__PURE__*/ jsx(Box, {
93
+ padding: spacing.r16,
94
+ children: /*#__PURE__*/ jsx(Text, {
95
+ color: "statusCritical",
96
+ children: "Error loading tags"
97
+ })
98
+ });
99
+ return /*#__PURE__*/ jsx(Box, {
100
+ children: /*#__PURE__*/ jsxs("form", {
101
+ onSubmit: handleSubmit(onSubmit),
102
+ children: [
103
+ /*#__PURE__*/ jsxs(Box, {
104
+ display: "flex",
105
+ justifyContent: "space-between",
106
+ alignItems: "center",
107
+ padding: spacing.r16,
108
+ borderBottom: "1px solid",
109
+ borderColor: "backgroundLevel3",
110
+ children: [
111
+ /*#__PURE__*/ jsx(Text, {
112
+ isEmphazed: true,
113
+ children: "Edit Tags"
114
+ }),
115
+ /*#__PURE__*/ jsxs(Box, {
116
+ display: "flex",
117
+ alignItems: "center",
118
+ gap: spacing.r8,
119
+ children: [
120
+ "set" === lastUsedMutation && setTaggingMutation.isSuccess && /*#__PURE__*/ jsx(Text, {
121
+ color: "statusHealthy",
122
+ children: "Saved successfully"
123
+ }),
124
+ "delete" === lastUsedMutation && deleteTaggingMutation.isSuccess && /*#__PURE__*/ jsx(Text, {
125
+ color: "statusHealthy",
126
+ children: "Saved successfully"
127
+ }),
128
+ "set" === lastUsedMutation && setTaggingMutation.isError && /*#__PURE__*/ jsx(Text, {
129
+ color: "statusCritical",
130
+ children: setTaggingMutation.error?.message || "Failed to save"
131
+ }),
132
+ "delete" === lastUsedMutation && deleteTaggingMutation.isError && /*#__PURE__*/ jsx(Text, {
133
+ color: "statusCritical",
134
+ children: deleteTaggingMutation.error?.message || "Failed to save"
135
+ }),
136
+ /*#__PURE__*/ jsx(Button, {
137
+ variant: "primary",
138
+ label: "Save",
139
+ disabled: !isValid || isSubmitting,
140
+ type: "submit",
141
+ icon: /*#__PURE__*/ jsx(Icon, {
142
+ name: "Save"
143
+ })
144
+ })
145
+ ]
146
+ })
147
+ ]
148
+ }),
149
+ /*#__PURE__*/ jsxs(Box, {
150
+ padding: spacing.r16,
151
+ display: "flex",
152
+ flexDirection: "column",
153
+ gap: spacing.r12,
154
+ children: [
155
+ fields.length > 0 && /*#__PURE__*/ jsxs(Box, {
156
+ display: "flex",
157
+ children: [
158
+ /*#__PURE__*/ jsx(Box, {
159
+ flex: "1",
160
+ children: /*#__PURE__*/ jsx(Text, {
161
+ color: "textSecondary",
162
+ isEmphazed: true,
163
+ children: "Key"
164
+ })
165
+ }),
166
+ /*#__PURE__*/ jsx(Box, {
167
+ flex: "1",
168
+ children: /*#__PURE__*/ jsx(Text, {
169
+ color: "textSecondary",
170
+ isEmphazed: true,
171
+ children: "Value"
172
+ })
173
+ })
174
+ ]
175
+ }),
176
+ 0 === fields.length && "success" === tagsStatus && /*#__PURE__*/ jsx(Box, {
177
+ padding: spacing.r16,
178
+ children: /*#__PURE__*/ jsx(Text, {
179
+ color: "textSecondary",
180
+ children: "No tags configured. Add tags to categorize this object."
181
+ })
182
+ }),
183
+ fields.map((field, index)=>/*#__PURE__*/ jsxs(Box, {
184
+ children: [
185
+ /*#__PURE__*/ jsxs(Box, {
186
+ display: "flex",
187
+ gap: spacing.r8,
188
+ alignItems: "center",
189
+ children: [
190
+ /*#__PURE__*/ jsx(Controller, {
191
+ control: control,
192
+ name: `tags.${index}.key`,
193
+ rules: {
194
+ required: "Key is required",
195
+ maxLength: {
196
+ value: MAX_TAG_KEY_LENGTH,
197
+ message: `Key must be ${MAX_TAG_KEY_LENGTH} characters or less`
198
+ },
199
+ validate: (value, formValues)=>{
200
+ if (!value.trim()) return "Key cannot be empty or whitespace only";
201
+ const keys = formValues.tags.map((t)=>t.key.trim());
202
+ const duplicates = keys.filter((k)=>k === value.trim());
203
+ return duplicates.length > 1 ? `Duplicate key "${value.trim()}"` : true;
204
+ }
205
+ },
206
+ render: ({ field: { onChange, value } })=>/*#__PURE__*/ jsx(Input, {
207
+ id: `key-${field.id}`,
208
+ value: value,
209
+ onChange: onChange,
210
+ placeholder: "Key",
211
+ "aria-label": `Tag ${index + 1} key`
212
+ })
213
+ }),
214
+ /*#__PURE__*/ jsx(Text, {
215
+ color: "textSecondary",
216
+ children: ":"
217
+ }),
218
+ /*#__PURE__*/ jsx(Controller, {
219
+ control: control,
220
+ name: `tags.${index}.value`,
221
+ rules: {
222
+ required: "Value is required",
223
+ maxLength: {
224
+ value: MAX_TAG_VALUE_LENGTH,
225
+ message: `Value must be ${MAX_TAG_VALUE_LENGTH} characters or less`
226
+ },
227
+ validate: (value)=>{
228
+ if (!value.trim()) return "Value cannot be empty or whitespace only";
229
+ return true;
230
+ }
231
+ },
232
+ render: ({ field: { onChange, value } })=>/*#__PURE__*/ jsx(Input, {
233
+ id: `value-${field.id}`,
234
+ value: value,
235
+ onChange: onChange,
236
+ placeholder: "Value",
237
+ "aria-label": `Tag ${index + 1} value`
238
+ })
239
+ }),
240
+ /*#__PURE__*/ jsx(Button, {
241
+ variant: "secondary",
242
+ icon: /*#__PURE__*/ jsx(Icon, {
243
+ name: "Delete"
244
+ }),
245
+ onClick: ()=>remove(index),
246
+ "aria-label": "Delete row",
247
+ type: "button"
248
+ })
249
+ ]
250
+ }),
251
+ (errors.tags?.[index]?.key || errors.tags?.[index]?.value) && /*#__PURE__*/ jsxs(Box, {
252
+ paddingTop: spacing.r4,
253
+ children: [
254
+ errors.tags?.[index]?.key && /*#__PURE__*/ jsx(Text, {
255
+ color: "statusCritical",
256
+ children: errors.tags[index]?.key?.message
257
+ }),
258
+ errors.tags?.[index]?.value && /*#__PURE__*/ jsx(Text, {
259
+ color: "statusCritical",
260
+ children: errors.tags[index]?.value?.message
261
+ })
262
+ ]
263
+ })
264
+ ]
265
+ }, field.id)),
266
+ /*#__PURE__*/ jsxs(Box, {
267
+ children: [
268
+ /*#__PURE__*/ jsx(Button, {
269
+ variant: "secondary",
270
+ icon: /*#__PURE__*/ jsx(Icon, {
271
+ name: "Create-add"
272
+ }),
273
+ label: "Add Tag",
274
+ onClick: ()=>append({
275
+ key: "",
276
+ value: ""
277
+ }),
278
+ type: "button",
279
+ disabled: fields.length >= MAX_TAGS_PER_OBJECT
280
+ }),
281
+ fields.length >= MAX_TAGS_PER_OBJECT && /*#__PURE__*/ jsx(Box, {
282
+ paddingTop: spacing.r8,
283
+ children: /*#__PURE__*/ jsxs(Text, {
284
+ color: "statusWarning",
285
+ children: [
286
+ "Maximum ",
287
+ MAX_TAGS_PER_OBJECT,
288
+ " tags allowed per object"
289
+ ]
290
+ })
291
+ })
292
+ ]
293
+ })
294
+ ]
295
+ })
296
+ ]
297
+ })
298
+ });
299
+ };
300
+ export { ObjectTags };
@@ -0,0 +1,9 @@
1
+ import { TableItem } from "../ObjectList";
2
+ export interface ObjectCommonProps {
3
+ bucketName: string;
4
+ objectKey: string;
5
+ versionId?: string;
6
+ }
7
+ export declare const ObjectDetails: ({ item }: {
8
+ item: TableItem;
9
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,49 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useParams } from "react-router-dom";
3
+ import { Text } from "@scality/core-ui";
4
+ import { Tabs } from "@scality/core-ui/dist/next";
5
+ import { ObjectSummary } from "./ObjectSummary.js";
6
+ import { ObjectMetadata } from "./ObjectMetadata.js";
7
+ import { ObjectTags } from "./ObjectTags.js";
8
+ const ObjectDetails = ({ item })=>{
9
+ const { bucketName } = useParams();
10
+ if (!bucketName || !item.Key) return /*#__PURE__*/ jsx(Text, {
11
+ children: "No object selected"
12
+ });
13
+ if ("deleteMarker" === item.type) return /*#__PURE__*/ jsx(Text, {
14
+ children: 'A "Delete Marker" is selected'
15
+ });
16
+ const versionId = "version" === item.type ? item.VersionId : void 0;
17
+ const mainTabs = [
18
+ {
19
+ label: "Summary",
20
+ Component: ObjectSummary,
21
+ query: ""
22
+ },
23
+ {
24
+ label: "Metadata",
25
+ Component: ObjectMetadata,
26
+ query: "metadata"
27
+ },
28
+ {
29
+ label: "Tags",
30
+ Component: ObjectTags,
31
+ query: "tags"
32
+ }
33
+ ];
34
+ return /*#__PURE__*/ jsx(Tabs, {
35
+ children: mainTabs.map((tab)=>/*#__PURE__*/ jsx(Tabs.Tab, {
36
+ label: tab.label,
37
+ path: "",
38
+ query: {
39
+ tab: tab.query
40
+ },
41
+ children: /*#__PURE__*/ jsx(tab.Component, {
42
+ bucketName: bucketName,
43
+ objectKey: item.Key,
44
+ versionId: versionId
45
+ })
46
+ }, tab.query || "summary"))
47
+ });
48
+ };
49
+ export { ObjectDetails };
@@ -0,0 +1,40 @@
1
+ import type { _Object, DeleteMarkerEntry, ObjectVersion } from "@aws-sdk/client-s3";
2
+ type FolderItem = {
3
+ Key: string;
4
+ displayName: string;
5
+ type: "folder";
6
+ LastModified?: undefined;
7
+ Size?: undefined;
8
+ StorageClass?: undefined;
9
+ VersionId?: undefined;
10
+ IsLatest?: undefined;
11
+ };
12
+ type ObjectItem = _Object & {
13
+ displayName: string;
14
+ type: "object";
15
+ IsLatest?: boolean;
16
+ VersionId?: string;
17
+ };
18
+ type VersionItem = ObjectVersion & {
19
+ displayName: string;
20
+ type: "version";
21
+ IsLatest?: boolean;
22
+ };
23
+ type DeleteMarkerItem = DeleteMarkerEntry & {
24
+ displayName: string;
25
+ type: "deleteMarker";
26
+ isDeleteMarker: true;
27
+ IsLatest?: boolean;
28
+ Size?: number;
29
+ };
30
+ export type TableItem = (FolderItem | ObjectItem | VersionItem | DeleteMarkerItem) & {
31
+ [key: string]: unknown;
32
+ };
33
+ interface ObjectListProps {
34
+ bucketName: string;
35
+ prefix: string;
36
+ onObjectSelect: (object: TableItem) => void;
37
+ onPrefixChange: (newPrefix: string) => void;
38
+ }
39
+ export declare const ObjectList: ({ bucketName, prefix, onObjectSelect, onPrefixChange, }: ObjectListProps) => import("react/jsx-runtime").JSX.Element;
40
+ export {};