Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: can not delete multiple entities #749

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/src/i18n/cn/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const dialogTrans = {
deleteTipAction: '输入',
deleteTipPurpose: '以确认。',
deleteTitle: `删除 {{type}}`,
deleteEntityTitle: `删除 Entity`,
renameTitle: `重命名 {{type}}`,
releaseTitle: `发布 {{type}}`,
duplicateTitle: `复制 {{type}}`,
Expand Down
1 change: 1 addition & 0 deletions client/src/i18n/en/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const dialogTrans = {
deleteTipAction: 'Type',
deleteTipPurpose: 'to confirm.',
deleteTitle: `Drop {{type}}`,
deleteEntityTitle: `Delete Entity`,
renameTitle: `Rename {{type}}`,
releaseTitle: `Release {{type}}`,
duplicateTitle: `Duplicate {{type}}`,
Expand Down
57 changes: 32 additions & 25 deletions client/src/pages/databases/collections/data/CollectionData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,27 +107,14 @@ const CollectionData = (props: CollectionDataProps) => {
setSelectedData(value);
};
const onDelete = async () => {
// reset query
// clear selection
setSelectedData([]);
// reset();
reset();
// update count
count(ConsistencyLevelEnum.Strong);
await query(0, ConsistencyLevelEnum.Strong);
};
const handleDelete = async () => {
// call delete api
await DataService.deleteEntities(collection.collection_name, {
expr: `${collection!.schema.primaryField.name} in [${selectedData
.map(v =>
collection!.schema.primaryField.data_type ===
DataTypeStringEnum.VarChar
? `"${v[collection!.schema.primaryField.name]}"`
: v[collection!.schema.primaryField.name]
)
.join(',')}]`,
});
handleCloseDialog();
openSnackBar(successTrans('delete', { name: collectionTrans('entities') }));
setSelectedData([]);
await onDelete();
// update query
query(0, ConsistencyLevelEnum.Strong);
};

// Query hook
Expand Down Expand Up @@ -342,12 +329,32 @@ const CollectionData = (props: CollectionDataProps) => {
params: {
component: (
<DeleteTemplate
label={btnTrans('drop')}
title={dialogTrans('deleteTitle', {
type: collectionTrans('entities'),
})}
label={btnTrans('delete')}
title={dialogTrans('deleteEntityTitle')}
text={collectionTrans('deleteDataWarning')}
handleDelete={handleDelete}
handleDelete={async () => {
// call delete api
await DataService.deleteEntities(collection.collection_name, {
expr: `${
collection!.schema.primaryField.name
} in [${selectedData
.map(v =>
collection!.schema.primaryField.data_type ===
DataTypeStringEnum.VarChar
? `"${v[collection!.schema.primaryField.name]}"`
: v[collection!.schema.primaryField.name]
)
.join(',')}]`,
});
handleCloseDialog();
openSnackBar(
successTrans('delete', {
name: collectionTrans('entities'),
})
);
setSelectedData([]);
await onDelete();
}}
/>
),
},
Expand All @@ -357,7 +364,7 @@ const CollectionData = (props: CollectionDataProps) => {
icon: 'delete',
tooltip: btnTrans('deleteTooltip'),
disabledTooltip: collectionTrans('deleteDisabledTooltip'),
disabled: () => selectedData.length === 0,
disabled: () => !selectedData?.length,
},
];

Expand Down
Loading