mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 04:16:00 +00:00
open new tab - corrent multiTabIndex
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { get } from 'svelte/store';
|
import { getCurrentDatabase } from '../stores';
|
||||||
import { currentDatabase } from '../stores';
|
|
||||||
import getConnectionLabel from '../utility/getConnectionLabel';
|
import getConnectionLabel from '../utility/getConnectionLabel';
|
||||||
import openNewTab from '../utility/openNewTab';
|
import openNewTab from '../utility/openNewTab';
|
||||||
|
|
||||||
@@ -9,11 +8,12 @@ export default function newQuery({
|
|||||||
icon = 'img sql-file',
|
icon = 'img sql-file',
|
||||||
title = undefined,
|
title = undefined,
|
||||||
initialData = undefined,
|
initialData = undefined,
|
||||||
|
multiTabIndex = undefined,
|
||||||
...props
|
...props
|
||||||
} = {}) {
|
} = {}) {
|
||||||
const $currentDatabase = get(currentDatabase);
|
const currentDb = getCurrentDatabase();
|
||||||
const connection = _.get($currentDatabase, 'connection') || {};
|
const connection = currentDb?.connection || {};
|
||||||
const database = _.get($currentDatabase, 'name');
|
const database = currentDb?.name;
|
||||||
|
|
||||||
const tooltip = `${getConnectionLabel(connection)}\n${database}`;
|
const tooltip = `${getConnectionLabel(connection)}\n${database}`;
|
||||||
|
|
||||||
@@ -23,6 +23,7 @@ export default function newQuery({
|
|||||||
icon,
|
icon,
|
||||||
tooltip,
|
tooltip,
|
||||||
tabComponent,
|
tabComponent,
|
||||||
|
multiTabIndex,
|
||||||
props: {
|
props: {
|
||||||
...props,
|
...props,
|
||||||
conid: connection._id,
|
conid: connection._id,
|
||||||
|
|||||||
@@ -565,7 +565,7 @@
|
|||||||
<FontIcon icon="icon split" />
|
<FontIcon icon="icon split" />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="icon-button" on:click={() => newQuery({})} title="New query">
|
<div class="icon-button" on:click={() => newQuery({ multiTabIndex })} title="New query">
|
||||||
<FontIcon icon="icon add" />
|
<FontIcon icon="icon add" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import uuidv1 from 'uuid/v1';
|
import uuidv1 from 'uuid/v1';
|
||||||
import { get } from 'svelte/store';
|
import { getActiveTab, getOpenedTabs, openedTabs } from '../stores';
|
||||||
import { getOpenedTabs, openedTabs } from '../stores';
|
|
||||||
import tabs from '../tabs';
|
import tabs from '../tabs';
|
||||||
import { setSelectedTabFunc } from './common';
|
import { setSelectedTabFunc } from './common';
|
||||||
import localforage from 'localforage';
|
import localforage from 'localforage';
|
||||||
@@ -17,7 +16,8 @@ function findFreeNumber(numbers: number[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default async function openNewTab(newTab, initialData = undefined, options = undefined) {
|
export default async function openNewTab(newTab, initialData = undefined, options = undefined) {
|
||||||
const oldTabs = get(openedTabs);
|
const oldTabs = getOpenedTabs();
|
||||||
|
const activeTab = getActiveTab();
|
||||||
|
|
||||||
let existing = null;
|
let existing = null;
|
||||||
|
|
||||||
@@ -98,6 +98,7 @@ export default async function openNewTab(newTab, initialData = undefined, option
|
|||||||
...newTab,
|
...newTab,
|
||||||
tabid,
|
tabid,
|
||||||
selected: true,
|
selected: true,
|
||||||
|
multiTabIndex: newTab?.multiTabIndex ?? activeTab?.multiTabIndex ?? 0,
|
||||||
tabOrder: _.findIndex(items, y => y.tabid == tabid),
|
tabOrder: _.findIndex(items, y => y.tabid == tabid),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user