@scality/data-browser-library 1.0.0-preview.7 → 1.0.0-preview.9
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/__tests__/BucketCreate.test.d.ts +1 -0
- package/dist/components/__tests__/BucketCreate.test.js +408 -0
- package/dist/components/__tests__/BucketLifecycleFormPage.test.d.ts +1 -0
- package/dist/components/__tests__/BucketLifecycleFormPage.test.js +618 -0
- package/dist/components/__tests__/BucketLifecycleList.test.d.ts +1 -0
- package/dist/components/__tests__/BucketLifecycleList.test.js +325 -0
- package/dist/components/__tests__/BucketList.test.js +190 -0
- package/dist/components/__tests__/BucketOverview.test.js +298 -8
- package/dist/components/__tests__/BucketReplicationFormPage.test.d.ts +1 -0
- package/dist/components/__tests__/BucketReplicationFormPage.test.js +1757 -0
- package/dist/components/__tests__/BucketReplicationList.test.d.ts +1 -0
- package/dist/components/__tests__/BucketReplicationList.test.js +344 -0
- package/dist/components/__tests__/DeleteBucketConfigRuleButton.test.d.ts +1 -0
- package/dist/components/__tests__/DeleteBucketConfigRuleButton.test.js +196 -0
- package/dist/components/__tests__/EmptyBucketButton.test.d.ts +1 -0
- package/dist/components/__tests__/EmptyBucketButton.test.js +302 -0
- package/dist/components/buckets/BucketCreate.d.ts +49 -0
- package/dist/components/buckets/BucketCreate.js +237 -0
- package/dist/components/buckets/BucketDetails.js +62 -10
- package/dist/components/buckets/BucketLifecycleFormPage.d.ts +15 -0
- package/dist/components/buckets/BucketLifecycleFormPage.js +1070 -0
- package/dist/components/buckets/BucketLifecycleList.d.ts +10 -0
- package/dist/components/buckets/BucketLifecycleList.js +270 -0
- package/dist/components/buckets/BucketList.d.ts +5 -2
- package/dist/components/buckets/BucketList.js +38 -28
- package/dist/components/buckets/BucketOverview.d.ts +65 -4
- package/dist/components/buckets/BucketOverview.js +261 -179
- package/dist/components/buckets/BucketPage.js +1 -1
- package/dist/components/buckets/BucketReplicationFormPage.d.ts +1 -0
- package/dist/components/buckets/BucketReplicationFormPage.js +834 -0
- package/dist/components/buckets/BucketReplicationList.d.ts +11 -0
- package/dist/components/buckets/BucketReplicationList.js +189 -0
- package/dist/components/buckets/DeleteBucketConfigRuleButton.d.ts +18 -0
- package/dist/components/buckets/DeleteBucketConfigRuleButton.js +53 -0
- package/dist/components/buckets/EmptyBucketButton.d.ts +5 -0
- package/dist/components/buckets/EmptyBucketButton.js +232 -0
- package/dist/components/buckets/EmptyBucketSummary.d.ts +9 -0
- package/dist/components/buckets/EmptyBucketSummary.js +60 -0
- package/dist/components/buckets/EmptyBucketSummaryList.d.ts +13 -0
- package/dist/components/buckets/EmptyBucketSummaryList.js +140 -0
- package/dist/components/buckets/notifications/BucketNotificationCreatePage.js +8 -8
- package/dist/components/index.d.ts +8 -1
- package/dist/components/index.js +9 -2
- package/dist/components/objects/ObjectLock/EditRetentionButton.d.ts +4 -0
- package/dist/components/objects/ObjectLock/EditRetentionButton.js +32 -0
- package/dist/components/objects/ObjectLock/ObjectLockRetentionSettings.d.ts +3 -0
- package/dist/components/objects/ObjectLock/ObjectLockRetentionSettings.js +211 -0
- package/dist/components/objects/ObjectLock/ObjectLockSettings.d.ts +9 -0
- package/dist/components/objects/ObjectLock/ObjectLockSettings.js +158 -0
- package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.d.ts +8 -0
- package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.js +39 -0
- package/dist/components/objects/ObjectLock/__tests__/EditRetentionButton.test.d.ts +1 -0
- package/dist/components/objects/ObjectLock/__tests__/EditRetentionButton.test.js +204 -0
- package/dist/components/objects/ObjectLock/__tests__/ObjectLockSettings.test.d.ts +1 -0
- package/dist/components/objects/ObjectLock/__tests__/ObjectLockSettings.test.js +374 -0
- package/dist/components/ui/ArrayFieldActions.d.ts +36 -0
- package/dist/components/ui/ArrayFieldActions.js +38 -0
- package/dist/components/ui/ConfirmDeleteRuleModal.d.ts +16 -0
- package/dist/components/ui/ConfirmDeleteRuleModal.js +43 -0
- package/dist/components/ui/FilterFormSection.d.ts +44 -0
- package/dist/components/ui/FilterFormSection.js +159 -0
- package/dist/config/factory.d.ts +13 -2
- package/dist/config/factory.js +9 -6
- package/dist/hooks/__tests__/useISVBucketDetection.test.d.ts +1 -0
- package/dist/hooks/__tests__/useISVBucketDetection.test.js +188 -0
- package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.js +44 -1
- package/dist/hooks/factories/useCreateS3QueryHook.js +22 -1
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.js +5 -1
- package/dist/hooks/useDeleteBucketConfigRule.d.ts +26 -0
- package/dist/hooks/useDeleteBucketConfigRule.js +46 -0
- package/dist/hooks/useEmptyBucket.d.ts +27 -0
- package/dist/hooks/useEmptyBucket.js +116 -0
- package/dist/hooks/useISVBucketDetection.d.ts +15 -0
- package/dist/hooks/useISVBucketDetection.js +27 -0
- package/dist/hooks/useTableRowSelection.d.ts +9 -0
- package/dist/hooks/useTableRowSelection.js +45 -0
- package/dist/test/setup.js +8 -0
- package/dist/test/testUtils.d.ts +99 -17
- package/dist/test/testUtils.js +64 -16
- package/dist/test/utils/errorHandling.test.js +39 -1
- package/dist/utils/constants.d.ts +12 -0
- package/dist/utils/constants.js +9 -0
- package/dist/utils/errorHandling.d.ts +9 -0
- package/dist/utils/errorHandling.js +6 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/s3RuleUtils.d.ts +53 -0
- package/dist/utils/s3RuleUtils.js +101 -0
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReplicationRule } from "@aws-sdk/client-s3";
|
|
2
|
+
interface BucketReplicationListProps {
|
|
3
|
+
bucketName: string;
|
|
4
|
+
replicationRules: ReplicationRule[];
|
|
5
|
+
replicationRole: string;
|
|
6
|
+
replicationStatus?: "idle" | "loading" | "error" | "success";
|
|
7
|
+
onCreateRule?: () => void;
|
|
8
|
+
onEditRule?: (ruleId: string) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function BucketReplicationList({ bucketName, replicationRules, replicationRole, replicationStatus, onCreateRule, onEditRule, }: BucketReplicationListProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ConstrainedText, Icon, Wrap, spacing } from "@scality/core-ui";
|
|
3
|
+
import { Box, Button, Table } from "@scality/core-ui/dist/next";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { useDeleteBucketReplication, useSetBucketReplication } from "../../hooks/bucketConfiguration.js";
|
|
6
|
+
import { DeleteBucketConfigRuleButton } from "./DeleteBucketConfigRuleButton.js";
|
|
7
|
+
import { useTableRowSelection } from "../../hooks/useTableRowSelection.js";
|
|
8
|
+
function BucketReplicationList({ bucketName, replicationRules, replicationRole, replicationStatus, onCreateRule, onEditRule }) {
|
|
9
|
+
const updateReplicationMutation = useSetBucketReplication();
|
|
10
|
+
const deleteReplicationMutation = useDeleteBucketReplication();
|
|
11
|
+
const columns = useMemo(()=>[
|
|
12
|
+
{
|
|
13
|
+
Header: "Rule ID",
|
|
14
|
+
accessor: "ID",
|
|
15
|
+
id: "id",
|
|
16
|
+
Cell: ({ value })=>/*#__PURE__*/ jsx(ConstrainedText, {
|
|
17
|
+
text: value || "-",
|
|
18
|
+
lineClamp: 2
|
|
19
|
+
}),
|
|
20
|
+
cellStyle: {
|
|
21
|
+
flex: "1",
|
|
22
|
+
width: "unset"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
Header: "Status",
|
|
27
|
+
accessor: "Status",
|
|
28
|
+
id: "status",
|
|
29
|
+
Cell: ({ value })=>{
|
|
30
|
+
const statusText = "Enabled" === value ? "Active" : "Disabled" === value ? "Inactive" : value;
|
|
31
|
+
return /*#__PURE__*/ jsx("span", {
|
|
32
|
+
children: statusText || "-"
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
cellStyle: {
|
|
36
|
+
width: "unset",
|
|
37
|
+
flex: "0.5"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
Header: "Priority",
|
|
42
|
+
accessor: "Priority",
|
|
43
|
+
id: "priority",
|
|
44
|
+
Cell: ({ value })=>/*#__PURE__*/ jsx("span", {
|
|
45
|
+
children: void 0 !== value ? value : "None"
|
|
46
|
+
}),
|
|
47
|
+
cellStyle: {
|
|
48
|
+
width: "unset",
|
|
49
|
+
flex: "0.5",
|
|
50
|
+
textAlign: "right",
|
|
51
|
+
paddingRight: spacing.r16
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
Header: "Destination",
|
|
56
|
+
accessor: "Destination",
|
|
57
|
+
id: "destination",
|
|
58
|
+
Cell: ({ row })=>{
|
|
59
|
+
const rule = row.original.Rule;
|
|
60
|
+
const destination = rule.Destination;
|
|
61
|
+
const bucketArn = destination?.Bucket || "";
|
|
62
|
+
const accountMatch = bucketArn.match(/arn:aws:s3:::([^:]+):([^:]+)/);
|
|
63
|
+
let bucketName;
|
|
64
|
+
let accountId;
|
|
65
|
+
if (accountMatch) {
|
|
66
|
+
accountId = accountMatch[1];
|
|
67
|
+
bucketName = accountMatch[2];
|
|
68
|
+
} else {
|
|
69
|
+
const parts = bucketArn.split(":::");
|
|
70
|
+
bucketName = parts[parts.length - 1] || bucketArn;
|
|
71
|
+
accountId = null;
|
|
72
|
+
}
|
|
73
|
+
const shortAccountId = accountId ? `${accountId.slice(0, 3)}...${accountId.slice(-3)}` : null;
|
|
74
|
+
const storageClass = destination?.StorageClass;
|
|
75
|
+
let displayText = `Replicate to ${bucketName}`;
|
|
76
|
+
const details = [];
|
|
77
|
+
if (shortAccountId) details.push(`account: ${shortAccountId}`);
|
|
78
|
+
if (storageClass) details.push(storageClass);
|
|
79
|
+
if (details.length > 0) displayText += ` (${details.join(", ")})`;
|
|
80
|
+
return /*#__PURE__*/ jsx(ConstrainedText, {
|
|
81
|
+
text: displayText || "-",
|
|
82
|
+
lineClamp: 2
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
cellStyle: {
|
|
86
|
+
width: "unset",
|
|
87
|
+
flex: "1.5"
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
Header: "",
|
|
92
|
+
accessor: "ID",
|
|
93
|
+
id: "operations",
|
|
94
|
+
cellStyle: {
|
|
95
|
+
flex: "0.5",
|
|
96
|
+
textAlign: "right",
|
|
97
|
+
paddingRight: spacing.r16,
|
|
98
|
+
width: "unset"
|
|
99
|
+
},
|
|
100
|
+
Cell: ({ value })=>/*#__PURE__*/ jsxs(Box, {
|
|
101
|
+
display: "flex",
|
|
102
|
+
gap: spacing.r8,
|
|
103
|
+
justifyContent: "flex-end",
|
|
104
|
+
children: [
|
|
105
|
+
/*#__PURE__*/ jsx(Button, {
|
|
106
|
+
icon: /*#__PURE__*/ jsx(Icon, {
|
|
107
|
+
name: "Edit"
|
|
108
|
+
}),
|
|
109
|
+
variant: "secondary",
|
|
110
|
+
type: "button",
|
|
111
|
+
onClick: (e)=>{
|
|
112
|
+
e.stopPropagation();
|
|
113
|
+
onEditRule?.(value);
|
|
114
|
+
},
|
|
115
|
+
"aria-label": "Edit rule",
|
|
116
|
+
tooltip: {
|
|
117
|
+
overlay: "Edit rule"
|
|
118
|
+
}
|
|
119
|
+
}),
|
|
120
|
+
/*#__PURE__*/ jsx(DeleteBucketConfigRuleButton, {
|
|
121
|
+
bucketName: bucketName,
|
|
122
|
+
ruleId: value,
|
|
123
|
+
rules: replicationRules,
|
|
124
|
+
ruleType: "replication",
|
|
125
|
+
updateMutation: updateReplicationMutation,
|
|
126
|
+
deleteMutation: deleteReplicationMutation,
|
|
127
|
+
buildUpdateInput: (remainingRules)=>({
|
|
128
|
+
ReplicationConfiguration: {
|
|
129
|
+
Role: replicationRole,
|
|
130
|
+
Rules: remainingRules
|
|
131
|
+
}
|
|
132
|
+
}),
|
|
133
|
+
successMessage: "Replication rule deleted successfully",
|
|
134
|
+
errorMessage: "Failed to delete replication rule"
|
|
135
|
+
})
|
|
136
|
+
]
|
|
137
|
+
})
|
|
138
|
+
}
|
|
139
|
+
], [
|
|
140
|
+
bucketName,
|
|
141
|
+
replicationRules,
|
|
142
|
+
replicationRole,
|
|
143
|
+
onEditRule,
|
|
144
|
+
updateReplicationMutation,
|
|
145
|
+
deleteReplicationMutation
|
|
146
|
+
]);
|
|
147
|
+
const tableData = useMemo(()=>replicationRules.map((rule)=>({
|
|
148
|
+
ID: rule.ID || "-",
|
|
149
|
+
Status: rule.Status || "-",
|
|
150
|
+
Priority: rule.Priority,
|
|
151
|
+
Destination: rule.Destination?.Bucket || "-",
|
|
152
|
+
Rule: rule
|
|
153
|
+
})), [
|
|
154
|
+
replicationRules
|
|
155
|
+
]);
|
|
156
|
+
const { selectedId, onRowSelected } = useTableRowSelection(tableData);
|
|
157
|
+
return /*#__PURE__*/ jsxs(Table, {
|
|
158
|
+
columns: columns,
|
|
159
|
+
data: tableData,
|
|
160
|
+
status: replicationStatus,
|
|
161
|
+
defaultSortingKey: "priority",
|
|
162
|
+
entityName: {
|
|
163
|
+
en: {
|
|
164
|
+
singular: "replication rule",
|
|
165
|
+
plural: "replication rules"
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
children: [
|
|
169
|
+
/*#__PURE__*/ jsx(Wrap, {
|
|
170
|
+
padding: spacing.r16,
|
|
171
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
172
|
+
icon: /*#__PURE__*/ jsx(Icon, {
|
|
173
|
+
name: "Create-add"
|
|
174
|
+
}),
|
|
175
|
+
label: "Create Rule",
|
|
176
|
+
variant: "primary",
|
|
177
|
+
onClick: onCreateRule
|
|
178
|
+
})
|
|
179
|
+
}),
|
|
180
|
+
/*#__PURE__*/ jsx(Table.SingleSelectableContent, {
|
|
181
|
+
rowHeight: "h48",
|
|
182
|
+
separationLineVariant: "backgroundLevel1",
|
|
183
|
+
selectedId: selectedId?.toString(),
|
|
184
|
+
onRowSelected: onRowSelected
|
|
185
|
+
})
|
|
186
|
+
]
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
export { BucketReplicationList };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { UseMutationResult } from "@tanstack/react-query";
|
|
2
|
+
interface DeleteBucketConfigRuleButtonProps<TRule extends {
|
|
3
|
+
ID?: string;
|
|
4
|
+
}> {
|
|
5
|
+
bucketName: string;
|
|
6
|
+
ruleId: string;
|
|
7
|
+
rules: TRule[];
|
|
8
|
+
ruleType: "lifecycle" | "replication";
|
|
9
|
+
updateMutation: UseMutationResult<any, any, any, unknown>;
|
|
10
|
+
deleteMutation: UseMutationResult<any, any, any, unknown>;
|
|
11
|
+
buildUpdateInput: (remainingRules: TRule[]) => Record<string, any>;
|
|
12
|
+
successMessage: string;
|
|
13
|
+
errorMessage: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function DeleteBucketConfigRuleButton<TRule extends {
|
|
16
|
+
ID?: string;
|
|
17
|
+
}>({ bucketName, ruleId, rules, ruleType, updateMutation, deleteMutation, buildUpdateInput, successMessage, errorMessage, }: DeleteBucketConfigRuleButtonProps<TRule>): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Icon } from "@scality/core-ui";
|
|
4
|
+
import { Button } from "@scality/core-ui/dist/next";
|
|
5
|
+
import { useDeleteBucketConfigRule } from "../../hooks/useDeleteBucketConfigRule.js";
|
|
6
|
+
import { ConfirmDeleteRuleModal } from "../ui/ConfirmDeleteRuleModal.js";
|
|
7
|
+
function DeleteBucketConfigRuleButton({ bucketName, ruleId, rules, ruleType, updateMutation, deleteMutation, buildUpdateInput, successMessage, errorMessage }) {
|
|
8
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
9
|
+
const { isDeleting, deleteRule } = useDeleteBucketConfigRule({
|
|
10
|
+
bucketName,
|
|
11
|
+
ruleId,
|
|
12
|
+
rules,
|
|
13
|
+
updateMutation,
|
|
14
|
+
deleteMutation,
|
|
15
|
+
buildUpdateInput,
|
|
16
|
+
successMessage,
|
|
17
|
+
errorMessage,
|
|
18
|
+
onSuccess: ()=>{
|
|
19
|
+
setIsModalOpen(false);
|
|
20
|
+
},
|
|
21
|
+
onError: ()=>{
|
|
22
|
+
setIsModalOpen(false);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
26
|
+
children: [
|
|
27
|
+
/*#__PURE__*/ jsx(Button, {
|
|
28
|
+
icon: /*#__PURE__*/ jsx(Icon, {
|
|
29
|
+
name: "Delete"
|
|
30
|
+
}),
|
|
31
|
+
variant: "secondary",
|
|
32
|
+
type: "button",
|
|
33
|
+
onClick: (e)=>{
|
|
34
|
+
e.stopPropagation();
|
|
35
|
+
setIsModalOpen(true);
|
|
36
|
+
},
|
|
37
|
+
"aria-label": "Delete rule",
|
|
38
|
+
tooltip: {
|
|
39
|
+
overlay: "Delete rule"
|
|
40
|
+
}
|
|
41
|
+
}),
|
|
42
|
+
/*#__PURE__*/ jsx(ConfirmDeleteRuleModal, {
|
|
43
|
+
isOpen: isModalOpen,
|
|
44
|
+
ruleId: ruleId,
|
|
45
|
+
ruleType: ruleType,
|
|
46
|
+
isDeleting: isDeleting,
|
|
47
|
+
onConfirm: deleteRule,
|
|
48
|
+
onCancel: ()=>setIsModalOpen(false)
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export { DeleteBucketConfigRuleButton };
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Banner, Icon, Loader, Modal, Stack, Text, Tooltip, Wrap } from "@scality/core-ui";
|
|
3
|
+
import { Box, Button } from "@scality/core-ui/dist/next";
|
|
4
|
+
import { Input } from "@scality/core-ui/dist/components/inputv2/inputv2";
|
|
5
|
+
import { useMemo, useState } from "react";
|
|
6
|
+
import { useIsBucketEmpty } from "../../hooks/useIsBucketEmpty.js";
|
|
7
|
+
import { useEmptyBucket } from "../../hooks/useEmptyBucket.js";
|
|
8
|
+
import { useGetBucketObjectLockConfiguration } from "../../hooks/bucketConfiguration.js";
|
|
9
|
+
import styled_components from "styled-components";
|
|
10
|
+
import { EmptyBucketSummary } from "./EmptyBucketSummary.js";
|
|
11
|
+
const MAX_OBJECTS_TO_DELETE = 20000;
|
|
12
|
+
const CustomListItem = styled_components.li`
|
|
13
|
+
padding: 0.5rem;
|
|
14
|
+
`;
|
|
15
|
+
const emptyBucketInfosList = [
|
|
16
|
+
"Emptying a bucket removes all contents and cannot be reversed.",
|
|
17
|
+
"New objects added during the empty action may also be removed.",
|
|
18
|
+
"Adjust workflows linked to this bucket to avoid adding objects during the emptying action."
|
|
19
|
+
];
|
|
20
|
+
const RetentionText = ()=>/*#__PURE__*/ jsx(Text, {
|
|
21
|
+
children: "If some of the objects you are trying to delete are locked in governance mode, confirming the deletion will effectively delete them as the governance retention will be bypassed."
|
|
22
|
+
});
|
|
23
|
+
const LifecycleText = ()=>/*#__PURE__*/ jsx(Text, {
|
|
24
|
+
children: "The action of emptying can erase a maximum of 20,000 objects. For buckets with a substantial number of objects, an expiration workflow (lifecycle rule) could provide an effective alternative to emptying the bucket."
|
|
25
|
+
});
|
|
26
|
+
const EmptyBucketButton = ({ bucketName })=>{
|
|
27
|
+
const [confirmText, setConfirmText] = useState("");
|
|
28
|
+
const [isEmptyModalOpen, setIsEmptyModalOpen] = useState(false);
|
|
29
|
+
const [showSummary, setShowSummary] = useState(false);
|
|
30
|
+
const { isEmpty, isLoading: isCheckingEmpty } = useIsBucketEmpty(bucketName);
|
|
31
|
+
const { data: objectLockData } = useGetBucketObjectLockConfiguration({
|
|
32
|
+
Bucket: bucketName
|
|
33
|
+
});
|
|
34
|
+
const isObjectLockEnabled = objectLockData?.ObjectLockConfiguration?.ObjectLockEnabled === "Enabled";
|
|
35
|
+
const { emptyBucket, isEmptying, error, result, reset } = useEmptyBucket({
|
|
36
|
+
maxObjects: MAX_OBJECTS_TO_DELETE,
|
|
37
|
+
bypassGovernanceRetention: true
|
|
38
|
+
});
|
|
39
|
+
const isConfirmed = confirmText === bucketName;
|
|
40
|
+
const deleteResultForSummary = useMemo(()=>{
|
|
41
|
+
if (!result) return;
|
|
42
|
+
return {
|
|
43
|
+
$metadata: {},
|
|
44
|
+
Deleted: Array.from({
|
|
45
|
+
length: result.deletedCount
|
|
46
|
+
}, (_, i)=>({
|
|
47
|
+
Key: `object-${i}`,
|
|
48
|
+
VersionId: void 0
|
|
49
|
+
})),
|
|
50
|
+
Errors: result.errors.map((error)=>({
|
|
51
|
+
Key: error.key,
|
|
52
|
+
Code: error.code,
|
|
53
|
+
Message: error.message
|
|
54
|
+
}))
|
|
55
|
+
};
|
|
56
|
+
}, [
|
|
57
|
+
result
|
|
58
|
+
]);
|
|
59
|
+
const handleEmptyBucket = async ()=>{
|
|
60
|
+
const bucketResult = await emptyBucket(bucketName);
|
|
61
|
+
if (bucketResult) {
|
|
62
|
+
setIsEmptyModalOpen(false);
|
|
63
|
+
setShowSummary(true);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const handleCloseSummary = ()=>{
|
|
67
|
+
setShowSummary(false);
|
|
68
|
+
setConfirmText("");
|
|
69
|
+
reset();
|
|
70
|
+
};
|
|
71
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
72
|
+
children: [
|
|
73
|
+
/*#__PURE__*/ jsx(Tooltip, {
|
|
74
|
+
overlay: isCheckingEmpty ? "Checking if bucket is empty" : "Bucket is already empty",
|
|
75
|
+
overlayStyle: {
|
|
76
|
+
width: "9rem",
|
|
77
|
+
display: isEmpty ? void 0 : "none"
|
|
78
|
+
},
|
|
79
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
80
|
+
icon: /*#__PURE__*/ jsx(Icon, {
|
|
81
|
+
name: "Eraser"
|
|
82
|
+
}),
|
|
83
|
+
disabled: Boolean(isEmpty) || isCheckingEmpty,
|
|
84
|
+
variant: "danger",
|
|
85
|
+
onClick: ()=>setIsEmptyModalOpen(true),
|
|
86
|
+
label: "Empty Bucket",
|
|
87
|
+
style: {
|
|
88
|
+
marginRight: "1rem"
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
}),
|
|
92
|
+
/*#__PURE__*/ jsx(Modal, {
|
|
93
|
+
isOpen: isEmptyModalOpen,
|
|
94
|
+
title: `Empty Bucket '${bucketName}'?`,
|
|
95
|
+
close: ()=>{
|
|
96
|
+
if (!isEmptying) {
|
|
97
|
+
setIsEmptyModalOpen(false);
|
|
98
|
+
setConfirmText("");
|
|
99
|
+
reset();
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
footer: /*#__PURE__*/ jsxs(Wrap, {
|
|
103
|
+
children: [
|
|
104
|
+
isEmptying && /*#__PURE__*/ jsx(Text, {
|
|
105
|
+
variant: "Larger",
|
|
106
|
+
children: result?.deletedCount ? `${result?.deletedCount} deletion attempts...` : "Deletion in progress..."
|
|
107
|
+
}),
|
|
108
|
+
/*#__PURE__*/ jsx("p", {}),
|
|
109
|
+
/*#__PURE__*/ jsxs(Stack, {
|
|
110
|
+
children: [
|
|
111
|
+
/*#__PURE__*/ jsx(Button, {
|
|
112
|
+
variant: "outline",
|
|
113
|
+
onClick: ()=>{
|
|
114
|
+
setIsEmptyModalOpen(false);
|
|
115
|
+
setConfirmText("");
|
|
116
|
+
reset();
|
|
117
|
+
},
|
|
118
|
+
label: "Cancel",
|
|
119
|
+
disabled: isEmptying
|
|
120
|
+
}),
|
|
121
|
+
/*#__PURE__*/ jsx(Button, {
|
|
122
|
+
disabled: !isConfirmed || isEmptying,
|
|
123
|
+
variant: "danger",
|
|
124
|
+
onClick: handleEmptyBucket,
|
|
125
|
+
icon: isEmptying ? /*#__PURE__*/ jsx(Loader, {
|
|
126
|
+
size: "larger"
|
|
127
|
+
}) : /*#__PURE__*/ jsx(Icon, {
|
|
128
|
+
name: "Eraser"
|
|
129
|
+
}),
|
|
130
|
+
label: "Empty"
|
|
131
|
+
})
|
|
132
|
+
]
|
|
133
|
+
})
|
|
134
|
+
]
|
|
135
|
+
}),
|
|
136
|
+
children: /*#__PURE__*/ jsxs(Box, {
|
|
137
|
+
maxWidth: "35rem",
|
|
138
|
+
children: [
|
|
139
|
+
error && /*#__PURE__*/ jsxs(Fragment, {
|
|
140
|
+
children: [
|
|
141
|
+
/*#__PURE__*/ jsx(Banner, {
|
|
142
|
+
variant: "danger",
|
|
143
|
+
icon: /*#__PURE__*/ jsx(Icon, {
|
|
144
|
+
name: "Exclamation-circle",
|
|
145
|
+
color: "statusCritical"
|
|
146
|
+
}),
|
|
147
|
+
title: "Error",
|
|
148
|
+
children: error.message
|
|
149
|
+
}),
|
|
150
|
+
/*#__PURE__*/ jsx("br", {})
|
|
151
|
+
]
|
|
152
|
+
}),
|
|
153
|
+
isObjectLockEnabled && /*#__PURE__*/ jsxs(Fragment, {
|
|
154
|
+
children: [
|
|
155
|
+
/*#__PURE__*/ jsx(Banner, {
|
|
156
|
+
icon: /*#__PURE__*/ jsx(Box, {
|
|
157
|
+
display: "flex",
|
|
158
|
+
alignItems: "center",
|
|
159
|
+
marginLeft: "0.571rem",
|
|
160
|
+
children: /*#__PURE__*/ jsx(Icon, {
|
|
161
|
+
name: "Exclamation-circle",
|
|
162
|
+
color: "statusWarning",
|
|
163
|
+
size: "lg"
|
|
164
|
+
})
|
|
165
|
+
}),
|
|
166
|
+
variant: "warning",
|
|
167
|
+
children: /*#__PURE__*/ jsx(RetentionText, {})
|
|
168
|
+
}),
|
|
169
|
+
/*#__PURE__*/ jsx("br", {})
|
|
170
|
+
]
|
|
171
|
+
}),
|
|
172
|
+
/*#__PURE__*/ jsx("ul", {
|
|
173
|
+
style: {
|
|
174
|
+
padding: "2rem"
|
|
175
|
+
},
|
|
176
|
+
children: emptyBucketInfosList.map((listInfo, i)=>/*#__PURE__*/ jsx(CustomListItem, {
|
|
177
|
+
children: listInfo
|
|
178
|
+
}, i))
|
|
179
|
+
}),
|
|
180
|
+
/*#__PURE__*/ jsx(Banner, {
|
|
181
|
+
icon: /*#__PURE__*/ jsx("div", {
|
|
182
|
+
style: {
|
|
183
|
+
display: "flex",
|
|
184
|
+
alignItems: "center",
|
|
185
|
+
marginLeft: "0.571rem"
|
|
186
|
+
},
|
|
187
|
+
children: /*#__PURE__*/ jsx(Icon, {
|
|
188
|
+
name: "Info-circle",
|
|
189
|
+
size: "lg"
|
|
190
|
+
})
|
|
191
|
+
}),
|
|
192
|
+
variant: "base",
|
|
193
|
+
children: /*#__PURE__*/ jsx(LifecycleText, {})
|
|
194
|
+
}),
|
|
195
|
+
/*#__PURE__*/ jsx("br", {}),
|
|
196
|
+
/*#__PURE__*/ jsxs(Box, {
|
|
197
|
+
display: "flex",
|
|
198
|
+
alignItems: "center",
|
|
199
|
+
paddingTop: "1rem",
|
|
200
|
+
children: [
|
|
201
|
+
/*#__PURE__*/ jsx("label", {
|
|
202
|
+
style: {
|
|
203
|
+
float: "left",
|
|
204
|
+
marginRight: "1rem"
|
|
205
|
+
},
|
|
206
|
+
children: "Type the name of the bucket to delete all its content."
|
|
207
|
+
}),
|
|
208
|
+
/*#__PURE__*/ jsx(Input, {
|
|
209
|
+
id: "confirm-input",
|
|
210
|
+
"aria-label": "confirm",
|
|
211
|
+
autoFocus: isEmptyModalOpen,
|
|
212
|
+
placeholder: bucketName,
|
|
213
|
+
type: "text",
|
|
214
|
+
value: confirmText,
|
|
215
|
+
onChange: (e)=>setConfirmText(e.target.value),
|
|
216
|
+
disabled: isEmptying
|
|
217
|
+
})
|
|
218
|
+
]
|
|
219
|
+
})
|
|
220
|
+
]
|
|
221
|
+
})
|
|
222
|
+
}),
|
|
223
|
+
deleteResultForSummary && /*#__PURE__*/ jsx(EmptyBucketSummary, {
|
|
224
|
+
deleteResult: deleteResultForSummary,
|
|
225
|
+
close: handleCloseSummary,
|
|
226
|
+
open: showSummary,
|
|
227
|
+
isFetchNextPage: !result?.limitReached
|
|
228
|
+
})
|
|
229
|
+
]
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
export { EmptyBucketButton };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DeleteObjectsCommandOutput } from "@aws-sdk/client-s3";
|
|
2
|
+
interface EmptyBucketSummaryProps {
|
|
3
|
+
deleteResult: DeleteObjectsCommandOutput;
|
|
4
|
+
close: () => void;
|
|
5
|
+
open: boolean;
|
|
6
|
+
isFetchNextPage: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const EmptyBucketSummary: ({ deleteResult, close, open, isFetchNextPage, }: EmptyBucketSummaryProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Banner, Icon, Modal, Wrap } from "@scality/core-ui";
|
|
3
|
+
import { Button } from "@scality/core-ui/dist/next";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { EmptyBucketSummaryList } from "./EmptyBucketSummaryList.js";
|
|
6
|
+
const useCreateDeleteSummaryData = (deleteResult)=>useMemo(()=>{
|
|
7
|
+
const deleteSummaryData = [
|
|
8
|
+
{
|
|
9
|
+
attempts: (deleteResult.Deleted?.length || 0) + (deleteResult.Errors?.length || 0),
|
|
10
|
+
deleted: deleteResult.Deleted?.length || 0,
|
|
11
|
+
errors: {
|
|
12
|
+
nbErrors: deleteResult.Errors?.length || 0,
|
|
13
|
+
messages: deleteResult.Errors?.map((error)=>error.Message || "") || []
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
];
|
|
17
|
+
return deleteSummaryData;
|
|
18
|
+
}, [
|
|
19
|
+
deleteResult
|
|
20
|
+
]);
|
|
21
|
+
const EmptyBucketSummary = ({ deleteResult, close, open, isFetchNextPage })=>{
|
|
22
|
+
const deleteSummaryData = useCreateDeleteSummaryData(deleteResult);
|
|
23
|
+
return /*#__PURE__*/ jsx(Modal, {
|
|
24
|
+
title: "Summary",
|
|
25
|
+
close: close,
|
|
26
|
+
isOpen: open,
|
|
27
|
+
footer: /*#__PURE__*/ jsxs(Wrap, {
|
|
28
|
+
children: [
|
|
29
|
+
/*#__PURE__*/ jsx("p", {}),
|
|
30
|
+
/*#__PURE__*/ jsx(Button, {
|
|
31
|
+
variant: "primary",
|
|
32
|
+
onClick: close,
|
|
33
|
+
label: "Close"
|
|
34
|
+
})
|
|
35
|
+
]
|
|
36
|
+
}),
|
|
37
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
38
|
+
children: [
|
|
39
|
+
!isFetchNextPage && /*#__PURE__*/ jsxs(Fragment, {
|
|
40
|
+
children: [
|
|
41
|
+
/*#__PURE__*/ jsx(Banner, {
|
|
42
|
+
variant: "danger",
|
|
43
|
+
icon: /*#__PURE__*/ jsx(Icon, {
|
|
44
|
+
name: "Exclamation-circle",
|
|
45
|
+
color: "statusCritical"
|
|
46
|
+
}),
|
|
47
|
+
title: "Error",
|
|
48
|
+
children: "Your bucket contains too many objects. We can delete up to 20 000 objects."
|
|
49
|
+
}),
|
|
50
|
+
/*#__PURE__*/ jsx("br", {})
|
|
51
|
+
]
|
|
52
|
+
}),
|
|
53
|
+
/*#__PURE__*/ jsx(EmptyBucketSummaryList, {
|
|
54
|
+
summaryData: deleteSummaryData
|
|
55
|
+
})
|
|
56
|
+
]
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
export { EmptyBucketSummary };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface DeleteSummaryData extends Record<string, unknown> {
|
|
2
|
+
attempts: number;
|
|
3
|
+
deleted: number;
|
|
4
|
+
errors: {
|
|
5
|
+
nbErrors: number;
|
|
6
|
+
messages: string[];
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
interface EmptyBucketSummaryListProps {
|
|
10
|
+
summaryData: DeleteSummaryData[];
|
|
11
|
+
}
|
|
12
|
+
export declare const EmptyBucketSummaryList: ({ summaryData, }: EmptyBucketSummaryListProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|