mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Do not allow to save invalid JSON in query tool JSON editor. #5822
This commit is contained in:
parent
8967a510c9
commit
08062e67ca
@ -122,7 +122,6 @@
|
|||||||
"jquery-contextmenu": "^2.9.2",
|
"jquery-contextmenu": "^2.9.2",
|
||||||
"json-bignumber": "^1.0.1",
|
"json-bignumber": "^1.0.1",
|
||||||
"jsoneditor": "^9.5.4",
|
"jsoneditor": "^9.5.4",
|
||||||
"jsoneditor-react": "^3.1.1",
|
|
||||||
"karma-coverage": "^2.0.3",
|
"karma-coverage": "^2.0.3",
|
||||||
"leaflet": "^1.5.1",
|
"leaflet": "^1.5.1",
|
||||||
"lodash": "4.*",
|
"lodash": "4.*",
|
||||||
|
@ -536,13 +536,13 @@ export class Tree {
|
|||||||
*/
|
*/
|
||||||
if (e.dataTransfer.setDragImage) {
|
if (e.dataTransfer.setDragImage) {
|
||||||
const dragItem = document.createElement('div');
|
const dragItem = document.createElement('div');
|
||||||
dragItem.setAttribute('drag-tree-node');
|
dragItem.classList.add('drag-tree-node');
|
||||||
dragItem.innerHTML = `<span>${_.escape(dropDetails.text)}</span>`;
|
dragItem.innerHTML = `<span>${_.escape(dropDetails.text)}</span>`;
|
||||||
|
|
||||||
document.querySelector('body .drag-tree-node').remove();
|
document.querySelector('body .drag-tree-node')?.remove();
|
||||||
document.body.appendChild(dragItem);
|
document.body.appendChild(dragItem);
|
||||||
|
|
||||||
e.dataTransfer.setDragImage(dragItem[0], 0, 0);
|
e.dataTransfer.setDragImage(dragItem, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,6 +349,7 @@ export function JsonTextEditor({row, column, onRowChange, onClose}) {
|
|||||||
return newVal;
|
return newVal;
|
||||||
});
|
});
|
||||||
const [localVal, setLocalVal] = React.useState(value);
|
const [localVal, setLocalVal] = React.useState(value);
|
||||||
|
const [hasError, setHasError] = React.useState(false);
|
||||||
|
|
||||||
const onChange = React.useCallback((newVal)=>{
|
const onChange = React.useCallback((newVal)=>{
|
||||||
setLocalVal(newVal);
|
setLocalVal(newVal);
|
||||||
@ -358,6 +359,10 @@ export function JsonTextEditor({row, column, onRowChange, onClose}) {
|
|||||||
onClose(false);
|
onClose(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(hasError) {
|
||||||
|
Notifier.error(gettext('Invalid JSON input'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
onRowChange({ ...row, [column.key]: localVal}, true);
|
onRowChange({ ...row, [column.key]: localVal}, true);
|
||||||
onClose();
|
onClose();
|
||||||
};
|
};
|
||||||
@ -370,7 +375,7 @@ export function JsonTextEditor({row, column, onRowChange, onClose}) {
|
|||||||
value={localVal}
|
value={localVal}
|
||||||
options={{
|
options={{
|
||||||
onChange: onChange,
|
onChange: onChange,
|
||||||
onError: (error)=>Notifier.error('Invalid Json: ' + error.message.split(':')[0]),
|
onValidationError: (errors)=>{setHasError(Boolean(errors.length));}
|
||||||
}}
|
}}
|
||||||
className={'jsoneditor-div'}
|
className={'jsoneditor-div'}
|
||||||
/>
|
/>
|
||||||
|
@ -6268,13 +6268,6 @@ json5@^2.1.2, json5@^2.2.2:
|
|||||||
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
|
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
|
||||||
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==
|
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==
|
||||||
|
|
||||||
jsoneditor-react@^3.1.1:
|
|
||||||
version "3.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/jsoneditor-react/-/jsoneditor-react-3.1.2.tgz#bc36356ac5ecb0d8f88d49a5ccbeecdd7f996164"
|
|
||||||
integrity sha512-XqU8BMdIhrlS5HUnn7rGhgZw315bdJGQrf6NG5UH40FSw2xNirQrxnM05aeAplHkp8FNkzN2WX0tfvEWdl2UUA==
|
|
||||||
dependencies:
|
|
||||||
prop-types "^15.7.2"
|
|
||||||
|
|
||||||
jsoneditor@^9.5.4:
|
jsoneditor@^9.5.4:
|
||||||
version "9.9.2"
|
version "9.9.2"
|
||||||
resolved "https://registry.yarnpkg.com/jsoneditor/-/jsoneditor-9.9.2.tgz#176112f71acbf37e977aae8656a17bc33a7a4269"
|
resolved "https://registry.yarnpkg.com/jsoneditor/-/jsoneditor-9.9.2.tgz#176112f71acbf37e977aae8656a17bc33a7a4269"
|
||||||
|
Loading…
Reference in New Issue
Block a user