mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 16:23:58 +00:00
Add initial key name support in DbKeyTab and DbKeysTree components
This commit is contained in:
@@ -16,12 +16,13 @@
|
|||||||
export let conid;
|
export let conid;
|
||||||
export let database;
|
export let database;
|
||||||
export let tabid;
|
export let tabid;
|
||||||
|
export let initialKeyName = '';
|
||||||
|
|
||||||
$: connection = useConnectionInfo({ conid });
|
$: connection = useConnectionInfo({ conid });
|
||||||
$: driver = $connection && findEngineDriver($connection, getExtensions());
|
$: driver = $connection && findEngineDriver($connection, getExtensions());
|
||||||
|
|
||||||
let item = {};
|
let item = {};
|
||||||
let keyName = '';
|
let keyName = initialKeyName || '';
|
||||||
$: type = driver?.supportedKeyTypes?.[0]?.name || '';
|
$: type = driver?.supportedKeyTypes?.[0]?.name || '';
|
||||||
|
|
||||||
$: console.log('DbKeyTab debug:', { conid, database, connection: $connection, driver, hasTypes: driver?.supportedKeyTypes?.length });
|
$: console.log('DbKeyTab debug:', { conid, database, connection: $connection, driver, hasTypes: driver?.supportedKeyTypes?.length });
|
||||||
|
|||||||
@@ -51,6 +51,19 @@
|
|||||||
function handleAddKey() {
|
function handleAddKey() {
|
||||||
const connection = $currentDatabase?.connection;
|
const connection = $currentDatabase?.connection;
|
||||||
const database = $currentDatabase?.name;
|
const database = $currentDatabase?.name;
|
||||||
|
const focusedKey = $focusedTreeDbKey;
|
||||||
|
|
||||||
|
let initialKeyName = '';
|
||||||
|
if (focusedKey) {
|
||||||
|
if (focusedKey.type === 'dir' && focusedKey.key) {
|
||||||
|
initialKeyName = focusedKey.key + treeKeySeparator;
|
||||||
|
} else if (focusedKey.key) {
|
||||||
|
const lastSeparatorIndex = focusedKey.key.lastIndexOf(treeKeySeparator);
|
||||||
|
if (lastSeparatorIndex !== -1) {
|
||||||
|
initialKeyName = focusedKey.key.substring(0, lastSeparatorIndex + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
openNewTab({
|
openNewTab({
|
||||||
tabComponent: 'DbKeyTab',
|
tabComponent: 'DbKeyTab',
|
||||||
@@ -59,6 +72,7 @@
|
|||||||
props: {
|
props: {
|
||||||
conid: connection?._id,
|
conid: connection?._id,
|
||||||
database,
|
database,
|
||||||
|
initialKeyName,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user