show generated query

This commit is contained in:
Jan Prochazka 2020-10-08 15:42:53 +02:00
parent 3819bf9bd7
commit 474d3962e2
2 changed files with 22 additions and 3 deletions

View File

@ -10,6 +10,7 @@ export default function DataGridContextMenu({
reload,
exportGrid,
filterSelectedValue,
openQuery,
}) {
return (
<>
@ -33,12 +34,11 @@ export default function DataGridContextMenu({
<DropDownMenuItem onClick={setNull} keyText="Ctrl+0">
Set NULL
</DropDownMenuItem>
<DropDownMenuItem onClick={exportGrid} >
Export
</DropDownMenuItem>
<DropDownMenuItem onClick={exportGrid}>Export</DropDownMenuItem>
<DropDownMenuItem onClick={filterSelectedValue} keyText="Ctrl+F">
Filter selected value
</DropDownMenuItem>
{openQuery && <DropDownMenuItem onClick={openQuery}>Open query</DropDownMenuItem>}
</>
);
}

View File

@ -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());
}