Merge branch 'master' into feature/tab-preview-mode

This commit is contained in:
Jan Prochazka
2024-11-22 08:35:28 +01:00
9 changed files with 68 additions and 5 deletions

View File

@@ -2,18 +2,22 @@ import { openedModals } from '../stores';
import { get } from 'svelte/store';
import uuidv1 from 'uuid/v1';
import _ from 'lodash';
import invalidateCommands from '../commands/invalidateCommands';
export function showModal(component, props = {}) {
const modalId = uuidv1();
openedModals.update(x => [...x, { component, modalId, props }]);
invalidateCommands();
}
export function closeModal(modalId) {
openedModals.update(x => x.filter(y => y.modalId != modalId));
invalidateCommands();
}
export function closeCurrentModal() {
openedModals.update(modals => modals.slice(0, modals.length - 1));
invalidateCommands();
}
export function getActiveModalId() {

View File

@@ -59,6 +59,7 @@
on:blur
bind:this={domEditor}
options={{
...$$props.options,
enableBasicAutocompletion: true,
}}
/>

View File

@@ -21,6 +21,7 @@
import SqlEditor from '../query/SqlEditor.svelte';
import {
currentEditorFontSize,
currentEditorWrapEnabled,
currentEditorTheme,
currentEditorKeybindigMode,
extensions,
@@ -163,6 +164,14 @@ ORDER BY
/>
</FormFieldTemplateLarge>
</div>
<div class="col-3">
<FormFieldTemplateLarge label="Enable word wrap" type="combo">
<CheckboxField
checked={$currentEditorWrapEnabled}
on:change={e => ($currentEditorWrapEnabled = e.target.checked)}
/>
</FormFieldTemplateLarge>
</div>
</div>
</svelte:fragment>
<svelte:fragment slot="2">

View File

@@ -108,6 +108,9 @@ export const currentEditorTheme = getElectron()
export const currentEditorKeybindigMode = getElectron()
? writableSettingsValue(null, 'currentEditorKeybindigMode')
: writableWithStorage(null, 'currentEditorKeybindigMode');
export const currentEditorWrapEnabled = getElectron()
? writableSettingsValue(false, 'currentEditorWrapEnabled')
: writableWithStorage(false, 'currentEditorWrapEnabled');
export const currentEditorFontSize = getElectron()
? writableSettingsValue(null, 'currentEditorFontSize')
: writableWithStorage(null, 'currentEditorFontSize');
@@ -330,3 +333,9 @@ selectedDatabaseObjectAppObject.subscribe(value => {
selectedDatabaseObjectAppObjectValue = value;
});
export const getSelectedDatabaseObjectAppObject = () => selectedDatabaseObjectAppObjectValue;
let openedModalsValue = [];
openedModals.subscribe(value => {
openedModalsValue = value;
});
export const getOpenedModals = () => openedModalsValue;

View File

@@ -155,6 +155,19 @@
);
const closeOthersInMultiTab = multiTabIndex =>
closeTabFunc((x, active) => x.tabid != active.tabid && (x.multiTabIndex || 0) == multiTabIndex);
const reopenClosedTab = () => {
const lastClosedTabId = getOpenedTabs()
.filter(x => x.closedTime)
.sort((a, b) => b.closedTime - a.closedTime)[0]?.tabid;
if (!lastClosedTabId) return;
openedTabs.update(x =>
x.map(tab =>
tab.tabid === lastClosedTabId ? { ...tab, selected: true, closedTime: null } : { ...tab, selected: false }
)
);
};
function getTabDbName(tab, connectionList) {
if (tab.tabComponent == 'ConnectionTab') return 'Connections';
@@ -224,7 +237,12 @@
category: 'Tabs',
name: 'Close tab',
keyText: isElectronAvailable() ? 'CtrlOrCommand+W' : null,
testEnabled: () => getOpenedTabs().filter(x => !x.closedTime).length >= 1,
testEnabled: () => {
const hasAnyOtherTab = getOpenedTabs().filter(x => !x.closedTime).length >= 1;
const hasAnyModalOpen = getOpenedModals().length > 0;
return hasAnyOtherTab && !hasConfirmModalOpen;
},
onClick: closeCurrentTab,
});
@@ -244,6 +262,15 @@
onClick: closeTabsButCurrentDb,
});
registerCommand({
id: 'tabs.reopenClosedTab',
category: 'Tabs',
name: 'Reopen closed tab',
keyText: 'CtrlOrCommand+Shift+T',
testEnabled: () => getOpenedTabs().filter(x => x.closedTime).length >= 1,
onClick: reopenClosedTab,
});
registerCommand({
id: 'tabs.addToFavorites',
category: 'Tabs',
@@ -283,6 +310,7 @@
draggingDbGroupTarget,
draggingTab,
draggingTabTarget,
getOpenedModals,
} from '../stores';
import tabs from '../tabs';
import { setSelectedTab, switchCurrentDatabase } from '../utility/common';

View File

@@ -62,7 +62,7 @@
import VerticalSplitter from '../elements/VerticalSplitter.svelte';
import SqlEditor from '../query/SqlEditor.svelte';
import useEditorData from '../query/useEditorData';
import { extensions } from '../stores';
import { currentEditorWrapEnabled, extensions } from '../stores';
import applyScriptTemplate from '../utility/applyScriptTemplate';
import { changeTab, markTabUnsaved } from '../utility/common';
import { getDatabaseInfo, useConnectionInfo } from '../utility/metadataLoaders';
@@ -154,6 +154,7 @@
$: connection = useConnectionInfo({ conid });
$: driver = findEngineDriver($connection, $extensions);
$: enableWrap = $currentEditorWrapEnabled || false;
$: effect = useEffect(() => {
return onSession(sessionId);
@@ -427,6 +428,9 @@
{conid}
{database}
splitterOptions={driver?.getQuerySplitterOptions('editor')}
options={{
wrap: enableWrap,
}}
value={$editorState.value || ''}
menu={createMenu()}
on:input={e => {
@@ -453,6 +457,9 @@
mode={driver?.editorMode || 'sql'}
value={$editorState.value || ''}
splitterOptions={driver?.getQuerySplitterOptions('editor')}
options={{
wrap: enableWrap,
}}
menu={createMenu()}
on:input={e => setEditorData(e.detail)}
on:focus={() => {