mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 02:43:59 +00:00
default action improved & configurable
This commit is contained in:
@@ -697,6 +697,16 @@
|
|||||||
initialData,
|
initialData,
|
||||||
{ forceNewTab }
|
{ forceNewTab }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (tabPreviewMode && defaultActionId && getBoolSettingsValue('defaultAction.useLastUsedAction', true)) {
|
||||||
|
lastUsedDefaultActions.update(actions => ({
|
||||||
|
...actions,
|
||||||
|
[objectTypeField]: defaultActionId,
|
||||||
|
}));
|
||||||
|
// apiCall('config/update-settings', {
|
||||||
|
// [`defaultAction.dbObjectClick.${objectTypeField}`]: defaultActionId,
|
||||||
|
// });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleDatabaseObjectClick(
|
export function handleDatabaseObjectClick(
|
||||||
@@ -708,7 +718,7 @@
|
|||||||
|
|
||||||
const activeTab = getActiveTab();
|
const activeTab = getActiveTab();
|
||||||
const activeTabProps = activeTab?.props || {};
|
const activeTabProps = activeTab?.props || {};
|
||||||
const activeDefaultActionId = activeTab?.props?.defaultActionId;
|
// const activeDefaultActionId = activeTab?.props?.defaultActionId;
|
||||||
|
|
||||||
if (matchDatabaseObjectAppObject(data, activeTabProps)) {
|
if (matchDatabaseObjectAppObject(data, activeTabProps)) {
|
||||||
if (!tabPreviewMode) {
|
if (!tabPreviewMode) {
|
||||||
@@ -725,11 +735,10 @@
|
|||||||
|
|
||||||
const availableDefaultActions = defaultDatabaseObjectAppObjectActions[objectTypeField];
|
const availableDefaultActions = defaultDatabaseObjectAppObjectActions[objectTypeField];
|
||||||
|
|
||||||
const configuredActionId = getCurrentSettings()[`defaultAction.dbObjectClick.${objectTypeField}`];
|
const configuredActionId = getLastUsedDefaultActions()[objectTypeField];
|
||||||
const prefferedAction =
|
const prefferedAction =
|
||||||
availableDefaultActions.find(x => x.defaultActionId == activeDefaultActionId) ??
|
// availableDefaultActions.find(x => x.defaultActionId == activeDefaultActionId) ??
|
||||||
availableDefaultActions.find(x => x.defaultActionId == configuredActionId) ??
|
availableDefaultActions.find(x => x.defaultActionId == configuredActionId) ?? availableDefaultActions[0];
|
||||||
availableDefaultActions[0];
|
|
||||||
|
|
||||||
// console.log('activeTab', activeTab);
|
// console.log('activeTab', activeTab);
|
||||||
|
|
||||||
@@ -832,6 +841,10 @@
|
|||||||
databaseObjectMenuClickHandler(data, { ...menu, forceNewTab: true, defaultActionId: null });
|
databaseObjectMenuClickHandler(data, { ...menu, forceNewTab: true, defaultActionId: null });
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
|
isBold:
|
||||||
|
data.objectTypeField &&
|
||||||
|
menu.defaultActionId &&
|
||||||
|
getLastUsedDefaultActions()[data.objectTypeField] == menu.defaultActionId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -868,6 +881,8 @@
|
|||||||
getActiveTab,
|
getActiveTab,
|
||||||
getCurrentSettings,
|
getCurrentSettings,
|
||||||
getExtensions,
|
getExtensions,
|
||||||
|
getLastUsedDefaultActions,
|
||||||
|
lastUsedDefaultActions,
|
||||||
openedConnections,
|
openedConnections,
|
||||||
openedTabs,
|
openedTabs,
|
||||||
pinnedTables,
|
pinnedTables,
|
||||||
@@ -901,6 +916,7 @@
|
|||||||
import { openImportExportTab } from '../utility/importExportTools';
|
import { openImportExportTab } from '../utility/importExportTools';
|
||||||
import { defaultDatabaseObjectAppObjectActions, matchDatabaseObjectAppObject } from './appObjectTools';
|
import { defaultDatabaseObjectAppObjectActions, matchDatabaseObjectAppObject } from './appObjectTools';
|
||||||
import { getSupportedScriptTemplates } from '../utility/applyScriptTemplate';
|
import { getSupportedScriptTemplates } from '../utility/applyScriptTemplate';
|
||||||
|
import { getBoolSettingsValue } from '../settings/settingsTools';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
export let passProps;
|
export let passProps;
|
||||||
|
|||||||
@@ -130,7 +130,7 @@
|
|||||||
changeActiveSubmenu();
|
changeActiveSubmenu();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<a on:click={e => handleClick(e, item)} class:disabled={item.disabled}>
|
<a on:click={e => handleClick(e, item)} class:disabled={item.disabled} class:bold={item.isBold}>
|
||||||
{item.text || item.label}
|
{item.text || item.label}
|
||||||
{#if item.keyText}
|
{#if item.keyText}
|
||||||
<span class="keyText">{formatKeyText(item.keyText)}</span>
|
<span class="keyText">{formatKeyText(item.keyText)}</span>
|
||||||
@@ -201,6 +201,10 @@
|
|||||||
color: var(--theme-font-3);
|
color: var(--theme-font-3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a.bold {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
a:hover:not(.disabled) {
|
a:hover:not(.disabled) {
|
||||||
background-color: var(--theme-bg-1);
|
background-color: var(--theme-bg-1);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
|||||||
@@ -1,18 +1,31 @@
|
|||||||
<script alng="ts">
|
<script lang="ts">
|
||||||
import { defaultDatabaseObjectAppObjectActions } from '../appobj/appObjectTools';
|
import { defaultDatabaseObjectAppObjectActions } from '../appobj/appObjectTools';
|
||||||
|
import FormFieldTemplateLarge from '../forms/FormFieldTemplateLarge.svelte';
|
||||||
import FormSelectField from '../forms/FormSelectField.svelte';
|
import FormSelectField from '../forms/FormSelectField.svelte';
|
||||||
|
import SelectField from '../forms/SelectField.svelte';
|
||||||
|
import { lastUsedDefaultActions } from '../stores';
|
||||||
|
|
||||||
export let label;
|
export let label;
|
||||||
export let objectTypeField;
|
export let objectTypeField;
|
||||||
|
export let disabled = false;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<FormSelectField
|
<FormFieldTemplateLarge {label} type="combo">
|
||||||
|
<SelectField
|
||||||
{label}
|
{label}
|
||||||
name={`defaultAction.dbObjectClick.${objectTypeField}`}
|
|
||||||
isNative
|
isNative
|
||||||
|
{disabled}
|
||||||
defaultValue={defaultDatabaseObjectAppObjectActions[objectTypeField][0]?.defaultActionId}
|
defaultValue={defaultDatabaseObjectAppObjectActions[objectTypeField][0]?.defaultActionId}
|
||||||
options={defaultDatabaseObjectAppObjectActions[objectTypeField].map(x => ({
|
options={defaultDatabaseObjectAppObjectActions[objectTypeField].map(x => ({
|
||||||
value: x.defaultActionId,
|
value: x.defaultActionId,
|
||||||
label: x.label,
|
label: x.label,
|
||||||
}))}
|
}))}
|
||||||
/>
|
value={$lastUsedDefaultActions[objectTypeField]}
|
||||||
|
on:change={e => {
|
||||||
|
$lastUsedDefaultActions = {
|
||||||
|
...$lastUsedDefaultActions,
|
||||||
|
[objectTypeField]: e.detail.value,
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</FormFieldTemplateLarge>
|
||||||
|
|||||||
@@ -278,22 +278,33 @@ 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
|
<FormCheckboxField name="defaultAction.useLastUsedAction" label="Use last used action" defaultValue={true} />
|
||||||
label="Connection click"
|
|
||||||
name="defaultAction.connectionClick"
|
|
||||||
isNative
|
|
||||||
defaultValue="connect"
|
|
||||||
options={[
|
|
||||||
{ value: 'openDetails', label: 'Edit / open details' },
|
|
||||||
{ value: 'connect', label: 'Connect' },
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormDefaultActionField label="Table click" objectTypeField="tables" />
|
<FormDefaultActionField
|
||||||
<FormDefaultActionField label="View click" objectTypeField="views" />
|
label="Table click"
|
||||||
<FormDefaultActionField label="Materialized view click" objectTypeField="matviews" />
|
objectTypeField="tables"
|
||||||
<FormDefaultActionField label="Procedure click" objectTypeField="procedures" />
|
disabled={values['defaultAction.useLastUsedAction'] !== false}
|
||||||
<FormDefaultActionField label="Function click" objectTypeField="functions" />
|
/>
|
||||||
|
<FormDefaultActionField
|
||||||
|
label="View click"
|
||||||
|
objectTypeField="views"
|
||||||
|
disabled={values['defaultAction.useLastUsedAction'] !== false}
|
||||||
|
/>
|
||||||
|
<FormDefaultActionField
|
||||||
|
label="Materialized view click"
|
||||||
|
objectTypeField="matviews"
|
||||||
|
disabled={values['defaultAction.useLastUsedAction'] !== false}
|
||||||
|
/>
|
||||||
|
<FormDefaultActionField
|
||||||
|
label="Procedure click"
|
||||||
|
objectTypeField="procedures"
|
||||||
|
disabled={values['defaultAction.useLastUsedAction'] !== false}
|
||||||
|
/>
|
||||||
|
<FormDefaultActionField
|
||||||
|
label="Function click"
|
||||||
|
objectTypeField="functions"
|
||||||
|
disabled={values['defaultAction.useLastUsedAction'] !== false}
|
||||||
|
/>
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
<svelte:fragment slot="5">
|
<svelte:fragment slot="5">
|
||||||
<div class="heading">Confirmations</div>
|
<div class="heading">Confirmations</div>
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ export const loadingPluginStore = writable({
|
|||||||
export const activeDbKeysStore = writableWithStorage({}, 'activeDbKeysStore');
|
export const activeDbKeysStore = writableWithStorage({}, 'activeDbKeysStore');
|
||||||
export const appliedCurrentSchema = writable<string>(null);
|
export const appliedCurrentSchema = writable<string>(null);
|
||||||
export const loadingSchemaLists = writable({}); // dict [`${conid}::${database}`]: true
|
export const loadingSchemaLists = writable({}); // dict [`${conid}::${database}`]: true
|
||||||
|
export const lastUsedDefaultActions = writableWithStorage({}, 'lastUsedDefaultActions');
|
||||||
|
|
||||||
export const selectedDatabaseObjectAppObject = writable(null);
|
export const selectedDatabaseObjectAppObject = writable(null);
|
||||||
export const focusedConnectionOrDatabase = writable<{ conid: string; database?: string; connection: any }>(null);
|
export const focusedConnectionOrDatabase = writable<{ conid: string; database?: string; connection: any }>(null);
|
||||||
@@ -352,3 +353,9 @@ openedSingleDatabaseConnections.subscribe(value => {
|
|||||||
openedSingleDatabaseConnectionsValue = value;
|
openedSingleDatabaseConnectionsValue = value;
|
||||||
});
|
});
|
||||||
export const getOpenedSingleDatabaseConnections = () => openedSingleDatabaseConnectionsValue;
|
export const getOpenedSingleDatabaseConnections = () => openedSingleDatabaseConnectionsValue;
|
||||||
|
|
||||||
|
let lastUsedDefaultActionsValue = {};
|
||||||
|
lastUsedDefaultActions.subscribe(value => {
|
||||||
|
lastUsedDefaultActionsValue = value;
|
||||||
|
});
|
||||||
|
export const getLastUsedDefaultActions = () => lastUsedDefaultActionsValue;
|
||||||
Reference in New Issue
Block a user