separate schema selector in frontend

This commit is contained in:
Jan Prochazka
2024-09-19 15:19:16 +02:00
parent cb7224ac94
commit 4431d08a88
14 changed files with 90 additions and 37 deletions

View File

@@ -46,7 +46,7 @@
databaseList.push({
text: `${db.name} on ${getConnectionLabel(connection)}`,
icon: 'img database',
onClick: () => currentDatabase.set({ connection, name: db.name }),
onClick: () => switchCurrentDatabase({ connection, name: db.name }),
});
}
}
@@ -80,7 +80,7 @@
import { useConnectionList, useDatabaseInfo } from '../utility/metadataLoaders';
import { getLocalStorage } from '../utility/storageCache';
import registerCommand from './registerCommand';
import { formatKeyText } from '../utility/common';
import { formatKeyText, switchCurrentDatabase } from '../utility/common';
let domInput;
let filter = '';

View File

@@ -3,6 +3,7 @@ import { currentDatabase, getCurrentDatabase } from '../stores';
import getElectron from '../utility/getElectron';
import registerCommand from './registerCommand';
import { apiCall } from '../utility/api';
import { switchCurrentDatabase } from '../utility/common';
registerCommand({
id: 'database.changeState',
@@ -40,7 +41,7 @@ registerCommand({
onClick: () => {
const electron = getElectron();
if (electron) apiCall('database-connections/disconnect', dbid);
currentDatabase.set(null);
switchCurrentDatabase(null);
},
},
];

View File

@@ -2,6 +2,7 @@ import _ from 'lodash';
import { recentDatabases, currentDatabase, getRecentDatabases } from '../stores';
import registerCommand from './registerCommand';
import { getConnectionLabel } from 'dbgate-tools';
import { switchCurrentDatabase } from '../utility/common';
currentDatabase.subscribe(value => {
if (!value) return;
@@ -17,7 +18,7 @@ currentDatabase.subscribe(value => {
function switchDatabaseCommand(db) {
return {
text: `${db.name} on ${getConnectionLabel(db?.connection, { allowExplicitDatabase: false })}`,
onClick: () => currentDatabase.set(db),
onClick: () => switchCurrentDatabase(db),
};
}

View File

@@ -35,7 +35,7 @@ import { apiCall } from '../utility/api';
import runCommand from './runCommand';
import { openWebLink } from '../utility/exportFileTools';
import { getSettings } from '../utility/metadataLoaders';
import { isMac } from '../utility/common';
import { isMac, switchCurrentDatabase } from '../utility/common';
import { doLogout, internalRedirectTo } from '../clientAuth';
import { disconnectServerConnection } from '../appobj/ConnectionAppObject.svelte';
import UploadErrorModal from '../modals/UploadErrorModal.svelte';
@@ -347,7 +347,7 @@ registerCommand({
onConfirm: async file => {
const resp = await apiCall('connections/new-sqlite-database', { file });
const connection = resp;
currentDatabase.set({ connection, name: `${file}.sqlite` });
switchCurrentDatabase({ connection, name: `${file}.sqlite` });
},
});
},