Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: handle delete local datasource correctly (#7563)

Liu Ji1174177a225c
diff --git a/frontend/src/components/InstanceForm/DataSourceSection/DataSourceTabs.vue b/frontend/src/components/InstanceForm/DataSourceSection/DataSourceTabs.vue
index 8e35b56805..b4b20fcfca 100644
--- a/frontend/src/components/InstanceForm/DataSourceSection/DataSourceTabs.vue
+++ b/frontend/src/components/InstanceForm/DataSourceSection/DataSourceTabs.vue
@@ -72,16 +72,18 @@ const {
const handleDeleteDataSource = async (ds: EditDataSource) => {
const removeLocalEditDataSource = (ds: EditDataSource) => {
const { dataSources, editingDataSourceId } = dataSourceEditState.value;
- if (ds.id !== editingDataSourceId) {
- return;
- }
const index = dataSources.findIndex((d) => d.id === ds.id);
if (index >= 0) {
pullAt(dataSources, index);
}
- const siblingIndex = Math.min(index, dataSources.length - 1);
- const siblingDataSource = dataSources[siblingIndex];
- dataSourceEditState.value.editingDataSourceId = siblingDataSource?.id;
+
+ if (ds.id === editingDataSourceId) {
+ // When the current editing datasource is deleted
+ // Switch to its sibling
+ const siblingIndex = Math.min(index, dataSources.length - 1);
+ const siblingDataSource = dataSources[siblingIndex];
+ dataSourceEditState.value.editingDataSourceId = siblingDataSource?.id;
+ }
};
if (instance.value && !ds.pendingCreate) {