feat(vector): support renaming Milvus collections
This commit is contained in:
1 parent
4b75334164
commit
52c892676c
16 files changed
+461
-102
No files matched your search
@@ -136,8 +136,12 @@ export function useSidebarDatabaseSpecificMutationRuntime(options: SidebarDataba
|
||||
return usesAnyMongoDriver(node);
|
||||
}
|
||||
|
||||
function canMutateMilvusCollectionNode(node: TreeNode): boolean {
|
||||
return node.type === "vector-collection" && !!node.connectionId && !!node.database && connectionStore.getConfig(node.connectionId)?.db_type === "milvus";
|
||||
}
|
||||
|
||||
function canRenameMongoCollectionNode(node: TreeNode): boolean {
|
||||
return canMutateMongoCollectionNode(node) && usesNativeMongoDriver(node) && isRenamableMongoCollection(node.label, mongoCollectionKindFromNode(node));
|
||||
return canMutateMilvusCollectionNode(node) || (canMutateMongoCollectionNode(node) && usesNativeMongoDriver(node) && isRenamableMongoCollection(node.label, mongoCollectionKindFromNode(node)));
|
||||
}
|
||||
|
||||
function canCloneMongoCollectionNode(node: TreeNode): boolean {
|
||||
@@ -169,7 +173,7 @@ export function useSidebarDatabaseSpecificMutationRuntime(options: SidebarDataba
|
||||
renameMongoCollectionPreview.value = "";
|
||||
return;
|
||||
}
|
||||
renameMongoCollectionPreview.value = mongoRenameCollectionPreview(node.database, node.label, newName);
|
||||
renameMongoCollectionPreview.value = canMutateMilvusCollectionNode(node) ? `POST /v2/vectordb/collections/rename\n${JSON.stringify({ dbName: node.database, collectionName: node.label, newCollectionName: newName })}` : mongoRenameCollectionPreview(node.database, node.label, newName);
|
||||
}
|
||||
|
||||
watch([showRenameMongoCollectionDialog, renameMongoCollectionName, () => activeNode.value.label, () => activeNode.value.database], () => {
|
||||
@@ -189,17 +193,37 @@ export function useSidebarDatabaseSpecificMutationRuntime(options: SidebarDataba
|
||||
await runMongoSidebarMutation({
|
||||
connection: connectionStore.getConfig(connectionId),
|
||||
database,
|
||||
reviewText: mongoRenameCollectionPreview(database, oldName, newName),
|
||||
reviewText: canMutateMilvusCollectionNode(node) ? `POST /v2/vectordb/collections/rename\n${JSON.stringify({ dbName: database, collectionName: oldName, newCollectionName: newName })}` : mongoRenameCollectionPreview(database, oldName, newName),
|
||||
source: t("production.sourceSidebar"),
|
||||
loading: renameMongoCollectionLoading,
|
||||
beforeExecute: () => connectionStore.ensureConnected(connectionId),
|
||||
execute: async () => {
|
||||
await api.mongoRenameCollection(connectionId, database, oldName, newName);
|
||||
await connectionStore.loadMongoCollections(connectionId, database);
|
||||
if (canMutateMilvusCollectionNode(node)) {
|
||||
await api.vectorRenameCollection(connectionId, database, oldName, newName);
|
||||
} else {
|
||||
await api.mongoRenameCollection(connectionId, database, oldName, newName);
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
onSuccess: async () => {
|
||||
toast(t("contextMenu.renameObjectSuccess", { oldName, newName }), 3000);
|
||||
showRenameMongoCollectionDialog.value = false;
|
||||
try {
|
||||
if (canMutateMilvusCollectionNode(node)) {
|
||||
await connectionStore.loadVectorCollections(connectionId, database);
|
||||
connectionStore.replacePinnedTreeNode(node, {
|
||||
...node,
|
||||
id: `${connectionId}:__vector_collection:${database}:${newName}`,
|
||||
label: newName,
|
||||
objectName: newName,
|
||||
tableName: newName,
|
||||
});
|
||||
} else {
|
||||
await connectionStore.loadMongoCollections(connectionId, database);
|
||||
}
|
||||
} catch (error) {
|
||||
connectionStore.removeTreeNode(node.id);
|
||||
toast(t("contextMenu.objectDropRefreshFailed", { message: translateBackendError(t, errorMessage(error)) }), 5000);
|
||||
}
|
||||
},
|
||||
onError: (error) => {
|
||||
renameMongoCollectionError.value = translateBackendError(t, errorMessage(error));
|
||||
|
||||
Reference in new issue
Block a user