From a8265cebff64274537aea4881c41c45ef725eb2a Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Sat, 12 Feb 2022 18:08:25 +0100 Subject: [PATCH] quick export from table data grid toolstrip --- .../web/src/buttons/ToolStripButton.svelte | 2 +- .../buttons/ToolStripDropDownButton.svelte | 7 +++- .../src/buttons/ToolStripExportButton.svelte | 0 packages/web/src/datagrid/DataGridCore.svelte | 2 + .../web/src/datagrid/SqlDataGridCore.svelte | 40 +++++++++++-------- packages/web/src/icons/FontIcon.svelte | 1 + packages/web/src/tabs/TableDataTab.svelte | 17 ++++++++ packages/web/src/tabs/ViewDataTab.svelte | 28 ++++++++----- packages/web/src/utility/contextMenu.ts | 2 +- .../web/src/utility/createQuickExportMenu.ts | 19 +++++++-- 10 files changed, 83 insertions(+), 35 deletions(-) create mode 100644 packages/web/src/buttons/ToolStripExportButton.svelte diff --git a/packages/web/src/buttons/ToolStripButton.svelte b/packages/web/src/buttons/ToolStripButton.svelte index f4e7ee2f..7016bd0c 100644 --- a/packages/web/src/buttons/ToolStripButton.svelte +++ b/packages/web/src/buttons/ToolStripButton.svelte @@ -11,7 +11,7 @@ function handleClick(e) { if (disabled) return; - dispatch('click'); + dispatch('click', { target: e.target }); } diff --git a/packages/web/src/buttons/ToolStripDropDownButton.svelte b/packages/web/src/buttons/ToolStripDropDownButton.svelte index 82b6de12..5a06ab9a 100644 --- a/packages/web/src/buttons/ToolStripDropDownButton.svelte +++ b/packages/web/src/buttons/ToolStripDropDownButton.svelte @@ -1,16 +1,18 @@ @@ -135,6 +150,8 @@ + + diff --git a/packages/web/src/tabs/ViewDataTab.svelte b/packages/web/src/tabs/ViewDataTab.svelte index 737901d2..fb38195d 100644 --- a/packages/web/src/tabs/ViewDataTab.svelte +++ b/packages/web/src/tabs/ViewDataTab.svelte @@ -8,6 +8,8 @@ import { findEngineDriver } from 'dbgate-tools'; import { setContext } from 'svelte'; import { writable } from 'svelte/store'; +import ToolStripCommandButton from '../buttons/ToolStripCommandButton.svelte'; +import ToolStripContainer from '../buttons/ToolStripContainer.svelte'; import DataGrid from '../datagrid/DataGrid.svelte'; import SqlDataGridCore from '../datagrid/SqlDataGridCore.svelte'; @@ -51,16 +53,22 @@ {#if display} - + + + + + + + {/if} { if (command.getSubCommands) visibleCommandPalette.set(command); diff --git a/packages/web/src/utility/createQuickExportMenu.ts b/packages/web/src/utility/createQuickExportMenu.ts index 4b6e0086..5872ade5 100644 --- a/packages/web/src/utility/createQuickExportMenu.ts +++ b/packages/web/src/utility/createQuickExportMenu.ts @@ -1,6 +1,20 @@ import { ExtensionsDirectory, QuickExportDefinition } from 'dbgate-types'; import getElectron from './getElectron'; +export function createQuickExportMenuItems( + extensions: ExtensionsDirectory, + handler: (fmt: QuickExportDefinition) => Function +) { + const electron = getElectron(); + if (!electron) { + return null; + } + return extensions.quickExports.map(fmt => ({ + text: fmt.label, + onClick: handler(fmt), + })); +} + export default function createQuickExportMenu( extensions: ExtensionsDirectory, handler: (fmt: QuickExportDefinition) => Function @@ -11,9 +25,6 @@ export default function createQuickExportMenu( } return { text: 'Quick export', - submenu: extensions.quickExports.map(fmt => ({ - text: fmt.label, - onClick: handler(fmt), - })), + submenu: createQuickExportMenuItems(extensions, handler), }; }