mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 21:16:00 +00:00
cloud connection save
This commit is contained in:
@@ -159,7 +159,7 @@
|
||||
$: currentConnection = getCurrentConnectionCore($values, driver);
|
||||
|
||||
async function handleSave() {
|
||||
if (saveOnCloud) {
|
||||
if (saveOnCloud && !getCurrentConnection()?._id) {
|
||||
showModal(ChooseCloudFolderModal, {
|
||||
requiredRoleVariants: ['write', 'admin'],
|
||||
message: 'Choose cloud folder to saved connection',
|
||||
@@ -184,6 +184,17 @@
|
||||
}
|
||||
},
|
||||
});
|
||||
} else if (
|
||||
// @ts-ignore
|
||||
getCurrentConnection()?._id?.startsWith('cloud://')
|
||||
) {
|
||||
let connection = getCurrentConnection();
|
||||
await apiCall('cloud/save-connection', { connection });
|
||||
showSnackbarSuccess('Connection saved');
|
||||
changeTab(tabid, tab => ({
|
||||
...tab,
|
||||
title: getConnectionLabel(connection),
|
||||
}));
|
||||
} else {
|
||||
let connection = getCurrentConnection();
|
||||
connection = {
|
||||
@@ -210,19 +221,32 @@
|
||||
|
||||
async function handleConnect() {
|
||||
let connection = getCurrentConnection();
|
||||
if (!connection._id) {
|
||||
connection = {
|
||||
...connection,
|
||||
unsaved: true,
|
||||
|
||||
if (
|
||||
// @ts-ignore
|
||||
connection?._id?.startsWith('cloud://')
|
||||
) {
|
||||
const saved = await apiCall('cloud/save-connection', { connection });
|
||||
changeTab(tabid, tab => ({
|
||||
...tab,
|
||||
title: getConnectionLabel(connection),
|
||||
}));
|
||||
openConnection(saved);
|
||||
} else {
|
||||
if (!connection._id) {
|
||||
connection = {
|
||||
...connection,
|
||||
unsaved: true,
|
||||
};
|
||||
}
|
||||
const saved = await apiCall('connections/save', connection);
|
||||
$values = {
|
||||
...$values,
|
||||
unsaved: connection.unsaved,
|
||||
_id: saved._id,
|
||||
};
|
||||
openConnection(saved);
|
||||
}
|
||||
const saved = await apiCall('connections/save', connection);
|
||||
$values = {
|
||||
...$values,
|
||||
unsaved: connection.unsaved,
|
||||
_id: saved._id,
|
||||
};
|
||||
openConnection(saved);
|
||||
// closeMultipleTabs(x => x.tabid == tabid, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
currentDatabase,
|
||||
expandedConnections,
|
||||
openedConnections,
|
||||
openedSingleDatabaseConnections,
|
||||
} from '../stores';
|
||||
import _ from 'lodash';
|
||||
import { plusExpandIcon } from '../icons/expandIcons';
|
||||
@@ -74,12 +75,26 @@
|
||||
};
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
const currentConid = $currentDatabase?.connection?._id;
|
||||
if (currentConid?.startsWith('cloud://') && !$cloudConnectionsStore[currentConid]) {
|
||||
loadCloudConnection(currentConid);
|
||||
}
|
||||
});
|
||||
function ensureCloudConnectionsLoaded(...conids) {
|
||||
_.uniq(conids).forEach(conid => {
|
||||
if (conid?.startsWith('cloud://') && !$cloudConnectionsStore[conid]) {
|
||||
loadCloudConnection(conid);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$: ensureCloudConnectionsLoaded(
|
||||
$currentDatabase?.connection?._id,
|
||||
...$openedSingleDatabaseConnections,
|
||||
...$openedConnections
|
||||
);
|
||||
|
||||
// onMount(() => {
|
||||
// const currentConid = $currentDatabase?.connection?._id;
|
||||
// if (currentConid?.startsWith('cloud://') && !$cloudConnectionsStore[currentConid]) {
|
||||
// loadCloudConnection(currentConid);
|
||||
// }
|
||||
// });
|
||||
|
||||
function createAddMenu() {
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user