tabstrips

This commit is contained in:
Jan Prochazka
2022-02-13 08:22:23 +01:00
parent 488b200fcb
commit e0b8eb3e79
10 changed files with 354 additions and 291 deletions

View File

@@ -19,8 +19,8 @@ module.exports = [
label: 'Window', label: 'Window',
submenu: [ submenu: [
{ command: 'new.query', hideDisabled: true }, { command: 'new.query', hideDisabled: true },
{ command: 'new.modelCompare', hideDisabled: true },
{ command: 'new.freetable', hideDisabled: true }, { command: 'new.freetable', hideDisabled: true },
{ command: 'new.shell', hideDisabled: true },
{ divider: true }, { divider: true },
{ command: 'tabs.closeTab', hideDisabled: true }, { command: 'tabs.closeTab', hideDisabled: true },
{ command: 'tabs.closeAll', hideDisabled: true }, { command: 'tabs.closeAll', hideDisabled: true },
@@ -50,6 +50,14 @@ module.exports = [
{ command: 'settings.show' }, { command: 'settings.show' },
], ],
}, },
{
label: 'Tools',
submenu: [
{ command: 'sql.generator' },
{ command: 'file.import' },
{ command: 'new.modelCompare' },
],
},
{ {
label: 'Help', label: 'Help',
submenu: [ submenu: [

View File

@@ -12,11 +12,12 @@
export let command; export let command;
export let component = ToolStripButton; export let component = ToolStripButton;
export let hideDisabled = false;
$: cmd = Object.values($commandsCustomized).find((x: any) => x.id == command) as any; $: cmd = Object.values($commandsCustomized).find((x: any) => x.id == command) as any;
</script> </script>
{#if cmd} {#if cmd && (!hideDisabled || cmd.enabled)}
<svelte:component <svelte:component
this={component} this={component}
title={getCommandTitle(cmd)} title={getCommandTitle(cmd)}

View File

@@ -103,6 +103,7 @@ registerCommand({
category: 'New', category: 'New',
icon: 'img shell', icon: 'img shell',
name: 'JavaScript Shell', name: 'JavaScript Shell',
menuName:' New JavaScript shell',
onClick: () => { onClick: () => {
openNewTab({ openNewTab({
title: 'Shell #', title: 'Shell #',
@@ -539,6 +540,7 @@ export function registerFileCommands({
category, category,
name: 'Undo', name: 'Undo',
group: 'undo', group: 'undo',
icon: 'icon undo',
testEnabled: () => getCurrentEditor()?.canUndo(), testEnabled: () => getCurrentEditor()?.canUndo(),
onClick: () => getCurrentEditor().undo(), onClick: () => getCurrentEditor().undo(),
}); });
@@ -547,6 +549,7 @@ export function registerFileCommands({
category, category,
group: 'redo', group: 'redo',
name: 'Redo', name: 'Redo',
icon: 'icon redo',
testEnabled: () => getCurrentEditor()?.canRedo(), testEnabled: () => getCurrentEditor()?.canRedo(),
onClick: () => getCurrentEditor().redo(), onClick: () => getCurrentEditor().redo(),
}); });

View File

@@ -356,6 +356,7 @@
return {}; return {};
}, {}); }, {});
registerMenu( registerMenu(
{ command: 'dataForm.refresh' },
{ placeTag: 'switch' }, { placeTag: 'switch' },
{ command: 'dataForm.copyToClipboard' }, { command: 'dataForm.copyToClipboard' },
{ divider: true }, { divider: true },

View File

@@ -1,60 +1,60 @@
<script lang="ts" context="module"> <script lang="ts" context="module">
const getCurrentEditor = () => getActiveComponent('TableEditor'); const getCurrentEditor = () => getActiveComponent('TableEditor');
// registerCommand({ registerCommand({
// id: 'tableEditor.addColumn', id: 'tableEditor.addColumn',
// category: 'Table editor', category: 'Table editor',
// name: 'Add column', name: 'Add column',
// icon: 'icon add-column', icon: 'icon add-column',
// toolbar: true, toolbar: true,
// isRelatedToTab: true, isRelatedToTab: true,
// testEnabled: () => getCurrentEditor()?.writable(), testEnabled: () => getCurrentEditor()?.writable(),
// onClick: () => getCurrentEditor().addColumn(), onClick: () => getCurrentEditor().addColumn(),
// }); });
// registerCommand({ registerCommand({
// id: 'tableEditor.addPrimaryKey', id: 'tableEditor.addPrimaryKey',
// category: 'Table editor', category: 'Table editor',
// name: 'Add primary key', name: 'Add primary key',
// icon: 'icon add-key', icon: 'icon add-key',
// toolbar: true, toolbar: true,
// isRelatedToTab: true, isRelatedToTab: true,
// testEnabled: () => getCurrentEditor()?.allowAddPrimaryKey(), testEnabled: () => getCurrentEditor()?.allowAddPrimaryKey(),
// onClick: () => getCurrentEditor().addPrimaryKey(), onClick: () => getCurrentEditor().addPrimaryKey(),
// }); });
// registerCommand({ registerCommand({
// id: 'tableEditor.addForeignKey', id: 'tableEditor.addForeignKey',
// category: 'Table editor', category: 'Table editor',
// name: 'Add foreign key', name: 'Add foreign key',
// icon: 'icon add-key', icon: 'icon add-key',
// toolbar: true, toolbar: true,
// isRelatedToTab: true, isRelatedToTab: true,
// testEnabled: () => getCurrentEditor()?.writable(), testEnabled: () => getCurrentEditor()?.writable(),
// onClick: () => getCurrentEditor().addForeignKey(), onClick: () => getCurrentEditor().addForeignKey(),
// }); });
// registerCommand({ registerCommand({
// id: 'tableEditor.addIndex', id: 'tableEditor.addIndex',
// category: 'Table editor', category: 'Table editor',
// name: 'Add index', name: 'Add index',
// icon: 'icon add-key', icon: 'icon add-key',
// toolbar: true, toolbar: true,
// isRelatedToTab: true, isRelatedToTab: true,
// testEnabled: () => getCurrentEditor()?.writable(), testEnabled: () => getCurrentEditor()?.writable(),
// onClick: () => getCurrentEditor().addIndex(), onClick: () => getCurrentEditor().addIndex(),
// }); });
// registerCommand({ registerCommand({
// id: 'tableEditor.addUnique', id: 'tableEditor.addUnique',
// category: 'Table editor', category: 'Table editor',
// name: 'Add unique', name: 'Add unique',
// icon: 'icon add-key', icon: 'icon add-key',
// toolbar: true, toolbar: true,
// isRelatedToTab: true, isRelatedToTab: true,
// testEnabled: () => getCurrentEditor()?.writable(), testEnabled: () => getCurrentEditor()?.writable(),
// onClick: () => getCurrentEditor().addUnique(), onClick: () => getCurrentEditor().addUnique(),
// }); });
</script> </script>
<script lang="ts"> <script lang="ts">
@@ -105,9 +105,9 @@
}); });
} }
// export function allowAddPrimaryKey() { export function allowAddPrimaryKey() {
// return writable() && !tableInfo?.primaryKey; return writable() && !tableInfo?.primaryKey;
// } }
export function addPrimaryKey() { export function addPrimaryKey() {
showModal(PrimaryKeyEditorModal, { showModal(PrimaryKeyEditorModal, {

View File

@@ -162,6 +162,8 @@
import { useArchiveFolders, useConnectionInfo, useDatabaseInfo } from '../utility/metadataLoaders'; import { useArchiveFolders, useConnectionInfo, useDatabaseInfo } from '../utility/metadataLoaders';
import resolveApi from '../utility/resolveApi'; import resolveApi from '../utility/resolveApi';
import { showSnackbarSuccess } from '../utility/snackbar'; import { showSnackbarSuccess } from '../utility/snackbar';
import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
import ToolStripCommandButton from '../buttons/ToolStripCommandButton.svelte';
export let tabid; export let tabid;
@@ -336,6 +338,7 @@
const menu = getContextMenu(); const menu = getContextMenu();
</script> </script>
<ToolStripContainer>
<div class="wrapper" use:contextMenu={menu}> <div class="wrapper" use:contextMenu={menu}>
<VerticalSplitter> <VerticalSplitter>
<div slot="1" class="flexcol"> <div slot="1" class="flexcol">
@@ -556,6 +559,13 @@
</svelte:fragment> </svelte:fragment>
</VerticalSplitter> </VerticalSplitter>
</div> </div>
<svelte:fragment slot="toolstrip">
<ToolStripCommandButton command="compareModels.reportDiff" />
<ToolStripCommandButton command="compareModels.swap" />
<ToolStripCommandButton command="compareModels.deploy" />
<ToolStripCommandButton command="compareModels.refresh" />
</svelte:fragment>
</ToolStripContainer>
<style> <style>
.wrapper { .wrapper {

View File

@@ -23,6 +23,9 @@
import { findEngineDriver } from 'dbgate-tools'; import { findEngineDriver } from 'dbgate-tools';
import createActivator, { getActiveComponent } from '../utility/createActivator'; import createActivator, { getActiveComponent } from '../utility/createActivator';
import DiagramDesigner from '../designer/DiagramDesigner.svelte'; import DiagramDesigner from '../designer/DiagramDesigner.svelte';
import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
import ToolStripCommandButton from '../buttons/ToolStripCommandButton.svelte';
import invalidateCommands from '../commands/invalidateCommands';
export let tabid; export let tabid;
export let conid; export let conid;
@@ -47,6 +50,7 @@
export function undo() { export function undo() {
dispatchModel({ type: 'undo' }); dispatchModel({ type: 'undo' });
invalidateCommands();
} }
export function canRedo() { export function canRedo() {
@@ -55,20 +59,24 @@
export function redo() { export function redo() {
dispatchModel({ type: 'redo' }); dispatchModel({ type: 'redo' });
invalidateCommands();
} }
const handleChange = (value, skipUndoChain) => const handleChange = (value, skipUndoChain) => {
// @ts-ignore // @ts-ignore
dispatchModel({ dispatchModel({
type: 'compute', type: 'compute',
useMerge: skipUndoChain, useMerge: skipUndoChain,
compute: v => (_.isFunction(value) ? value(v) : value), compute: v => (_.isFunction(value) ? value(v) : value),
}); });
invalidateCommands();
};
const { editorState, editorValue, setEditorData } = useEditorData({ const { editorState, editorValue, setEditorData } = useEditorData({
tabid, tabid,
onInitialData: value => { onInitialData: value => {
dispatchModel({ type: 'reset', value }); dispatchModel({ type: 'reset', value });
invalidateCommands();
}, },
}); });
@@ -90,4 +98,13 @@
} }
</script> </script>
<ToolStripContainer>
<DiagramDesigner value={$modelState.value || {}} {conid} {database} onChange={handleChange} menu={createMenu} /> <DiagramDesigner value={$modelState.value || {}} {conid} {database} onChange={handleChange} menu={createMenu} />
<svelte:fragment slot="toolstrip">
<ToolStripCommandButton command="designer.arrange" />
<ToolStripCommandButton command="diagram.save" />
<ToolStripCommandButton command="diagram.export" />
<ToolStripCommandButton command="diagram.undo" />
<ToolStripCommandButton command="diagram.redo" />
</svelte:fragment>
</ToolStripContainer>

View File

@@ -37,6 +37,8 @@
<script lang="ts"> <script lang="ts">
import { getContext } from 'svelte'; import { getContext } from 'svelte';
import ToolStripCommandButton from '../buttons/ToolStripCommandButton.svelte';
import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
import invalidateCommands from '../commands/invalidateCommands'; import invalidateCommands from '../commands/invalidateCommands';
import registerCommand from '../commands/registerCommand'; import registerCommand from '../commands/registerCommand';
@@ -211,6 +213,7 @@
} }
</script> </script>
<ToolStripContainer>
<VerticalSplitter> <VerticalSplitter>
<svelte:fragment slot="1"> <svelte:fragment slot="1">
<AceEditor <AceEditor
@@ -229,3 +232,10 @@
<RunnerOutputPane {runnerId} {executeNumber} /> <RunnerOutputPane {runnerId} {executeNumber} />
</svelte:fragment> </svelte:fragment>
</VerticalSplitter> </VerticalSplitter>
<svelte:fragment slot="toolstrip">
<ToolStripCommandButton command="shell.execute" />
<ToolStripCommandButton command="shell.kill" />
<ToolStripCommandButton command="shell.save" />
<ToolStripCommandButton command="shell.copyNodeScript" />
</svelte:fragment>
</ToolStripContainer>

View File

@@ -137,10 +137,13 @@
/> />
<svelte:fragment slot="toolstrip"> <svelte:fragment slot="toolstrip">
<ToolStripCommandButton command="dataGrid.refresh" /> <ToolStripCommandButton command="dataGrid.refresh" hideDisabled />
<ToolStripCommandButton command="dataForm.refresh" hideDisabled />
<ToolStripCommandButton command="tableData.save" /> <ToolStripCommandButton command="tableData.save" />
<ToolStripCommandButton command="dataGrid.insertNewRow" /> <ToolStripCommandButton command="dataGrid.insertNewRow" hideDisabled />
<ToolStripCommandButton command="dataGrid.deleteSelectedRows" /> <ToolStripCommandButton command="dataGrid.deleteSelectedRows" hideDisabled />
<ToolStripCommandButton command="dataGrid.switchToForm" hideDisabled />
<ToolStripCommandButton command="dataGrid.switchToTable" hideDisabled />
<ToolStripExportButton {quickExportHandlerRef} /> <ToolStripExportButton {quickExportHandlerRef} />
</svelte:fragment> </svelte:fragment>
</ToolStripContainer> </ToolStripContainer>

View File

@@ -58,6 +58,8 @@
import StatusBarTabItem from '../widgets/StatusBarTabItem.svelte'; import StatusBarTabItem from '../widgets/StatusBarTabItem.svelte';
import openNewTab from '../utility/openNewTab'; import openNewTab from '../utility/openNewTab';
import { apiCall } from '../utility/api'; import { apiCall } from '../utility/api';
import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
import ToolStripCommandButton from '../buttons/ToolStripCommandButton.svelte';
export let tabid; export let tabid;
export let conid; export let conid;
@@ -162,6 +164,7 @@
// } // }
</script> </script>
<ToolStripContainer>
<TableEditor <TableEditor
bind:this={domEditor} bind:this={domEditor}
tableInfo={showTable} tableInfo={showTable}
@@ -182,6 +185,13 @@
) )
: null} : null}
/> />
<svelte:fragment slot="toolstrip">
<ToolStripCommandButton command="tableStructure.save" />
<ToolStripCommandButton command="tableStructure.reset" />
<ToolStripCommandButton command="tableEditor.addColumn" />
<ToolStripCommandButton command="tableEditor.addIndex" />
</svelte:fragment>
</ToolStripContainer>
{#if objectTypeField == 'tables'} {#if objectTypeField == 'tables'}
<StatusBarTabItem <StatusBarTabItem