Add initial key name support in DbKeyTab and DbKeysTree components

This commit is contained in:
Stela Augustinova
2025-12-09 16:39:36 +01:00
parent 056ee0d58e
commit 623a23492f
2 changed files with 16 additions and 1 deletions

View File

@@ -16,12 +16,13 @@
export let conid;
export let database;
export let tabid;
export let initialKeyName = '';
$: connection = useConnectionInfo({ conid });
$: driver = $connection && findEngineDriver($connection, getExtensions());
let item = {};
let keyName = '';
let keyName = initialKeyName || '';
$: type = driver?.supportedKeyTypes?.[0]?.name || '';
$: console.log('DbKeyTab debug:', { conid, database, connection: $connection, driver, hasTypes: driver?.supportedKeyTypes?.length });

View File

@@ -51,6 +51,19 @@
function handleAddKey() {
const connection = $currentDatabase?.connection;
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({
tabComponent: 'DbKeyTab',
@@ -59,6 +72,7 @@
props: {
conid: connection?._id,
database,
initialKeyName,
},
});