mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-24 23:26:00 +00:00
separate schema selector in frontend
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { getOpenedTabs, openedTabs } from '../stores';
|
||||
import { findDefaultSchema, findEngineDriver, isCompositeDbName } from 'dbgate-tools';
|
||||
import { currentDatabase, getExtensions, getOpenedTabs, openedTabs } from '../stores';
|
||||
import _ from 'lodash';
|
||||
import { getSchemaList } from './metadataLoaders';
|
||||
|
||||
export class LoadingToken {
|
||||
isCanceled = false;
|
||||
@@ -82,3 +84,21 @@ export function isCtrlOrCommandKey(event) {
|
||||
}
|
||||
return event.ctrlKey;
|
||||
}
|
||||
|
||||
export async function switchCurrentDatabase(data) {
|
||||
if (data?.connection?.useSeparateSchemas && !isCompositeDbName(data.name)) {
|
||||
const conid = data.connection._id;
|
||||
const database = data.name;
|
||||
const storageKey = `selected-schema-${conid}-${database}`;
|
||||
const schemaInStorage = localStorage.getItem(storageKey);
|
||||
const schemas = await getSchemaList({ conid, database });
|
||||
const driver = findEngineDriver(data.connection, getExtensions());
|
||||
const defaultSchema = findDefaultSchema(schemas, driver?.dialect, schemaInStorage);
|
||||
currentDatabase.set({
|
||||
...data,
|
||||
name: `${data.name}::${defaultSchema}`,
|
||||
});
|
||||
} else {
|
||||
currentDatabase.set(data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user