focused connection changes

This commit is contained in:
SPRINX0\prochazka
2024-12-13 10:48:42 +01:00
parent faad82fc34
commit a810dc4204
5 changed files with 29 additions and 5 deletions

View File

@@ -12,6 +12,7 @@ import { shouldShowTab } from '../tabpanel/TabsPanel.svelte';
import { callWhenAppLoaded, getAppLoaded } from './appLoadManager';
import { getConnectionInfo } from './metadataLoaders';
import { switchCurrentDatabase } from './common';
import { extractDbNameFromComposite, isCompositeDbName } from 'dbgate-tools';
// let lastCurrentTab = null;
@@ -82,7 +83,10 @@ currentDatabase.subscribe(currentDb => {
if (currentDb) {
focusedConnectionOrDatabase.set({
conid: currentDb.connection?._id,
database: currentDb.name,
database:
currentDb.connection?.useSeparateSchemas && isCompositeDbName(currentDb.name)
? extractDbNameFromComposite(currentDb.name)
: currentDb.name,
connection: currentDb.connection,
});
} else {

View File

@@ -2,10 +2,11 @@ import _ from 'lodash';
import uuidv1 from 'uuid/v1';
import { getActiveTab, getOpenedTabs, openedTabs } from '../stores';
import tabs from '../tabs';
import { setSelectedTabFunc } from './common';
import { setSelectedTabFunc, switchCurrentDatabase } from './common';
import localforage from 'localforage';
import stableStringify from 'json-stable-stringify';
import { saveAllPendingEditorData } from '../query/useEditorData';
import { getConnectionInfo } from './metadataLoaders';
function findFreeNumber(numbers: number[]) {
if (numbers.length == 0) return 1;
@@ -21,7 +22,16 @@ export default async function openNewTab(newTab, initialData: any = undefined, o
let existing = null;
const { savedFile, savedFolder, savedFilePath } = newTab.props || {};
const { savedFile, savedFolder, savedFilePath, conid, database } = newTab.props || {};
if (conid && database) {
const connection = await getConnectionInfo({ conid });
await switchCurrentDatabase({
connection,
name: database,
});
}
const { tabPreviewMode } = newTab;
if (savedFile || savedFilePath) {
existing = oldTabs.find(