mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 04:16:00 +00:00
save new connection on cloud
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
import ConnectionAdvancedDriverFields from '../settings/ConnectionAdvancedDriverFields.svelte';
|
||||
import DatabaseLoginModal from '../modals/DatabaseLoginModal.svelte';
|
||||
import { _t } from '../translations';
|
||||
import ChooseCloudFolderModal from '../modals/ChooseCloudFolderModal.svelte';
|
||||
|
||||
export let connection;
|
||||
export let tabid;
|
||||
@@ -44,6 +45,7 @@
|
||||
export let inlineTabs = false;
|
||||
|
||||
export let onlyTestButton;
|
||||
export let saveOnCloud = false;
|
||||
|
||||
let isTesting;
|
||||
let sqlConnectResult;
|
||||
@@ -157,26 +159,53 @@
|
||||
$: currentConnection = getCurrentConnectionCore($values, driver);
|
||||
|
||||
async function handleSave() {
|
||||
let connection = getCurrentConnection();
|
||||
connection = {
|
||||
...connection,
|
||||
unsaved: false,
|
||||
};
|
||||
const saved = await apiCall('connections/save', connection);
|
||||
$values = {
|
||||
...$values,
|
||||
_id: saved._id,
|
||||
unsaved: false,
|
||||
};
|
||||
changeTab(tabid, tab => ({
|
||||
...tab,
|
||||
title: getConnectionLabel(saved),
|
||||
props: {
|
||||
...tab.props,
|
||||
conid: saved._id,
|
||||
},
|
||||
}));
|
||||
showSnackbarSuccess('Connection saved');
|
||||
if (saveOnCloud) {
|
||||
showModal(ChooseCloudFolderModal, {
|
||||
requiredRoleVariants: ['write', 'admin'],
|
||||
message: 'Choose cloud folder to saved connection',
|
||||
onConfirm: async folid => {
|
||||
let connection = getCurrentConnection();
|
||||
const saved = await apiCall('cloud/save-connection', { folid, connection });
|
||||
if (saved?._id) {
|
||||
$values = {
|
||||
...$values,
|
||||
_id: saved._id,
|
||||
unsaved: false,
|
||||
};
|
||||
changeTab(tabid, tab => ({
|
||||
...tab,
|
||||
title: getConnectionLabel(saved),
|
||||
props: {
|
||||
...tab.props,
|
||||
conid: saved._id,
|
||||
},
|
||||
}));
|
||||
showSnackbarSuccess('Connection saved');
|
||||
}
|
||||
},
|
||||
});
|
||||
} else {
|
||||
let connection = getCurrentConnection();
|
||||
connection = {
|
||||
...connection,
|
||||
unsaved: false,
|
||||
};
|
||||
const saved = await apiCall('connections/save', connection);
|
||||
$values = {
|
||||
...$values,
|
||||
_id: saved._id,
|
||||
unsaved: false,
|
||||
};
|
||||
changeTab(tabid, tab => ({
|
||||
...tab,
|
||||
title: getConnectionLabel(saved),
|
||||
props: {
|
||||
...tab.props,
|
||||
conid: saved._id,
|
||||
},
|
||||
}));
|
||||
showSnackbarSuccess('Connection saved');
|
||||
}
|
||||
}
|
||||
|
||||
async function handleConnect() {
|
||||
@@ -287,7 +316,9 @@
|
||||
{:else if isConnected}
|
||||
<FormButton value="Disconnect" on:click={handleDisconnect} data-testid="ConnectionTab_buttonDisconnect" />
|
||||
{:else}
|
||||
<FormButton value="Connect" on:click={handleConnect} data-testid="ConnectionTab_buttonConnect" />
|
||||
{#if $values._id || !saveOnCloud}
|
||||
<FormButton value="Connect" on:click={handleConnect} data-testid="ConnectionTab_buttonConnect" />
|
||||
{/if}
|
||||
{#if isTesting}
|
||||
<FormButton value="Cancel test" on:click={handleCancelTest} />
|
||||
{:else}
|
||||
|
||||
Reference in New Issue
Block a user