fix(sidebar): preserve dirty procedure source tabs

This commit is contained in:
Melody Ruch authored and GitHub committed 2026-08-12 21:06:13 +08:00
1 parent 9b24d962bb
commit a9194ba3b5
4 files changed
+121 -13

No files matched your search

@@ -1813,15 +1813,24 @@ function openObjectSourceDialog(initialEditing: boolean, viewPackageBody = false
databaseType,
signature: sourceNode.signature,
});
const tabId = queryStore.createTab(connectionId, database, `Source - ${node.label}`, "query", schema, editableSource, node.catalog, { forceNew: true });
const sourceIsEditable = raw.editable !== false && !["SEQUENCE", "TRIGGER", "TYPE", "TYPE_BODY"].includes(resolvedType);
if (sourceIsEditable) {
queryStore.setObjectSource(tabId, {
queryStore.openObjectSourceTab({
connectionId,
database,
title: `Source - ${node.label}`,
schema,
name: objectName,
objectType: resolvedType,
signature: node.signature,
catalog: node.catalog,
sql: editableSource,
objectSource: {
schema,
name: objectName,
objectType: resolvedType,
signature: node.signature,
},
});
} else {
queryStore.createTab(connectionId, database, `Source - ${node.label}`, "query", schema, editableSource, node.catalog, { forceNew: true });
}
})
.catch((e: any) => {
+38
View File
@@ -108,6 +108,16 @@ interface OpenSavedSqlOptions {
targetMode?: SavedSqlOpenTargetMode;
}
interface OpenObjectSourceTabOptions {
connectionId: string;
database: string;
title: string;
schema?: string;
catalog?: string;
sql: string;
objectSource: NonNullable<QueryTab["objectSource"]>;
}
interface UpdateExecutionTargetOptions {
persistSavedSqlTarget?: boolean;
}
@@ -1625,6 +1635,33 @@ export const useQueryStore = defineStore("query", () => {
return id;
}
function openObjectSourceTab(options: OpenObjectSourceTabOptions) {
const existing = tabs.value.find(
(tab) =>
tab.mode === "query" &&
tab.connectionId === options.connectionId &&
tab.database === options.database &&
(tab.schema || "") === (options.schema || "") &&
(tab.catalog || "") === (options.catalog || "") &&
tab.objectSource?.name === options.objectSource.name &&
tab.objectSource.objectType === options.objectSource.objectType &&
(tab.objectSource.schema || "") === (options.objectSource.schema || "") &&
(tab.objectSource.signature || "") === (options.objectSource.signature || ""),
);
if (existing) {
switchTab(existing.id);
if (!isTabDirty(existing)) {
updateSql(existing.id, options.sql);
markTabClean(existing);
}
return existing.id;
}
const id = createTab(options.connectionId, options.database, options.title, "query", options.schema, options.sql, options.catalog, { forceNew: true });
setObjectSource(id, options.objectSource);
return id;
}
function showExecutedQueryResults(connectionId: string, database: string, sql: string, queryResults: QueryResult[]) {
const id = createTab(connectionId, database, undefined, "query", undefined, sql);
const tab = tabs.value.find((item) => item.id === id);
@@ -5819,6 +5856,7 @@ export const useQueryStore = defineStore("query", () => {
hasDirtyTabs,
isConfirmingAppClose,
createTab,
openObjectSourceTab,
showExecutedQueryResults,
switchTab,
closeTab,