mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 12:53:58 +00:00
change selected object when switching tab
This commit is contained in:
@@ -887,7 +887,7 @@
|
|||||||
export let passProps;
|
export let passProps;
|
||||||
|
|
||||||
function handleClick({ forceNewTab = false, tabPreviewMode = false } = {}) {
|
function handleClick({ forceNewTab = false, tabPreviewMode = false } = {}) {
|
||||||
$selectedDatabaseObjectAppObject = data;
|
$selectedDatabaseObjectAppObject = _.pick(data, ['conid', 'database', 'objectTypeField', 'pureName', 'schemaName']);
|
||||||
handleDatabaseObjectClick(data, { forceNewTab, tabPreviewMode });
|
handleDatabaseObjectClick(data, { forceNewTab, tabPreviewMode });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -924,7 +924,7 @@
|
|||||||
isChoosed={matchDatabaseObjectAppObject($selectedDatabaseObjectAppObject, data)}
|
isChoosed={matchDatabaseObjectAppObject($selectedDatabaseObjectAppObject, data)}
|
||||||
on:click={() => handleClick({ tabPreviewMode: true })}
|
on:click={() => handleClick({ tabPreviewMode: true })}
|
||||||
on:middleclick={() => handleClick({ forceNewTab: true })}
|
on:middleclick={() => handleClick({ forceNewTab: true })}
|
||||||
on:dblclick={() => handleClick({})}
|
on:dblclick={() => handleClick({ tabPreviewMode: false })}
|
||||||
on:expand
|
on:expand
|
||||||
on:dragstart
|
on:dragstart
|
||||||
on:dragenter
|
on:dragenter
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { currentDatabase, getActiveTab, getCurrentDatabase, getLockedDatabaseMode, openedTabs } from '../stores';
|
import {
|
||||||
|
currentDatabase,
|
||||||
|
getActiveTab,
|
||||||
|
getCurrentDatabase,
|
||||||
|
getLockedDatabaseMode,
|
||||||
|
openedTabs,
|
||||||
|
selectedDatabaseObjectAppObject,
|
||||||
|
} from '../stores';
|
||||||
import { shouldShowTab } from '../tabpanel/TabsPanel.svelte';
|
import { shouldShowTab } from '../tabpanel/TabsPanel.svelte';
|
||||||
import { callWhenAppLoaded, getAppLoaded } from './appLoadManager';
|
import { callWhenAppLoaded, getAppLoaded } from './appLoadManager';
|
||||||
import { getConnectionInfo } from './metadataLoaders';
|
import { getConnectionInfo } from './metadataLoaders';
|
||||||
@@ -31,19 +38,34 @@ import { switchCurrentDatabase } from './common';
|
|||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
export function changeDatabaseByCurrentTab() {
|
export async function changeDatabaseByCurrentTab() {
|
||||||
const currentTab = getActiveTab();
|
const currentTab = getActiveTab();
|
||||||
const { conid, database } = currentTab?.props || {};
|
const { conid, database, objectTypeField, pureName, schemaName, defaultActionId } = currentTab?.props || {};
|
||||||
const db = getCurrentDatabase();
|
const db = getCurrentDatabase();
|
||||||
if (conid && database && (conid != db?.connection?._id || database != db?.name)) {
|
if (conid && database && (conid != db?.connection?._id || database != db?.name)) {
|
||||||
const doWork = async () => {
|
|
||||||
const connection = await getConnectionInfo({ conid });
|
const connection = await getConnectionInfo({ conid });
|
||||||
switchCurrentDatabase({
|
switchCurrentDatabase({
|
||||||
connection,
|
connection,
|
||||||
name: database,
|
name: database,
|
||||||
});
|
});
|
||||||
};
|
// const doWork = async () => {
|
||||||
callWhenAppLoaded(doWork);
|
// const connection = await getConnectionInfo({ conid });
|
||||||
|
// switchCurrentDatabase({
|
||||||
|
// connection,
|
||||||
|
// name: database,
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
// callWhenAppLoaded(doWork);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (conid && database && objectTypeField && pureName && defaultActionId) {
|
||||||
|
selectedDatabaseObjectAppObject.set({
|
||||||
|
conid,
|
||||||
|
database,
|
||||||
|
objectTypeField,
|
||||||
|
pureName,
|
||||||
|
schemaName,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user