mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
1) Add server mode validation in the binary path. 2) Updated preferences tree rendering to avoid using the ReactDOM render. 3) Updated CSS for keyboard shortcuts checkbox border makes it consistent with input box border. 4) Fixed jasmine test case and improved code coverage. 5) Fixed SonarQube issues. 6) Added validation to disable "Maximum column with" option if "Column sized by" option is set to "Column name" in Query Tool -> Result grid. 7) Updated documentation with the latest screenshots. 8) Correct typo in the documentation. Fixes #7261 refs #7149
85 lines
2.6 KiB
JavaScript
85 lines
2.6 KiB
JavaScript
// /////////////////////////////////////////////////////////////
|
|
// //
|
|
// // pgAdmin 4 - PostgreSQL Tools
|
|
// //
|
|
// // Copyright (C) 2013 - 2022, The pgAdmin Development Team
|
|
// // This software is released under the PostgreSQL Licence
|
|
// //
|
|
// //////////////////////////////////////////////////////////////
|
|
|
|
import gettext from 'sources/gettext';
|
|
import * as React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { Directory} from 'react-aspen';
|
|
import { FileTreeX, TreeModelX } from 'pgadmin4-tree';
|
|
import { Tree } from '../../../../static/js/tree/tree';
|
|
import { ManagePreferenceTreeNodes } from '../../../../static/js/tree/preference_nodes';
|
|
import pgAdmin from 'sources/pgadmin';
|
|
|
|
|
|
export default function PreferencesTree({ pgBrowser, data }) {
|
|
const pTreeModelX = React.useRef();
|
|
const onReadyRef = React.useRef();
|
|
const [loaded, setLoaded] = React.useState(false);
|
|
|
|
const MOUNT_POINT = '/preferences';
|
|
|
|
React.useEffect(() => {
|
|
setLoaded(false);
|
|
|
|
// Setup host
|
|
let ptree = new ManagePreferenceTreeNodes(data);
|
|
// Init Tree with the Tree Parent node '/browser'
|
|
ptree.init(MOUNT_POINT);
|
|
|
|
const host = {
|
|
pathStyle: 'unix',
|
|
getItems: (path) => {
|
|
return ptree.readNode(path);
|
|
|
|
},
|
|
sortComparator: (a, b) => {
|
|
// No nee to sort Query tool options.
|
|
if (a._parent && a._parent._fileName == 'Query Tool') return 0;
|
|
// Sort alphabetically
|
|
if (a.constructor === b.constructor) {
|
|
return pgAdmin.natural_sort(a.fileName, b.fileName);
|
|
}
|
|
let retval = 0;
|
|
if (a.constructor === Directory) {
|
|
retval = -1;
|
|
} else if (b.constructor === Directory) {
|
|
retval = 1;
|
|
}
|
|
return retval;
|
|
},
|
|
};
|
|
|
|
pTreeModelX.current = new TreeModelX(host, MOUNT_POINT);
|
|
onReadyRef.current = function onReady(handler) {
|
|
// Initialize preferences Tree
|
|
pgBrowser.ptree = new Tree(handler, ptree, pgBrowser, 'preferences');
|
|
// Expand directoy on loading.
|
|
pTreeModelX.current.root._children.forEach((_d)=> {
|
|
_d.root.expandDirectory(_d);
|
|
});
|
|
|
|
return true;
|
|
};
|
|
|
|
pTreeModelX.current.root.ensureLoaded().then(() => {
|
|
setLoaded(true);
|
|
});
|
|
}, [data]);
|
|
|
|
if (!loaded || _.isUndefined(pTreeModelX.current) || _.isUndefined(onReadyRef.current)) {
|
|
return (gettext('Loading...'));
|
|
}
|
|
return (<FileTreeX model={pTreeModelX.current} height={'100%'} onReady={onReadyRef.current} />);
|
|
}
|
|
|
|
PreferencesTree.propTypes = {
|
|
pgBrowser: PropTypes.any,
|
|
data: PropTypes.array,
|
|
ptree: PropTypes.any,
|
|
}; |