open new tab - corrent multiTabIndex

This commit is contained in:
Jan Prochazka 2023-03-05 12:14:43 +01:00
parent 15d005be13
commit d283429f40
3 changed files with 11 additions and 9 deletions

View File

@ -1,6 +1,5 @@
import _ from 'lodash';
import { get } from 'svelte/store';
import { currentDatabase } from '../stores';
import { getCurrentDatabase } from '../stores';
import getConnectionLabel from '../utility/getConnectionLabel';
import openNewTab from '../utility/openNewTab';
@ -9,11 +8,12 @@ export default function newQuery({
icon = 'img sql-file',
title = undefined,
initialData = undefined,
multiTabIndex = undefined,
...props
} = {}) {
const $currentDatabase = get(currentDatabase);
const connection = _.get($currentDatabase, 'connection') || {};
const database = _.get($currentDatabase, 'name');
const currentDb = getCurrentDatabase();
const connection = currentDb?.connection || {};
const database = currentDb?.name;
const tooltip = `${getConnectionLabel(connection)}\n${database}`;
@ -23,6 +23,7 @@ export default function newQuery({
icon,
tooltip,
tabComponent,
multiTabIndex,
props: {
...props,
conid: connection._id,

View File

@ -565,7 +565,7 @@
<FontIcon icon="icon split" />
</div>
{/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" />
</div>
</div>

View File

@ -1,7 +1,6 @@
import _ from 'lodash';
import uuidv1 from 'uuid/v1';
import { get } from 'svelte/store';
import { getOpenedTabs, openedTabs } from '../stores';
import { getActiveTab, getOpenedTabs, openedTabs } from '../stores';
import tabs from '../tabs';
import { setSelectedTabFunc } from './common';
import localforage from 'localforage';
@ -17,7 +16,8 @@ function findFreeNumber(numbers: number[]) {
}
export default async function openNewTab(newTab, initialData = undefined, options = undefined) {
const oldTabs = get(openedTabs);
const oldTabs = getOpenedTabs();
const activeTab = getActiveTab();
let existing = null;
@ -98,6 +98,7 @@ export default async function openNewTab(newTab, initialData = undefined, option
...newTab,
tabid,
selected: true,
multiTabIndex: newTab?.multiTabIndex ?? activeTab?.multiTabIndex ?? 0,
tabOrder: _.findIndex(items, y => y.tabid == tabid),
},
];