Fix Query tool issues:

1. Warning/Confirm dialogs should be inside the query tool.
2. The Help button in View/Edit data should open the corresponding help page.
3. Disable execute options when query tool in transaction.
4. Grid not loading more than 10000 rows. react-data-grid issue, PR sent. Use a fork till then.
5. NOTICE messages should not be part of Notifier success popups.

Fixes #7350
pull/85/head
Aditya Toshniwal 2022-05-09 12:39:29 +05:30 committed by Akshay Joshi
parent 5ebc9d7d2e
commit 1135821870
8 changed files with 34 additions and 28 deletions

View File

@ -2,7 +2,7 @@
Version 6.9 Version 6.9
************ ************
Release date: 2022-05-06 Release date: 2022-05-12
This release contains a number of bug fixes and new features since the release of pgAdmin4 6.8. This release contains a number of bug fixes and new features since the release of pgAdmin4 6.8.

View File

@ -151,7 +151,7 @@
"react": "^17.0.1", "react": "^17.0.1",
"react-aspen": "^1.1.0", "react-aspen": "^1.1.0",
"react-checkbox-tree": "^1.7.2", "react-checkbox-tree": "^1.7.2",
"react-data-grid": "^7.0.0-beta.12", "react-data-grid": "git+https://github.com/adityatoshniwal/react-data-grid.git/#0cbf9165a98bd723604c9c0d5954b50b179d3901",
"react-dom": "^17.0.1", "react-dom": "^17.0.1",
"react-draggable": "^4.4.4", "react-draggable": "^4.4.4",
"react-leaflet": "^3.2.2", "react-leaflet": "^3.2.2",

View File

@ -445,6 +445,7 @@ function SchemaDialogView({
const isNew = schema.isNew(schema.origData); const isNew = schema.isNew(schema.origData);
const checkIsMounted = useIsMounted(); const checkIsMounted = useIsMounted();
const preFormReadyQueue = useRef([]); const preFormReadyQueue = useRef([]);
const Notifier = props.Notifier || Notify;
const depListenerObj = useRef(new DepListener()); const depListenerObj = useRef(new DepListener());
/* The session data */ /* The session data */
@ -578,7 +579,7 @@ function SchemaDialogView({
}; };
/* Confirm before reset */ /* Confirm before reset */
if(props.confirmOnCloseReset) { if(props.confirmOnCloseReset) {
Notify.confirm( Notifier.confirm(
gettext('Warning'), gettext('Warning'),
gettext('Changes will be lost. Are you sure you want to reset?'), gettext('Changes will be lost. Are you sure you want to reset?'),
resetIt, resetIt,
@ -605,7 +606,7 @@ function SchemaDialogView({
changeData[schema.idAttribute] = schema.origData[schema.idAttribute]; changeData[schema.idAttribute] = schema.origData[schema.idAttribute];
} }
if (schema.warningText) { if (schema.warningText) {
Notify.confirm( Notifier.confirm(
gettext('Warning'), gettext('Warning'),
schema.warningText, schema.warningText,
()=> { ()=> {
@ -626,7 +627,7 @@ function SchemaDialogView({
props.onSave(isNew, changeData) props.onSave(isNew, changeData)
.then(()=>{ .then(()=>{
if(schema.informText) { if(schema.informText) {
Notify.alert( Notifier.alert(
gettext('Warning'), gettext('Warning'),
schema.informText, schema.informText,
); );
@ -785,6 +786,7 @@ SchemaDialogView.propTypes = {
customSaveBtnName: PropTypes.string, customSaveBtnName: PropTypes.string,
customSaveBtnIconType: PropTypes.string, customSaveBtnIconType: PropTypes.string,
formClassName: CustomPropTypes.className, formClassName: CustomPropTypes.className,
Notifier: PropTypes.object,
}; };
const usePropsStyles = makeStyles((theme)=>({ const usePropsStyles = makeStyles((theme)=>({

View File

@ -261,9 +261,12 @@ function initialiseColumns(columns, rows, totalRowCount, columnWidthBy) {
setEditorFormatter(col); setEditorFormatter(col);
} }
let rowNumWidth = canvasContext.measureText((totalRowCount||'').toString()).width;
/* padding 8 on both sides*/
rowNumWidth += 16;
let rowNumCol = { let rowNumCol = {
key: ROWNUM_KEY, name: '', frozen: true, resizable: false, key: ROWNUM_KEY, name: '', frozen: true, resizable: false,
minWidth: 45, width: canvasContext.measureText((totalRowCount||'').toString()).width, minWidth: 45, width: rowNumWidth,
}; };
rowNumCol.cellClass = cellClassGetter(rowNumCol); rowNumCol.cellClass = cellClassGetter(rowNumCol);
retColumns.unshift(rowNumCol); retColumns.unshift(rowNumCol);

View File

@ -249,6 +249,7 @@ export default function NewConnectionDialog({onClose, onSave}) {
disableDialogHelp={true} disableDialogHelp={true}
isTabView={false} isTabView={false}
formClassName={classes.root} formClassName={classes.root}
Notifier={queryToolCtx.modal}
/>; />;
} }

View File

@ -151,6 +151,7 @@ export function MainToolBar({containerRef, onFilterClick, onManageMacros}) {
'rollback': true, 'rollback': true,
'filter': true, 'filter': true,
'limit': false, 'limit': false,
'execute-options': !queryToolCtx.params.is_query_tool,
}); });
const {openMenuName, toggleMenu, onMenuClose} = usePgMenuGroup(); const {openMenuName, toggleMenu, onMenuClose} = usePgMenuGroup();
const [checkedMenuItems, setCheckedMenuItems] = React.useState({}); const [checkedMenuItems, setCheckedMenuItems] = React.useState({});
@ -306,9 +307,11 @@ export function MainToolBar({containerRef, onFilterClick, onManageMacros}) {
if(isInTxn()) { if(isInTxn()) {
setDisableButton('commit', false); setDisableButton('commit', false);
setDisableButton('rollback', false); setDisableButton('rollback', false);
setDisableButton('execute-options', true);
} else { } else {
setDisableButton('commit', true); setDisableButton('commit', true);
setDisableButton('rollback', true); setDisableButton('rollback', true);
setDisableButton('execute-options', !queryToolCtx.params.is_query_tool);
} }
eventBus.registerListener(QUERY_TOOL_EVENTS.WARN_TXN_CLOSE, warnTxnClose); eventBus.registerListener(QUERY_TOOL_EVENTS.WARN_TXN_CLOSE, warnTxnClose);
return ()=>{ return ()=>{
@ -338,7 +341,7 @@ export function MainToolBar({containerRef, onFilterClick, onManageMacros}) {
}); });
}; };
const onHelpClick=()=>{ const onHelpClick=()=>{
let url = url_for('help.static', {'filename': 'query_tool.html'}); let url = url_for('help.static', {'filename': queryToolCtx.params.is_query_tool ? 'query_tool.html' : 'editgrid.html'});
window.open(url, 'pgadmin_help'); window.open(url, 'pgadmin_help');
}; };
const confirmDiscard=(callback)=>{ const confirmDiscard=(callback)=>{
@ -504,7 +507,7 @@ export function MainToolBar({containerRef, onFilterClick, onManageMacros}) {
onClick={executeQuery} disabled={buttonsDisabled['execute']} shortcut={queryToolPref.execute_query}/> onClick={executeQuery} disabled={buttonsDisabled['execute']} shortcut={queryToolPref.execute_query}/>
<PgIconButton title={gettext('Execute options')} icon={<KeyboardArrowDownIcon />} splitButton <PgIconButton title={gettext('Execute options')} icon={<KeyboardArrowDownIcon />} splitButton
name="menu-autocommit" ref={autoCommitMenuRef} accesskey={shortcut_key(queryToolPref.btn_delete_row)} name="menu-autocommit" ref={autoCommitMenuRef} accesskey={shortcut_key(queryToolPref.btn_delete_row)}
onClick={toggleMenu} disabled={!queryToolCtx.params.is_query_tool}/> onClick={toggleMenu} disabled={buttonsDisabled['execute-options']}/>
</PgButtonGroup> </PgButtonGroup>
<PgButtonGroup size="small"> <PgButtonGroup size="small">
<PgIconButton title={gettext('Explain')} icon={<ExplicitRoundedIcon />} <PgIconButton title={gettext('Explain')} icon={<ExplicitRoundedIcon />}

View File

@ -618,14 +618,17 @@ export class ResultSetUtils {
this.eventBus.fireEvent(QUERY_TOOL_EVENTS.TASK_END, gettext('Query complete'), endTime); this.eventBus.fireEvent(QUERY_TOOL_EVENTS.TASK_END, gettext('Query complete'), endTime);
this.setEndTime(endTime); this.setEndTime(endTime);
let msg = gettext('Query returned successfully in %s.', this.queryRunTime()); let retMsg, tabMsg;
retMsg = tabMsg = gettext('Query returned successfully in %s.', this.queryRunTime());
if(this.hasResultsToDisplay(httpMessage.data.data)) { if(this.hasResultsToDisplay(httpMessage.data.data)) {
msg = gettext('Successfully run. Total query runtime: %s.', this.queryRunTime()) let msg1 = gettext('Successfully run. Total query runtime: %s.', this.queryRunTime());
+ '\n' + gettext('%s rows affected.', httpMessage.data.data?.rows_affected); let msg2 = gettext('%s rows affected.', httpMessage.data.data?.rows_affected);
retMsg = msg1 + ' ' + msg2;
tabMsg = msg1 + '\n' + msg2;
if(!_.isNull(httpMessage.data.data.additional_messages)){ if(!_.isNull(httpMessage.data.data.additional_messages)){
msg = httpMessage.data.data.additional_messages + '\n' + msg; tabMsg = httpMessage.data.data.additional_messages + '\n' + tabMsg;
} }
this.eventBus.fireEvent(QUERY_TOOL_EVENTS.SET_MESSAGE, msg); this.eventBus.fireEvent(QUERY_TOOL_EVENTS.SET_MESSAGE, tabMsg);
this.setClientPK(httpMessage.data.data.client_primary_key); this.setClientPK(httpMessage.data.data.client_primary_key);
let {result} = httpMessage.data.data; let {result} = httpMessage.data.data;
let data = { let data = {
@ -646,12 +649,12 @@ export class ResultSetUtils {
} }
} else { } else {
if (httpMessage.data.data.result) { if (httpMessage.data.data.result) {
msg = httpMessage.data.data.result + '\n\n' + msg; tabMsg = httpMessage.data.data.result + '\n\n' + tabMsg;
} }
this.eventBus.fireEvent(QUERY_TOOL_EVENTS.SET_MESSAGE, msg, true); this.eventBus.fireEvent(QUERY_TOOL_EVENTS.SET_MESSAGE, tabMsg, true);
this.eventBus.fireEvent(QUERY_TOOL_EVENTS.FOCUS_PANEL, PANELS.MESSAGES); this.eventBus.fireEvent(QUERY_TOOL_EVENTS.FOCUS_PANEL, PANELS.MESSAGES);
} }
return msg; return retMsg;
} }
} }

View File

@ -3629,15 +3629,10 @@ caniuse-api@^3.0.0:
lodash.memoize "^4.1.2" lodash.memoize "^4.1.2"
lodash.uniq "^4.5.0" lodash.uniq "^4.5.0"
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001286: caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001272, caniuse-lite@^1.0.30001274, caniuse-lite@^1.0.30001286:
version "1.0.30001309" version "1.0.30001338"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001309.tgz" resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001338.tgz"
integrity sha512-Pl8vfigmBXXq+/yUz1jUwULeq9xhMJznzdc/xwl4WclDAuebcTHVefpz8lE/bMI+UN7TOkSSe7B7RnZd6+dzjA== integrity sha512-1gLHWyfVoRDsHieO+CaeYe7jSo/MT7D7lhaXUiwwbuR5BwQxORs0f1tAwUSQr3YbxRXJvxHM/PA5FfPQRnsPeQ==
caniuse-lite@^1.0.30001272, caniuse-lite@^1.0.30001274:
version "1.0.30001278"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001278.tgz#51cafc858df77d966b17f59b5839250b24417fff"
integrity sha512-mpF9KeH8u5cMoEmIic/cr7PNS+F5LWBk0t2ekGT60lFf0Wq+n9LspAj0g3P+o7DQhD3sUdlMln4YFAWhFYn9jg==
caw@^2.0.0, caw@^2.0.1: caw@^2.0.0, caw@^2.0.1:
version "2.0.1" version "2.0.1"
@ -8882,10 +8877,9 @@ react-checkbox-tree@^1.7.2:
nanoid "^3.0.0" nanoid "^3.0.0"
prop-types "^15.5.8" prop-types "^15.5.8"
react-data-grid@^7.0.0-beta.12: "react-data-grid@git+https://github.com/adityatoshniwal/react-data-grid.git/#0cbf9165a98bd723604c9c0d5954b50b179d3901":
version "7.0.0-beta.12" version "7.0.0-beta.12"
resolved "https://registry.yarnpkg.com/react-data-grid/-/react-data-grid-7.0.0-beta.12.tgz#a6310a83a7ad4913a595a8b2a667e4951a95dc58" resolved "git+https://github.com/adityatoshniwal/react-data-grid.git/#0cbf9165a98bd723604c9c0d5954b50b179d3901"
integrity sha512-cgKE4fl/glKllpfY444H1ZF4mNDUfIU7kyrSYVUy8W1npTvGk9CL++ASs1pTSSi2Eg2Sx7vqnC1gEx6C92Kqjw==
dependencies: dependencies:
clsx "^1.1.1" clsx "^1.1.1"