@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.
- package/dist/components/Editor.d.ts +12 -0
- package/dist/components/Editor.js +28 -0
- package/dist/components/__tests__/BucketList.test.d.ts +1 -0
- package/dist/components/__tests__/BucketList.test.js +225 -0
- package/dist/components/__tests__/BucketOverview.test.d.ts +1 -0
- package/dist/components/__tests__/BucketOverview.test.js +479 -0
- package/dist/components/__tests__/BucketPolicyPage.test.d.ts +1 -0
- package/dist/components/__tests__/BucketPolicyPage.test.js +213 -0
- package/dist/components/__tests__/CreateFolderButton.test.d.ts +1 -0
- package/dist/components/__tests__/CreateFolderButton.test.js +147 -0
- package/dist/components/__tests__/DeleteBucketButton.test.d.ts +1 -0
- package/dist/components/__tests__/DeleteBucketButton.test.js +272 -0
- package/dist/components/__tests__/DeleteObjectButton.test.d.ts +1 -0
- package/dist/components/__tests__/DeleteObjectButton.test.js +302 -0
- package/dist/components/__tests__/MetadataSearch.test.d.ts +1 -0
- package/dist/components/__tests__/MetadataSearch.test.js +201 -0
- package/dist/components/__tests__/ObjectList.test.d.ts +1 -0
- package/dist/components/__tests__/ObjectList.test.js +283 -0
- package/dist/components/__tests__/UploadButton.test.d.ts +1 -0
- package/dist/components/__tests__/UploadButton.test.js +144 -0
- package/dist/components/buckets/BucketDetails.d.ts +1 -0
- package/dist/components/buckets/BucketDetails.js +51 -0
- package/dist/components/buckets/BucketList.d.ts +12 -0
- package/dist/components/buckets/BucketList.js +136 -0
- package/dist/components/buckets/BucketLocation.d.ts +3 -0
- package/dist/components/buckets/BucketLocation.js +16 -0
- package/dist/components/buckets/BucketOverview.d.ts +14 -0
- package/dist/components/buckets/BucketOverview.js +209 -0
- package/dist/components/buckets/BucketPage.d.ts +2 -0
- package/dist/components/buckets/BucketPage.js +47 -0
- package/dist/components/buckets/BucketPolicyButton.d.ts +7 -0
- package/dist/components/buckets/BucketPolicyButton.js +18 -0
- package/dist/components/buckets/BucketPolicyPage.d.ts +1 -0
- package/dist/components/buckets/BucketPolicyPage.js +205 -0
- package/dist/components/buckets/DeleteBucketButton.d.ts +8 -0
- package/dist/components/buckets/DeleteBucketButton.js +78 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/components/index.js +13 -0
- package/dist/components/layouts/BrowserPageLayout.d.ts +9 -0
- package/dist/components/layouts/BrowserPageLayout.js +46 -0
- package/dist/components/objects/CreateFolderButton.d.ts +29 -0
- package/dist/components/objects/CreateFolderButton.js +118 -0
- package/dist/components/objects/DeleteObjectButton.d.ts +8 -0
- package/dist/components/objects/DeleteObjectButton.js +191 -0
- package/dist/components/objects/ObjectDetails/ObjectMetadata.d.ts +2 -0
- package/dist/components/objects/ObjectDetails/ObjectMetadata.js +323 -0
- package/dist/components/objects/ObjectDetails/ObjectSummary.d.ts +3 -0
- package/dist/components/objects/ObjectDetails/ObjectSummary.js +193 -0
- package/dist/components/objects/ObjectDetails/ObjectTags.d.ts +3 -0
- package/dist/components/objects/ObjectDetails/ObjectTags.js +300 -0
- package/dist/components/objects/ObjectDetails/index.d.ts +9 -0
- package/dist/components/objects/ObjectDetails/index.js +49 -0
- package/dist/components/objects/ObjectList.d.ts +40 -0
- package/dist/components/objects/ObjectList.js +407 -0
- package/dist/components/objects/ObjectPage.d.ts +1 -0
- package/dist/components/objects/ObjectPage.js +43 -0
- package/dist/components/objects/UploadButton.d.ts +34 -0
- package/dist/components/objects/UploadButton.js +229 -0
- package/dist/components/providers/DataBrowserProvider.d.ts +20 -0
- package/dist/components/providers/DataBrowserProvider.js +42 -0
- package/dist/components/search/MetadataSearch.d.ts +5 -0
- package/dist/components/search/MetadataSearch.js +162 -0
- package/dist/components/search/SearchHints.d.ts +8 -0
- package/dist/components/search/SearchHints.js +21 -0
- package/dist/components/ui/DeleteObjectModalContent.d.ts +5 -0
- package/dist/components/ui/DeleteObjectModalContent.js +71 -0
- package/dist/components/ui/Search.elements.d.ts +17 -0
- package/dist/components/ui/Search.elements.js +59 -0
- package/dist/components/ui/Table.elements.d.ts +36 -0
- package/dist/components/ui/Table.elements.js +87 -0
- package/dist/config/factory.d.ts +52 -0
- package/dist/config/factory.js +70 -0
- package/dist/config/types.d.ts +46 -0
- package/dist/config/types.js +0 -0
- package/dist/hooks/__tests__/useIsBucketEmpty.test.d.ts +1 -0
- package/dist/hooks/__tests__/useIsBucketEmpty.test.js +122 -0
- package/dist/hooks/bucketConfiguration.d.ts +147 -0
- package/dist/hooks/bucketConfiguration.js +59 -0
- package/dist/hooks/bucketOperations.d.ts +36 -0
- package/dist/hooks/bucketOperations.js +12 -0
- package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.d.ts +1 -0
- package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.js +276 -0
- package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.d.ts +1 -0
- package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.js +259 -0
- package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.d.ts +1 -0
- package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.js +166 -0
- package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.d.ts +1 -0
- package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.js +200 -0
- package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.d.ts +1 -0
- package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.js +136 -0
- package/dist/hooks/factories/index.d.ts +18 -0
- package/dist/hooks/factories/index.js +5 -0
- package/dist/hooks/factories/useCreateS3InfiniteQueryHook.d.ts +13 -0
- package/dist/hooks/factories/useCreateS3InfiniteQueryHook.js +76 -0
- package/dist/hooks/factories/useCreateS3LoginHook.d.ts +8 -0
- package/dist/hooks/factories/useCreateS3LoginHook.js +22 -0
- package/dist/hooks/factories/useCreateS3MutationHook.d.ts +5 -0
- package/dist/hooks/factories/useCreateS3MutationHook.js +50 -0
- package/dist/hooks/factories/useCreateS3QueryHook.d.ts +3 -0
- package/dist/hooks/factories/useCreateS3QueryHook.js +30 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/index.js +8 -0
- package/dist/hooks/loginOperations.d.ts +21 -0
- package/dist/hooks/loginOperations.js +9 -0
- package/dist/hooks/objectOperations.d.ts +190 -0
- package/dist/hooks/objectOperations.js +66 -0
- package/dist/hooks/presignedOperations.d.ts +73 -0
- package/dist/hooks/presignedOperations.js +72 -0
- package/dist/hooks/useIsBucketEmpty.d.ts +7 -0
- package/dist/hooks/useIsBucketEmpty.js +36 -0
- package/dist/hooks/useLoginMutation.d.ts +21 -0
- package/dist/hooks/useLoginMutation.js +9 -0
- package/dist/hooks/useS3Client.d.ts +1 -0
- package/dist/hooks/useS3Client.js +13 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/schemas/bucketPolicySchema.json +321 -0
- package/dist/test/msw/handlers/deleteBucket.d.ts +1 -0
- package/dist/test/msw/handlers/deleteBucket.js +14 -0
- package/dist/test/msw/handlers/getBucketAcl.d.ts +1 -0
- package/dist/test/msw/handlers/getBucketAcl.js +96 -0
- package/dist/test/msw/handlers/getBucketLocation.d.ts +1 -0
- package/dist/test/msw/handlers/getBucketLocation.js +23 -0
- package/dist/test/msw/handlers/getBucketPolicy.d.ts +11 -0
- package/dist/test/msw/handlers/getBucketPolicy.js +72 -0
- package/dist/test/msw/handlers/headObject.d.ts +1 -0
- package/dist/test/msw/handlers/headObject.js +17 -0
- package/dist/test/msw/handlers/listBuckets.d.ts +1 -0
- package/dist/test/msw/handlers/listBuckets.js +24 -0
- package/dist/test/msw/handlers/listObjectVersions.d.ts +1 -0
- package/dist/test/msw/handlers/listObjectVersions.js +83 -0
- package/dist/test/msw/handlers/listObjects.d.ts +1 -0
- package/dist/test/msw/handlers/listObjects.js +66 -0
- package/dist/test/msw/handlers/objectLegalHold.d.ts +1 -0
- package/dist/test/msw/handlers/objectLegalHold.js +24 -0
- package/dist/test/msw/handlers/objectRetention.d.ts +1 -0
- package/dist/test/msw/handlers/objectRetention.js +27 -0
- package/dist/test/msw/handlers/putBucketAcl.d.ts +1 -0
- package/dist/test/msw/handlers/putBucketAcl.js +18 -0
- package/dist/test/msw/handlers/putObject.d.ts +1 -0
- package/dist/test/msw/handlers/putObject.js +16 -0
- package/dist/test/msw/handlers.d.ts +4 -0
- package/dist/test/msw/handlers.js +109 -0
- package/dist/test/msw/index.d.ts +2 -0
- package/dist/test/msw/index.js +3 -0
- package/dist/test/msw/server.d.ts +4 -0
- package/dist/test/msw/server.js +20 -0
- package/dist/test/msw/utils.d.ts +2 -0
- package/dist/test/msw/utils.js +13 -0
- package/dist/test/setup.d.ts +1 -0
- package/dist/test/setup.js +82 -0
- package/dist/test/testUtils.d.ts +82 -0
- package/dist/test/testUtils.js +236 -0
- package/dist/test/utils/errorHandling.test.d.ts +1 -0
- package/dist/test/utils/errorHandling.test.js +385 -0
- package/dist/types/index.d.ts +48 -0
- package/dist/types/index.js +0 -0
- package/dist/utils/deletion/index.d.ts +2 -0
- package/dist/utils/deletion/index.js +2 -0
- package/dist/utils/deletion/messages.d.ts +5 -0
- package/dist/utils/deletion/messages.js +29 -0
- package/dist/utils/deletion/types.d.ts +11 -0
- package/dist/utils/deletion/types.js +0 -0
- package/dist/utils/errorHandling.d.ts +54 -0
- package/dist/utils/errorHandling.js +79 -0
- package/dist/utils/hooks.d.ts +2 -0
- package/dist/utils/hooks.js +26 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/proxyMiddleware.d.ts +18 -0
- package/dist/utils/proxyMiddleware.js +56 -0
- package/dist/utils/s3Client.d.ts +5 -0
- package/dist/utils/s3Client.js +35 -0
- package/dist/utils/useFeatures.d.ts +1 -0
- package/dist/utils/useFeatures.js +7 -0
- 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,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 };
|