@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,209 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ConstrainedText, Icon, Loader, spacing } from "@scality/core-ui";
|
|
3
|
+
import { Box, Button } from "@scality/core-ui/dist/next";
|
|
4
|
+
import "react";
|
|
5
|
+
import { useGetBucketAcl, useGetBucketCors, useGetBucketObjectLockConfiguration, useGetBucketPolicy, useGetBucketVersioning } from "../../hooks/index.js";
|
|
6
|
+
import { useDataBrowserContext } from "../providers/DataBrowserProvider.js";
|
|
7
|
+
import { Body, Group, GroupContent, GroupName, Key, Row, Table, TableContainer, Value } from "../ui/Table.elements.js";
|
|
8
|
+
import { BucketLocation } from "./BucketLocation.js";
|
|
9
|
+
import { BucketPolicyButton } from "./BucketPolicyButton.js";
|
|
10
|
+
const BucketOverview = ({ bucketName, onEmptyBucket, onDeleteBucket, onEditPolicy, renderDeleteButton, renderEmptyButton, isEmptyBucketDisabled = true, isDeleteBucketDisabled = false })=>{
|
|
11
|
+
const { getS3Config } = useDataBrowserContext();
|
|
12
|
+
const config = getS3Config();
|
|
13
|
+
const { data: versioningData, status: versioningStatus } = useGetBucketVersioning({
|
|
14
|
+
Bucket: bucketName
|
|
15
|
+
});
|
|
16
|
+
const { data: aclData, status: aclStatus } = useGetBucketAcl({
|
|
17
|
+
Bucket: bucketName
|
|
18
|
+
});
|
|
19
|
+
const { data: corsData, status: corsStatus } = useGetBucketCors({
|
|
20
|
+
Bucket: bucketName
|
|
21
|
+
});
|
|
22
|
+
const { data: objectLockData, status: objectLockStatus } = useGetBucketObjectLockConfiguration({
|
|
23
|
+
Bucket: bucketName
|
|
24
|
+
});
|
|
25
|
+
const { data: policyData, error: policyError, status: policyStatus } = useGetBucketPolicy({
|
|
26
|
+
Bucket: bucketName
|
|
27
|
+
});
|
|
28
|
+
return /*#__PURE__*/ jsxs(TableContainer, {
|
|
29
|
+
children: [
|
|
30
|
+
/*#__PURE__*/ jsxs(Box, {
|
|
31
|
+
display: "flex",
|
|
32
|
+
justifyContent: "flex-end",
|
|
33
|
+
paddingBottom: spacing.r16,
|
|
34
|
+
children: [
|
|
35
|
+
renderEmptyButton ? renderEmptyButton(bucketName) : /*#__PURE__*/ jsx(Button, {
|
|
36
|
+
icon: /*#__PURE__*/ jsx(Icon, {
|
|
37
|
+
name: "Eraser"
|
|
38
|
+
}),
|
|
39
|
+
disabled: isEmptyBucketDisabled,
|
|
40
|
+
variant: "danger",
|
|
41
|
+
label: "Empty Bucket",
|
|
42
|
+
onClick: onEmptyBucket,
|
|
43
|
+
style: {
|
|
44
|
+
marginRight: "1rem"
|
|
45
|
+
}
|
|
46
|
+
}),
|
|
47
|
+
renderDeleteButton ? renderDeleteButton(bucketName) : /*#__PURE__*/ jsx(Button, {
|
|
48
|
+
icon: /*#__PURE__*/ jsx(Icon, {
|
|
49
|
+
name: "Delete"
|
|
50
|
+
}),
|
|
51
|
+
disabled: isDeleteBucketDisabled,
|
|
52
|
+
variant: "danger",
|
|
53
|
+
label: "Delete Bucket",
|
|
54
|
+
onClick: onDeleteBucket
|
|
55
|
+
})
|
|
56
|
+
]
|
|
57
|
+
}),
|
|
58
|
+
/*#__PURE__*/ jsx(Table, {
|
|
59
|
+
children: /*#__PURE__*/ jsxs(Body, {
|
|
60
|
+
children: [
|
|
61
|
+
/*#__PURE__*/ jsxs(Group, {
|
|
62
|
+
children: [
|
|
63
|
+
/*#__PURE__*/ jsx(GroupName, {
|
|
64
|
+
children: "General"
|
|
65
|
+
}),
|
|
66
|
+
/*#__PURE__*/ jsxs(GroupContent, {
|
|
67
|
+
children: [
|
|
68
|
+
/*#__PURE__*/ jsxs(Row, {
|
|
69
|
+
children: [
|
|
70
|
+
/*#__PURE__*/ jsx(Key, {
|
|
71
|
+
children: "Name"
|
|
72
|
+
}),
|
|
73
|
+
/*#__PURE__*/ jsx(Value, {
|
|
74
|
+
width: "15rem",
|
|
75
|
+
children: /*#__PURE__*/ jsx(ConstrainedText, {
|
|
76
|
+
text: bucketName,
|
|
77
|
+
lineClamp: 2
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
]
|
|
81
|
+
}),
|
|
82
|
+
/*#__PURE__*/ jsxs(Row, {
|
|
83
|
+
children: [
|
|
84
|
+
/*#__PURE__*/ jsx(Key, {
|
|
85
|
+
children: "Versioning"
|
|
86
|
+
}),
|
|
87
|
+
/*#__PURE__*/ jsx(Value, {
|
|
88
|
+
children: "pending" === versioningStatus ? /*#__PURE__*/ jsx(Loader, {}) : "error" === versioningStatus ? "Error" : versioningData?.Status === "Enabled" ? "Active" : "Inactive"
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
}),
|
|
92
|
+
/*#__PURE__*/ jsxs(Row, {
|
|
93
|
+
children: [
|
|
94
|
+
/*#__PURE__*/ jsx(Key, {
|
|
95
|
+
children: "Location"
|
|
96
|
+
}),
|
|
97
|
+
/*#__PURE__*/ jsx(Value, {
|
|
98
|
+
children: /*#__PURE__*/ jsx(BucketLocation, {
|
|
99
|
+
bucketName: bucketName
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
]
|
|
103
|
+
})
|
|
104
|
+
]
|
|
105
|
+
})
|
|
106
|
+
]
|
|
107
|
+
}),
|
|
108
|
+
/*#__PURE__*/ jsxs(Group, {
|
|
109
|
+
children: [
|
|
110
|
+
/*#__PURE__*/ jsx(GroupName, {
|
|
111
|
+
children: "Data protection"
|
|
112
|
+
}),
|
|
113
|
+
/*#__PURE__*/ jsx(GroupContent, {
|
|
114
|
+
children: /*#__PURE__*/ jsxs(Row, {
|
|
115
|
+
children: [
|
|
116
|
+
/*#__PURE__*/ jsx(Key, {
|
|
117
|
+
children: "Object-lock"
|
|
118
|
+
}),
|
|
119
|
+
/*#__PURE__*/ jsx(Value, {
|
|
120
|
+
children: "pending" === objectLockStatus ? /*#__PURE__*/ jsx(Loader, {}) : "error" === objectLockStatus ? "Disabled" : objectLockData?.ObjectLockConfiguration?.ObjectLockEnabled === "Enabled" ? "Enabled" : "Disabled"
|
|
121
|
+
})
|
|
122
|
+
]
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
]
|
|
126
|
+
}),
|
|
127
|
+
/*#__PURE__*/ jsxs(Group, {
|
|
128
|
+
children: [
|
|
129
|
+
/*#__PURE__*/ jsx(GroupName, {
|
|
130
|
+
children: "Permissions"
|
|
131
|
+
}),
|
|
132
|
+
/*#__PURE__*/ jsxs(GroupContent, {
|
|
133
|
+
children: [
|
|
134
|
+
/*#__PURE__*/ jsxs(Row, {
|
|
135
|
+
children: [
|
|
136
|
+
/*#__PURE__*/ jsx(Key, {
|
|
137
|
+
children: "Owner"
|
|
138
|
+
}),
|
|
139
|
+
/*#__PURE__*/ jsx(Value, {
|
|
140
|
+
children: "pending" === aclStatus ? /*#__PURE__*/ jsx(Loader, {}) : "error" === aclStatus ? "Error" : aclData?.Owner?.DisplayName || "N/A"
|
|
141
|
+
})
|
|
142
|
+
]
|
|
143
|
+
}),
|
|
144
|
+
/*#__PURE__*/ jsxs(Row, {
|
|
145
|
+
children: [
|
|
146
|
+
/*#__PURE__*/ jsx(Key, {
|
|
147
|
+
children: "ACL"
|
|
148
|
+
}),
|
|
149
|
+
/*#__PURE__*/ jsx(Value, {
|
|
150
|
+
children: "pending" === aclStatus ? /*#__PURE__*/ jsx(Loader, {}) : "error" === aclStatus ? "Error" : aclData?.Grants?.length ? `${aclData.Grants.length} Grantee${1 !== aclData.Grants.length ? "s" : ""}` : "N/A"
|
|
151
|
+
})
|
|
152
|
+
]
|
|
153
|
+
}),
|
|
154
|
+
/*#__PURE__*/ jsxs(Row, {
|
|
155
|
+
children: [
|
|
156
|
+
/*#__PURE__*/ jsx(Key, {
|
|
157
|
+
children: "CORS"
|
|
158
|
+
}),
|
|
159
|
+
/*#__PURE__*/ jsx(Value, {
|
|
160
|
+
children: "pending" === corsStatus ? /*#__PURE__*/ jsx(Loader, {}) : "error" === corsStatus ? "No" : corsData?.CORSRules && corsData.CORSRules.length > 0 ? "Yes" : "No"
|
|
161
|
+
})
|
|
162
|
+
]
|
|
163
|
+
}),
|
|
164
|
+
/*#__PURE__*/ jsxs(Row, {
|
|
165
|
+
children: [
|
|
166
|
+
/*#__PURE__*/ jsx(Key, {
|
|
167
|
+
children: "Public"
|
|
168
|
+
}),
|
|
169
|
+
/*#__PURE__*/ jsx(Value, {
|
|
170
|
+
children: "pending" === aclStatus ? /*#__PURE__*/ jsx(Loader, {}) : "error" === aclStatus ? "No" : aclData?.Grants ? aclData.Grants.find((grant)=>grant.Grantee?.URI === (config.publicAclIndicator || "http://acs.amazonaws.com/groups/global/AllUsers")) ? "Yes" : "No" : "No"
|
|
171
|
+
})
|
|
172
|
+
]
|
|
173
|
+
}),
|
|
174
|
+
/*#__PURE__*/ jsxs(Row, {
|
|
175
|
+
children: [
|
|
176
|
+
/*#__PURE__*/ jsx(Key, {
|
|
177
|
+
children: "Bucket Policy"
|
|
178
|
+
}),
|
|
179
|
+
/*#__PURE__*/ jsx(Value, {
|
|
180
|
+
children: "error" === policyStatus && policyError?.name !== "NoSuchBucketPolicy" ? "Error" : /*#__PURE__*/ jsxs(Box, {
|
|
181
|
+
display: "flex",
|
|
182
|
+
justifyContent: "space-between",
|
|
183
|
+
alignItems: "center",
|
|
184
|
+
gap: spacing.r8,
|
|
185
|
+
children: [
|
|
186
|
+
/*#__PURE__*/ jsx("span", {
|
|
187
|
+
children: policyData?.Policy ? "Configured" : "Not configured"
|
|
188
|
+
}),
|
|
189
|
+
/*#__PURE__*/ jsx(BucketPolicyButton, {
|
|
190
|
+
hasPolicy: !!policyData?.Policy,
|
|
191
|
+
isLoading: "pending" === policyStatus,
|
|
192
|
+
onEdit: ()=>onEditPolicy?.(bucketName)
|
|
193
|
+
})
|
|
194
|
+
]
|
|
195
|
+
})
|
|
196
|
+
})
|
|
197
|
+
]
|
|
198
|
+
})
|
|
199
|
+
]
|
|
200
|
+
})
|
|
201
|
+
]
|
|
202
|
+
})
|
|
203
|
+
]
|
|
204
|
+
})
|
|
205
|
+
})
|
|
206
|
+
]
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
export { BucketOverview };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useBuckets } from "../../hooks/index.js";
|
|
3
|
+
import { TextBadge } from "@scality/core-ui";
|
|
4
|
+
import { Navigate, useNavigate, useParams } from "react-router-dom";
|
|
5
|
+
import { BrowserPageLayout } from "../layouts/BrowserPageLayout.js";
|
|
6
|
+
import { BucketDetails } from "./BucketDetails.js";
|
|
7
|
+
import { BucketList } from "./BucketList.js";
|
|
8
|
+
import { BucketLocation } from "./BucketLocation.js";
|
|
9
|
+
const BucketPage_BucketPage = ()=>{
|
|
10
|
+
const { data, status } = useBuckets();
|
|
11
|
+
const { bucketName } = useParams();
|
|
12
|
+
const navigate = useNavigate();
|
|
13
|
+
const buckets = data?.Buckets || [];
|
|
14
|
+
const numInstance = buckets.length;
|
|
15
|
+
if (!bucketName && buckets.length > 0 && "success" === status) {
|
|
16
|
+
const firstBucketName = buckets[0]?.Name;
|
|
17
|
+
if (firstBucketName) return /*#__PURE__*/ jsx(Navigate, {
|
|
18
|
+
to: `/buckets/${firstBucketName}`,
|
|
19
|
+
replace: true
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return /*#__PURE__*/ jsx(BrowserPageLayout, {
|
|
23
|
+
title: /*#__PURE__*/ jsxs(Fragment, {
|
|
24
|
+
children: [
|
|
25
|
+
"All Buckets",
|
|
26
|
+
/*#__PURE__*/ jsx(TextBadge, {
|
|
27
|
+
text: numInstance.toString(),
|
|
28
|
+
variant: "infoPrimary"
|
|
29
|
+
})
|
|
30
|
+
]
|
|
31
|
+
}),
|
|
32
|
+
leftPanel: /*#__PURE__*/ jsx(BucketList, {
|
|
33
|
+
buckets: buckets,
|
|
34
|
+
bucketStatus: "pending" === status ? "loading" : "error" === status ? "error" : "success",
|
|
35
|
+
selectedBucketName: bucketName,
|
|
36
|
+
onBucketSelect: (bucketName)=>navigate(`/buckets/${bucketName}`),
|
|
37
|
+
onCreateBucket: ()=>navigate("/create-bucket"),
|
|
38
|
+
onNavigateToBucket: (bucketName)=>navigate(`/buckets/${bucketName}/objects`),
|
|
39
|
+
renderBucketLocation: (bucketName)=>/*#__PURE__*/ jsx(BucketLocation, {
|
|
40
|
+
bucketName: bucketName
|
|
41
|
+
})
|
|
42
|
+
}),
|
|
43
|
+
rightPanel: /*#__PURE__*/ jsx(BucketDetails, {})
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
const BucketPage = BucketPage_BucketPage;
|
|
47
|
+
export { BucketPage_BucketPage as BucketPage, BucketPage as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Icon, spacing } from "@scality/core-ui";
|
|
3
|
+
import { Box, Button } from "@scality/core-ui/dist/next";
|
|
4
|
+
const BucketPolicyButton = ({ hasPolicy, isLoading, onEdit })=>/*#__PURE__*/ jsx(Box, {
|
|
5
|
+
display: "flex",
|
|
6
|
+
alignItems: "center",
|
|
7
|
+
gap: spacing.r8,
|
|
8
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
9
|
+
isLoading: isLoading,
|
|
10
|
+
variant: "outline",
|
|
11
|
+
label: hasPolicy ? "Edit" : "Create",
|
|
12
|
+
icon: /*#__PURE__*/ jsx(Icon, {
|
|
13
|
+
name: hasPolicy ? "Pen" : "Create-add"
|
|
14
|
+
}),
|
|
15
|
+
onClick: onEdit
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
export { BucketPolicyButton };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BucketPolicyPage: React.FC;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useMemo } from "react";
|
|
3
|
+
import { useNavigate, useParams } from "react-router-dom";
|
|
4
|
+
import { Form, FormGroup, FormSection, Icon, Loader, Stack, Text } from "@scality/core-ui";
|
|
5
|
+
import { Box, Button, CopyButton } from "@scality/core-ui/dist/next";
|
|
6
|
+
import { Controller, useForm } from "react-hook-form";
|
|
7
|
+
import { Editor } from "../Editor.js";
|
|
8
|
+
import { useGetBucketPolicy, useSetBucketPolicy } from "../../hooks/index.js";
|
|
9
|
+
import bucketPolicySchema from "../../schemas/bucketPolicySchema.json";
|
|
10
|
+
const getDefaultPolicyTemplate = (bucketName)=>`{
|
|
11
|
+
"Version": "2012-10-17",
|
|
12
|
+
"Statement": [
|
|
13
|
+
{
|
|
14
|
+
"Sid": "ExampleStatement",
|
|
15
|
+
"Effect": "Allow",
|
|
16
|
+
"Principal": "*",
|
|
17
|
+
"Action": "s3:GetObject",
|
|
18
|
+
"Resource": "arn:aws:s3:::${bucketName}/*"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}`;
|
|
22
|
+
const BucketPolicyPage = ()=>{
|
|
23
|
+
const { bucketName } = useParams();
|
|
24
|
+
const navigate = useNavigate();
|
|
25
|
+
const { mutate: savePolicy, isPending: isSaving } = useSetBucketPolicy();
|
|
26
|
+
const { control, handleSubmit, watch, setValue, setError, formState: { isDirty, isValid, errors } } = useForm({
|
|
27
|
+
mode: "onChange",
|
|
28
|
+
defaultValues: {
|
|
29
|
+
policyDocument: ""
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const policyDocument = watch("policyDocument");
|
|
33
|
+
const { data: policyData, status: policyStatus, error: policyError } = useGetBucketPolicy({
|
|
34
|
+
Bucket: bucketName
|
|
35
|
+
});
|
|
36
|
+
const isCreateMode = useMemo(()=>policyError && ("NoSuchBucketPolicy" === policyError.name || policyError.message?.includes("does not exist")), [
|
|
37
|
+
policyError
|
|
38
|
+
]);
|
|
39
|
+
const initialPolicy = useMemo(()=>{
|
|
40
|
+
const policyString = policyData?.Policy;
|
|
41
|
+
if (policyString) try {
|
|
42
|
+
const parsed = JSON.parse(policyString);
|
|
43
|
+
return JSON.stringify(parsed, null, 2);
|
|
44
|
+
} catch {
|
|
45
|
+
return policyString;
|
|
46
|
+
}
|
|
47
|
+
return getDefaultPolicyTemplate(bucketName);
|
|
48
|
+
}, [
|
|
49
|
+
policyData,
|
|
50
|
+
bucketName
|
|
51
|
+
]);
|
|
52
|
+
useEffect(()=>{
|
|
53
|
+
setValue("policyDocument", initialPolicy);
|
|
54
|
+
}, [
|
|
55
|
+
initialPolicy,
|
|
56
|
+
setValue
|
|
57
|
+
]);
|
|
58
|
+
const handleBeforeMount = useCallback((monaco)=>{
|
|
59
|
+
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
|
|
60
|
+
validate: true,
|
|
61
|
+
schemas: [
|
|
62
|
+
{
|
|
63
|
+
uri: "http://myserver/bucket-policy-schema.json",
|
|
64
|
+
fileMatch: [
|
|
65
|
+
"*"
|
|
66
|
+
],
|
|
67
|
+
schema: bucketPolicySchema
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
});
|
|
71
|
+
}, []);
|
|
72
|
+
const handleCancel = useCallback(()=>{
|
|
73
|
+
navigate(`/buckets/${bucketName}`);
|
|
74
|
+
}, [
|
|
75
|
+
navigate,
|
|
76
|
+
bucketName
|
|
77
|
+
]);
|
|
78
|
+
const onSubmit = useCallback((data)=>{
|
|
79
|
+
try {
|
|
80
|
+
JSON.parse(data.policyDocument);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
const errorMessage = "Invalid JSON format";
|
|
83
|
+
setError("policyDocument", {
|
|
84
|
+
type: "custom",
|
|
85
|
+
message: errorMessage
|
|
86
|
+
});
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const minifiedPolicy = JSON.stringify(JSON.parse(data.policyDocument));
|
|
90
|
+
savePolicy({
|
|
91
|
+
Bucket: bucketName,
|
|
92
|
+
Policy: minifiedPolicy
|
|
93
|
+
}, {
|
|
94
|
+
onSuccess: ()=>{
|
|
95
|
+
navigate(`/buckets/${bucketName}`);
|
|
96
|
+
},
|
|
97
|
+
onError: (error)=>{
|
|
98
|
+
const errorMessage = error instanceof Error ? error.message : "Failed to save policy";
|
|
99
|
+
setError("policyDocument", {
|
|
100
|
+
type: "custom",
|
|
101
|
+
message: `Save policy error: ${errorMessage}`
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}, [
|
|
106
|
+
bucketName,
|
|
107
|
+
savePolicy,
|
|
108
|
+
navigate,
|
|
109
|
+
setError
|
|
110
|
+
]);
|
|
111
|
+
if ("pending" === policyStatus) return /*#__PURE__*/ jsx(Loader, {
|
|
112
|
+
centered: true,
|
|
113
|
+
size: "massive",
|
|
114
|
+
children: /*#__PURE__*/ jsx(Fragment, {
|
|
115
|
+
children: "Loading policy..."
|
|
116
|
+
})
|
|
117
|
+
});
|
|
118
|
+
return /*#__PURE__*/ jsx(Form, {
|
|
119
|
+
onSubmit: handleSubmit(onSubmit),
|
|
120
|
+
layout: {
|
|
121
|
+
kind: "page",
|
|
122
|
+
title: `Bucket Policy ${isCreateMode ? "Creation" : "Edition"}`
|
|
123
|
+
},
|
|
124
|
+
requireMode: isCreateMode ? "partial" : "all",
|
|
125
|
+
rightActions: /*#__PURE__*/ jsxs(Stack, {
|
|
126
|
+
gap: "r16",
|
|
127
|
+
children: [
|
|
128
|
+
/*#__PURE__*/ jsx(Button, {
|
|
129
|
+
variant: "outline",
|
|
130
|
+
label: "Cancel",
|
|
131
|
+
onClick: handleCancel,
|
|
132
|
+
type: "button",
|
|
133
|
+
disabled: isSaving
|
|
134
|
+
}),
|
|
135
|
+
/*#__PURE__*/ jsx(Button, {
|
|
136
|
+
variant: "primary",
|
|
137
|
+
label: "Save",
|
|
138
|
+
icon: /*#__PURE__*/ jsx(Icon, {
|
|
139
|
+
name: "Save"
|
|
140
|
+
}),
|
|
141
|
+
type: "submit",
|
|
142
|
+
disabled: !isDirty || !isValid || isSaving
|
|
143
|
+
})
|
|
144
|
+
]
|
|
145
|
+
}),
|
|
146
|
+
children: /*#__PURE__*/ jsxs(FormSection, {
|
|
147
|
+
children: [
|
|
148
|
+
/*#__PURE__*/ jsx(FormGroup, {
|
|
149
|
+
id: "bucketName",
|
|
150
|
+
label: "Bucket Name",
|
|
151
|
+
required: true,
|
|
152
|
+
direction: "horizontal",
|
|
153
|
+
content: /*#__PURE__*/ jsx(Text, {
|
|
154
|
+
children: bucketName
|
|
155
|
+
})
|
|
156
|
+
}),
|
|
157
|
+
/*#__PURE__*/ jsx(FormGroup, {
|
|
158
|
+
id: "policyDocument",
|
|
159
|
+
label: "Policy Document",
|
|
160
|
+
required: true,
|
|
161
|
+
direction: "vertical",
|
|
162
|
+
help: "AWS Bucket policy standards are supported.",
|
|
163
|
+
helpErrorPosition: "bottom",
|
|
164
|
+
error: errors?.policyDocument?.message,
|
|
165
|
+
content: /*#__PURE__*/ jsxs(Stack, {
|
|
166
|
+
children: [
|
|
167
|
+
/*#__PURE__*/ jsx(Controller, {
|
|
168
|
+
control: control,
|
|
169
|
+
name: "policyDocument",
|
|
170
|
+
rules: {
|
|
171
|
+
required: "The policy document is required",
|
|
172
|
+
validate: (value)=>{
|
|
173
|
+
try {
|
|
174
|
+
JSON.parse(value);
|
|
175
|
+
return true;
|
|
176
|
+
} catch {
|
|
177
|
+
return "Invalid JSON format";
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
render: ({ field: { onChange, value } })=>/*#__PURE__*/ jsx(Editor, {
|
|
182
|
+
value: value,
|
|
183
|
+
onChange: onChange,
|
|
184
|
+
language: "json",
|
|
185
|
+
height: "60vh",
|
|
186
|
+
width: "33rem",
|
|
187
|
+
beforeMount: handleBeforeMount
|
|
188
|
+
})
|
|
189
|
+
}),
|
|
190
|
+
/*#__PURE__*/ jsx(Box, {
|
|
191
|
+
alignSelf: "baseline",
|
|
192
|
+
children: /*#__PURE__*/ jsx(CopyButton, {
|
|
193
|
+
textToCopy: policyDocument,
|
|
194
|
+
label: "Policy",
|
|
195
|
+
variant: "outline"
|
|
196
|
+
})
|
|
197
|
+
})
|
|
198
|
+
]
|
|
199
|
+
})
|
|
200
|
+
})
|
|
201
|
+
]
|
|
202
|
+
})
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
export { BucketPolicyPage };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface DeleteBucketButtonProps {
|
|
2
|
+
bucketName: string;
|
|
3
|
+
onDeleteSuccess?: (bucketName: string) => void;
|
|
4
|
+
onDeleteError?: (error: Error) => void;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const DeleteBucketButton: ({ bucketName, onDeleteSuccess, onDeleteError, disabled, }: DeleteBucketButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default DeleteBucketButton;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useIsBucketEmpty } from "../../hooks/useIsBucketEmpty.js";
|
|
4
|
+
import { useDeleteBucket } from "../../hooks/bucketOperations.js";
|
|
5
|
+
import { Icon, Loader, Modal, Stack, Tooltip, Wrap } from "@scality/core-ui";
|
|
6
|
+
import { Button } from "@scality/core-ui/dist/next";
|
|
7
|
+
const DeleteBucketButton = ({ bucketName, onDeleteSuccess, onDeleteError, disabled = false })=>{
|
|
8
|
+
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
|
9
|
+
const { isEmpty, isLoading } = useIsBucketEmpty(bucketName);
|
|
10
|
+
const { mutate: deleteBucket, status } = useDeleteBucket();
|
|
11
|
+
const handleDeleteClick = ()=>{
|
|
12
|
+
setIsDeleteModalOpen(!isDeleteModalOpen);
|
|
13
|
+
};
|
|
14
|
+
const approve = ()=>{
|
|
15
|
+
deleteBucket({
|
|
16
|
+
Bucket: bucketName
|
|
17
|
+
}, {
|
|
18
|
+
onSuccess: ()=>{
|
|
19
|
+
handleDeleteClick();
|
|
20
|
+
onDeleteSuccess?.(bucketName);
|
|
21
|
+
},
|
|
22
|
+
onError: (error)=>{
|
|
23
|
+
onDeleteError?.(error instanceof Error ? error : new Error("Delete failed"));
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
const isButtonDisabled = disabled || !isEmpty;
|
|
28
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
29
|
+
children: [
|
|
30
|
+
/*#__PURE__*/ jsx(Tooltip, {
|
|
31
|
+
overlay: isLoading ? "Checking bucket..." : "Bucket is not empty",
|
|
32
|
+
overlayStyle: {
|
|
33
|
+
display: isEmpty ? "none" : void 0
|
|
34
|
+
},
|
|
35
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
36
|
+
icon: /*#__PURE__*/ jsx(Icon, {
|
|
37
|
+
name: "Delete"
|
|
38
|
+
}),
|
|
39
|
+
disabled: isButtonDisabled,
|
|
40
|
+
variant: "danger",
|
|
41
|
+
onClick: handleDeleteClick,
|
|
42
|
+
label: "Delete Bucket"
|
|
43
|
+
})
|
|
44
|
+
}),
|
|
45
|
+
/*#__PURE__*/ jsx(Modal, {
|
|
46
|
+
close: handleDeleteClick,
|
|
47
|
+
isOpen: isDeleteModalOpen,
|
|
48
|
+
footer: /*#__PURE__*/ jsxs(Wrap, {
|
|
49
|
+
children: [
|
|
50
|
+
/*#__PURE__*/ jsx("p", {}),
|
|
51
|
+
/*#__PURE__*/ jsxs(Stack, {
|
|
52
|
+
children: [
|
|
53
|
+
/*#__PURE__*/ jsx(Button, {
|
|
54
|
+
variant: "outline",
|
|
55
|
+
onClick: handleDeleteClick,
|
|
56
|
+
label: "Cancel"
|
|
57
|
+
}),
|
|
58
|
+
/*#__PURE__*/ jsx(Button, {
|
|
59
|
+
disabled: "pending" === status,
|
|
60
|
+
variant: "danger",
|
|
61
|
+
onClick: approve,
|
|
62
|
+
icon: "pending" === status && /*#__PURE__*/ jsx(Loader, {
|
|
63
|
+
size: "larger"
|
|
64
|
+
}),
|
|
65
|
+
label: "Delete"
|
|
66
|
+
})
|
|
67
|
+
]
|
|
68
|
+
})
|
|
69
|
+
]
|
|
70
|
+
}),
|
|
71
|
+
title: "Confirmation",
|
|
72
|
+
children: `Are you sure you want to delete bucket: ${bucketName} ?`
|
|
73
|
+
})
|
|
74
|
+
]
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
const buckets_DeleteBucketButton = DeleteBucketButton;
|
|
78
|
+
export { DeleteBucketButton, buckets_DeleteBucketButton as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { DeleteBucketButton } from "./buckets/DeleteBucketButton";
|
|
2
|
+
export { BucketList } from "./buckets/BucketList";
|
|
3
|
+
export { BucketOverview } from "./buckets/BucketOverview";
|
|
4
|
+
export { BucketPage } from "./buckets/BucketPage";
|
|
5
|
+
export { BucketPolicyPage } from "./buckets/BucketPolicyPage";
|
|
6
|
+
export { UploadButton } from "./objects/UploadButton";
|
|
7
|
+
export { CreateFolderButton } from "./objects/CreateFolderButton";
|
|
8
|
+
export { ObjectDetails } from "./objects/ObjectDetails";
|
|
9
|
+
export { ObjectList } from "./objects/ObjectList";
|
|
10
|
+
export { ObjectPage } from "./objects/ObjectPage";
|
|
11
|
+
export { MetadataSearch } from "./search/MetadataSearch";
|
|
12
|
+
export { DataBrowserProvider, useDataBrowserContext, useDataBrowserTheme, } from "./providers/DataBrowserProvider";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DeleteBucketButton } from "./buckets/DeleteBucketButton.js";
|
|
2
|
+
import { BucketList } from "./buckets/BucketList.js";
|
|
3
|
+
import { BucketOverview } from "./buckets/BucketOverview.js";
|
|
4
|
+
import { BucketPage } from "./buckets/BucketPage.js";
|
|
5
|
+
import { BucketPolicyPage } from "./buckets/BucketPolicyPage.js";
|
|
6
|
+
import { UploadButton } from "./objects/UploadButton.js";
|
|
7
|
+
import { CreateFolderButton } from "./objects/CreateFolderButton.js";
|
|
8
|
+
import { ObjectDetails } from "./objects/ObjectDetails/index.js";
|
|
9
|
+
import { ObjectList } from "./objects/ObjectList.js";
|
|
10
|
+
import { ObjectPage } from "./objects/ObjectPage.js";
|
|
11
|
+
import { MetadataSearch } from "./search/MetadataSearch.js";
|
|
12
|
+
import { DataBrowserProvider, useDataBrowserContext, useDataBrowserTheme } from "./providers/DataBrowserProvider.js";
|
|
13
|
+
export { BucketList, BucketOverview, BucketPage, BucketPolicyPage, CreateFolderButton, DataBrowserProvider, DeleteBucketButton, MetadataSearch, ObjectDetails, ObjectList, ObjectPage, UploadButton, useDataBrowserContext, useDataBrowserTheme };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare const HeadTitle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
+
interface BrowserPageLayoutProps {
|
|
4
|
+
title: React.ReactNode;
|
|
5
|
+
leftPanel: React.ReactNode;
|
|
6
|
+
rightPanel: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const BrowserPageLayout: React.FC<BrowserPageLayoutProps>;
|
|
9
|
+
export {};
|