fix(editor): confirm unsaved structure changes

This commit is contained in:
t8y2 committed 2026-07-13 21:27:02 +08:00
1 parent 032a8d0f80
commit 8f619fb791
6 files changed
+161 -12

No files matched your search

@@ -893,6 +893,7 @@ function onStructureContentScroll(tab: TableInfoTab, event: Event) {
function createCurrentDraft(initialized = true): TableStructureEditorDraft {
return {
dirty: hasPendingStructureChanges(),
activeTab: activeTab.value as TableStructureEditorDraft["activeTab"],
newTableName: newTableName.value,
tableComment: tableComment.value,
@@ -2145,7 +2146,7 @@ function toggleSqlPreviewCollapsed() {
}
async function applyChanges() {
if (!canApply.value || !props.connectionId || !props.database) return;
if (!canApply.value || !props.connectionId || !props.database) return false;
const sql = previewSqlText.value;
const connection = store.getConfig(props.connectionId);
const productionContext = productionContextForDatabase(connection, props.database);
@@ -2157,7 +2158,7 @@ async function applyChanges() {
productionDatabases: productionContext.databases,
source: t("production.sourceStructure"),
});
if (!confirmed) return;
if (!confirmed) return false;
}
saving.value = true;
errorMessage.value = "";
@@ -2185,16 +2186,20 @@ async function applyChanges() {
postSaveRefreshing.value = true;
skipNextRefreshVersion = true;
emit("saved", tableComment.value !== originalTableComment.value);
void refreshStructureAfterSave(refreshScope);
await refreshStructureAfterSave(refreshScope);
}
return true;
} catch (e: any) {
errorMessage.value = e?.message || String(e);
await recordStructureHistory(sql, startedAt, false, undefined, errorMessage.value);
return false;
} finally {
saving.value = false;
}
}
defineExpose({ applyChanges });
function addItemForActiveTab(): boolean {
if (activeTab.value === "columns" && canAddColumn.value) {
void addColumn();