From 474d3962e2673baa8114c8534bfa00eb9f036fd2 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Thu, 8 Oct 2020 15:42:53 +0200 Subject: [PATCH] show generated query --- .../web/src/datagrid/DataGridContextMenu.js | 6 +++--- packages/web/src/datagrid/DataGridCore.js | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/packages/web/src/datagrid/DataGridContextMenu.js b/packages/web/src/datagrid/DataGridContextMenu.js index 5664bf64..34acf765 100644 --- a/packages/web/src/datagrid/DataGridContextMenu.js +++ b/packages/web/src/datagrid/DataGridContextMenu.js @@ -10,6 +10,7 @@ export default function DataGridContextMenu({ reload, exportGrid, filterSelectedValue, + openQuery, }) { return ( <> @@ -33,12 +34,11 @@ export default function DataGridContextMenu({ Set NULL - - Export - + Export Filter selected value + {openQuery && Open query} ); } diff --git a/packages/web/src/datagrid/DataGridCore.js b/packages/web/src/datagrid/DataGridCore.js index e97e71f1..b20397a9 100644 --- a/packages/web/src/datagrid/DataGridCore.js +++ b/packages/web/src/datagrid/DataGridCore.js @@ -44,6 +44,8 @@ import ErrorInfo from '../widgets/ErrorInfo'; import useShowModal from '../modals/showModal'; import ErrorMessageModal from '../modals/ErrorMessageModal'; import ImportExportModal from '../modals/ImportExportModal'; +import { openNewTab } from '../utility/common'; +import { useSetOpenedTabs } from '../utility/globalState'; const GridContainer = styled.div` position: absolute; @@ -239,6 +241,7 @@ export default function DataGridCore(props) { const changeSet = changeSetState && changeSetState.value; const setChangeSet = React.useCallback((value) => dispatchChangeSet({ type: 'set', value }), [dispatchChangeSet]); + const setOpenedTabs = useSetOpenedTabs(); const changeSetRef = React.useRef(changeSet); @@ -560,6 +563,7 @@ export default function DataGridCore(props) { setNull={setNull} exportGrid={exportGrid} filterSelectedValue={filterSelectedValue} + openQuery={display.baseTable ? openQuery : null} /> ); }; @@ -845,6 +849,21 @@ export default function DataGridCore(props) { display.setFilters(flts); } + function openQuery() { + openNewTab(setOpenedTabs, { + title: 'Query', + icon: 'sql.svg', + tabComponent: 'QueryTab', + props: { + initialScript: display.getExportQuery(), + schemaName: display.baseTable.schemaName, + pureName: display.baseTable.pureName, + conid, + database, + }, + }); + } + function revertAllChanges() { setChangeSet(createChangeSet()); }