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