mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 02:56:01 +00:00
change current db by tab
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import App from './App.svelte';
|
import App from './App.svelte';
|
||||||
import './utility/connectionsPinger';
|
import './utility/connectionsPinger';
|
||||||
|
import './utility/changeCurrentDbByTab';
|
||||||
import './commands/stdCommands';
|
import './commands/stdCommands';
|
||||||
|
|
||||||
const app = new App({
|
const app = new App({
|
||||||
|
|||||||
25
packages/web/src/utility/changeCurrentDbByTab.ts
Normal file
25
packages/web/src/utility/changeCurrentDbByTab.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import _ from 'lodash';
|
||||||
|
import { currentDatabase, openedTabs } from '../stores';
|
||||||
|
|
||||||
|
let lastCurrentTab = null;
|
||||||
|
|
||||||
|
openedTabs.subscribe(value => {
|
||||||
|
const newCurrentTab = (value || []).find(x => x.selected);
|
||||||
|
if (newCurrentTab == lastCurrentTab) return;
|
||||||
|
|
||||||
|
if (newCurrentTab) {
|
||||||
|
const { conid, database } = newCurrentTab.props || {};
|
||||||
|
if (
|
||||||
|
conid &&
|
||||||
|
database &&
|
||||||
|
(conid != _.get(lastCurrentTab, 'props.conid') || database != _.get(lastCurrentTab, 'props.database'))
|
||||||
|
) {
|
||||||
|
currentDatabase.set({
|
||||||
|
connection: { _id: conid },
|
||||||
|
name: database,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lastCurrentTab = newCurrentTab;
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user