mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 08:43:57 +00:00
configurable connection click, database click #959
This commit is contained in:
@@ -123,6 +123,7 @@
|
|||||||
import { getConnectionLabel } from 'dbgate-tools';
|
import { getConnectionLabel } from 'dbgate-tools';
|
||||||
import hasPermission from '../utility/hasPermission';
|
import hasPermission from '../utility/hasPermission';
|
||||||
import { switchCurrentDatabase } from '../utility/common';
|
import { switchCurrentDatabase } from '../utility/common';
|
||||||
|
import { getConnectionClickActionSetting } from '../settings/settingsTools';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
export let passProps;
|
export let passProps;
|
||||||
@@ -184,16 +185,24 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
const config = getCurrentConfig();
|
const config = getCurrentConfig();
|
||||||
if (config.runAsPortal == false && !config.storageDatabase) {
|
|
||||||
openNewTab({
|
const connectionClickAction = getConnectionClickActionSetting();
|
||||||
title: getConnectionLabel(data),
|
if (connectionClickAction == 'openDetails') {
|
||||||
icon: 'img connection',
|
if (config.runAsPortal == false && !config.storageDatabase) {
|
||||||
tabComponent: 'ConnectionTab',
|
openNewTab({
|
||||||
tabPreviewMode: true,
|
title: getConnectionLabel(data),
|
||||||
props: {
|
icon: 'img connection',
|
||||||
conid: data._id,
|
tabComponent: 'ConnectionTab',
|
||||||
},
|
tabPreviewMode: true,
|
||||||
});
|
props: {
|
||||||
|
conid: data._id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (connectionClickAction == 'connect') {
|
||||||
|
await tick();
|
||||||
|
handleConnect();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -351,11 +351,13 @@ await dbgateApi.dropAllDbObjects(${JSON.stringify(
|
|||||||
text: `New ${driver?.collectionSingularLabel ?? 'collection/container'}`,
|
text: `New ${driver?.collectionSingularLabel ?? 'collection/container'}`,
|
||||||
},
|
},
|
||||||
hasPermission(`dbops/query`) &&
|
hasPermission(`dbops/query`) &&
|
||||||
driver?.databaseEngineTypes?.includes('sql') && isProApp() && { onClick: handleQueryDesigner, text: 'Design query' },
|
driver?.databaseEngineTypes?.includes('sql') &&
|
||||||
driver?.databaseEngineTypes?.includes('sql') && isProApp() && {
|
isProApp() && { onClick: handleQueryDesigner, text: 'Design query' },
|
||||||
onClick: handleNewPerspective,
|
driver?.databaseEngineTypes?.includes('sql') &&
|
||||||
text: 'Design perspective query',
|
isProApp() && {
|
||||||
},
|
onClick: handleNewPerspective,
|
||||||
|
text: 'Design perspective query',
|
||||||
|
},
|
||||||
connection.useSeparateSchemas && { onClick: handleRefreshSchemas, text: 'Refresh schemas' },
|
connection.useSeparateSchemas && { onClick: handleRefreshSchemas, text: 'Refresh schemas' },
|
||||||
|
|
||||||
{ divider: true },
|
{ divider: true },
|
||||||
@@ -486,6 +488,7 @@ await dbgateApi.dropAllDbObjects(${JSON.stringify(
|
|||||||
import ChooseArchiveFolderModal from '../modals/ChooseArchiveFolderModal.svelte';
|
import ChooseArchiveFolderModal from '../modals/ChooseArchiveFolderModal.svelte';
|
||||||
import { extractShellConnection } from '../impexp/createImpExpScript';
|
import { extractShellConnection } from '../impexp/createImpExpScript';
|
||||||
import { getNumberIcon } from '../icons/FontIcon.svelte';
|
import { getNumberIcon } from '../icons/FontIcon.svelte';
|
||||||
|
import { getDatabaseClickActionSetting } from '../settings/settingsTools';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
export let passProps;
|
export let passProps;
|
||||||
@@ -523,6 +526,9 @@ await dbgateApi.dropAllDbObjects(${JSON.stringify(
|
|||||||
on:click={() => {
|
on:click={() => {
|
||||||
// switchCurrentDatabase(data);
|
// switchCurrentDatabase(data);
|
||||||
$focusedConnectionOrDatabase = { conid: data.connection?._id, database: data.name, connection: data.connection };
|
$focusedConnectionOrDatabase = { conid: data.connection?._id, database: data.name, connection: data.connection };
|
||||||
|
if (getDatabaseClickActionSetting() == 'switch') {
|
||||||
|
switchCurrentDatabase(data);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
on:dragstart
|
on:dragstart
|
||||||
on:dragenter
|
on:dragenter
|
||||||
|
|||||||
@@ -278,6 +278,30 @@ ORDER BY
|
|||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
<svelte:fragment slot="4">
|
<svelte:fragment slot="4">
|
||||||
<div class="heading">Default actions</div>
|
<div class="heading">Default actions</div>
|
||||||
|
|
||||||
|
<FormSelectField
|
||||||
|
label="Connection click"
|
||||||
|
name="defaultAction.connectionClick"
|
||||||
|
isNative
|
||||||
|
defaultValue="connect"
|
||||||
|
options={[
|
||||||
|
{ value: 'openDetails', label: 'Edit / open details' },
|
||||||
|
{ value: 'connect', label: 'Connect' },
|
||||||
|
{ value: 'none', label: 'Do nothing' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<FormSelectField
|
||||||
|
label="Database click"
|
||||||
|
name="defaultAction.databaseClick"
|
||||||
|
isNative
|
||||||
|
defaultValue="switch"
|
||||||
|
options={[
|
||||||
|
{ value: 'switch', label: 'Switch database' },
|
||||||
|
{ value: 'none', label: 'Do nothing' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
<FormCheckboxField name="defaultAction.useLastUsedAction" label="Use last used action" defaultValue={true} />
|
<FormCheckboxField name="defaultAction.useLastUsedAction" label="Use last used action" defaultValue={true} />
|
||||||
|
|
||||||
<FormDefaultActionField
|
<FormDefaultActionField
|
||||||
|
|||||||
@@ -28,3 +28,11 @@ export function getStringSettingsValue(name, defaultValue) {
|
|||||||
if (res == null) return defaultValue;
|
if (res == null) return defaultValue;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getConnectionClickActionSetting(): 'connect' | 'openDetails' | 'none' {
|
||||||
|
return getStringSettingsValue('defaultAction.connectionClick', 'connect');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getDatabaseClickActionSetting(): 'switch' | 'none' {
|
||||||
|
return getStringSettingsValue('defaultAction.databaseClick', 'switch');
|
||||||
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
import { switchCurrentDatabase } from '../utility/common';
|
import { switchCurrentDatabase } from '../utility/common';
|
||||||
import openNewTab from '../utility/openNewTab';
|
import openNewTab from '../utility/openNewTab';
|
||||||
import { openConnection } from '../appobj/ConnectionAppObject.svelte';
|
import { openConnection } from '../appobj/ConnectionAppObject.svelte';
|
||||||
|
import { getConnectionClickActionSetting } from '../settings/settingsTools';
|
||||||
|
|
||||||
const connections = useConnectionList();
|
const connections = useConnectionList();
|
||||||
const serverStatus = useServerStatus();
|
const serverStatus = useServerStatus();
|
||||||
@@ -194,7 +195,11 @@
|
|||||||
/>
|
/>
|
||||||
<CloseSearchButton bind:filter />
|
<CloseSearchButton bind:filter />
|
||||||
{#if $commandsCustomized['new.connection']?.enabled}
|
{#if $commandsCustomized['new.connection']?.enabled}
|
||||||
<InlineButton on:click={() => runCommand('new.connection')} title="Add new connection" data-testid="ConnectionList_buttonNewConnection">
|
<InlineButton
|
||||||
|
on:click={() => runCommand('new.connection')}
|
||||||
|
title="Add new connection"
|
||||||
|
data-testid="ConnectionList_buttonNewConnection"
|
||||||
|
>
|
||||||
<FontIcon icon="icon plus-thick" />
|
<FontIcon icon="icon plus-thick" />
|
||||||
</InlineButton>
|
</InlineButton>
|
||||||
<InlineButton on:click={() => runCommand('new.connection.folder')} title="Add new connection folder">
|
<InlineButton on:click={() => runCommand('new.connection.folder')} title="Add new connection folder">
|
||||||
@@ -235,6 +240,8 @@
|
|||||||
domFilter?.focus(text);
|
domFilter?.focus(text);
|
||||||
}}
|
}}
|
||||||
handleObjectClick={(data, options) => {
|
handleObjectClick={(data, options) => {
|
||||||
|
const connectionClickAction = getConnectionClickActionSetting();
|
||||||
|
|
||||||
if (data.database) {
|
if (data.database) {
|
||||||
if (options.focusTab) {
|
if (options.focusTab) {
|
||||||
if ($openedSingleDatabaseConnections.includes(data.conid)) {
|
if ($openedSingleDatabaseConnections.includes(data.conid)) {
|
||||||
@@ -250,7 +257,7 @@
|
|||||||
openConnection(data.connection);
|
openConnection(data.connection);
|
||||||
} else {
|
} else {
|
||||||
const config = getCurrentConfig();
|
const config = getCurrentConfig();
|
||||||
if (config.runAsPortal == false && !config.storageDatabase) {
|
if (config.runAsPortal == false && !config.storageDatabase && connectionClickAction == 'openDetails') {
|
||||||
openNewTab({
|
openNewTab({
|
||||||
title: getConnectionLabel(data.connection),
|
title: getConnectionLabel(data.connection),
|
||||||
icon: 'img connection',
|
icon: 'img connection',
|
||||||
|
|||||||
Reference in New Issue
Block a user