Remove aciTree and its references.

This commit is contained in:
Akshay Joshi 2022-04-13 17:35:01 +05:30
parent 3a4ff2677e
commit 86a3696ab4
20 changed files with 57 additions and 135 deletions

View File

@ -95,7 +95,6 @@
"@types/classnames": "^2.2.6",
"@types/react": "^16.7.18",
"@types/react-dom": "^16.0.11",
"acitree": "git+https://github.com/imsurinder90/jquery-aciTree.git#rc.7",
"ajv": "^8.8.2",
"alertifyjs": "git+https://github.com/EnterpriseDB/AlertifyJS/#72c1d794f5b6d4ec13a68d123c08f19021afe263",
"aspen-decorations": "^1.0.2",

View File

@ -97,8 +97,7 @@ class BrowserModule(PgAdminModule):
('static', 'vendor/codemirror/codemirror.css'),
('static', 'vendor/codemirror/addon/dialog/dialog.css'),
('static', context_menu_file),
('static', wcdocker_file),
(BROWSER_STATIC, 'vendor/aciTree/css/aciTree.css')
('static', wcdocker_file)
]:
stylesheets.append(url_for(endpoint, filename=filename))
return stylesheets
@ -139,49 +138,6 @@ class BrowserModule(PgAdminModule):
'exports': 'jQuery.contextMenu',
'preloaded': True
})
scripts.append({
'name': JQUERY_ACIPLUGIN,
'path': url_for(
BROWSER_STATIC,
filename='vendor/aciTree/jquery.aciPlugin.min'
),
'deps': ['jquery'],
'exports': 'aciPluginClass',
'preloaded': True
})
scripts.append({
'name': 'jquery.acitree',
'path': url_for(
BROWSER_STATIC,
filename='vendor/aciTree/jquery.aciTree' if
current_app.debug else 'vendor/aciTree/jquery.aciTree.min'
),
'deps': ['jquery', JQUERY_ACIPLUGIN],
'exports': 'aciPluginClass.plugins.aciTree',
'preloaded': True
})
scripts.append({
'name': 'jquery.acisortable',
'path': url_for(
BROWSER_STATIC,
filename='vendor/aciTree/jquery.aciSortable.min'
),
'deps': ['jquery', JQUERY_ACIPLUGIN],
'exports': 'aciPluginClass.plugins.aciSortable',
'when': None,
'preloaded': True
})
scripts.append({
'name': 'jquery.acifragment',
'path': url_for(
BROWSER_STATIC,
filename='vendor/aciTree/jquery.aciFragment.min'
),
'deps': ['jquery', JQUERY_ACIPLUGIN],
'exports': 'aciPluginClass.plugins.aciFragment',
'when': None,
'preloaded': True
})
scripts.append({
'name': 'wcdocker',
'path': url_for(

View File

@ -16,15 +16,13 @@ define('pgadmin.browser', [
'sources/check_node_visibility', './toolbar', 'pgadmin.help',
'sources/csrf', 'sources/utils', 'sources/window', 'pgadmin.authenticate.kerberos',
'sources/tree/tree_init',
'pgadmin.browser.utils', 'wcdocker', 'jquery.contextmenu', 'jquery.aciplugin',
'jquery.acitree',
'pgadmin.browser.utils', 'wcdocker', 'jquery.contextmenu',
'pgadmin.browser.preferences', 'pgadmin.browser.messages',
'pgadmin.browser.menu', 'pgadmin.browser.panel', 'pgadmin.browser.layout',
'pgadmin.browser.runtime', 'pgadmin.browser.error', 'pgadmin.browser.frame',
'pgadmin.browser.node', 'pgadmin.browser.collection', 'pgadmin.browser.activity',
'sources/codemirror/addon/fold/pgadmin-sqlfoldcode', 'pgadmin.browser.dialog',
'pgadmin.browser.keyboard', 'sources/tree/pgadmin_tree_save_state','jquery.acisortable',
'jquery.acifragment',
'pgadmin.browser.keyboard', 'sources/tree/pgadmin_tree_save_state'
], function(
gettext, url_for, require, $, _,
Bootstrap, pgAdmin, Alertify, codemirror,

View File

@ -368,12 +368,12 @@ _.extend(pgBrowser.keyboardNavigation, {
return isPanelVisible;
},
getTreeDetails: function() {
const aciTree = pgAdmin.Browser.tree;
const selectedTreeNode = aciTree.selected() ? aciTree.selected() : aciTree.first();
const selectedTreeNodeData = selectedTreeNode ? aciTree.itemData(selectedTreeNode) : undefined;
const tree = pgAdmin.Browser.tree;
const selectedTreeNode = tree.selected() ? tree.selected() : tree.first();
const selectedTreeNodeData = selectedTreeNode ? tree.itemData(selectedTreeNode) : undefined;
return {
t: aciTree,
t: tree,
i: selectedTreeNode,
d: selectedTreeNodeData,
};

View File

@ -29,7 +29,7 @@ class CheckForXssFeatureTest(BaseFeatureTest):
found them in the code then we are not vulnerable otherwise we might.
We will cover,
1) Browser Tree (aciTree)
1) Browser Tree
2) Properties Tab (BackFrom)
3) Dependents Tab (BackGrid)
4) SQL Tab (Code Mirror)

View File

@ -602,7 +602,7 @@ export default function PreferencesComponent({ ...props }) {
<Box className={clsx(classes.preferences)}>
<Box className={clsx(classes.treeContainer)} >
<Box className={clsx('aciTree', classes.tree)} id={'treeContainer'} tabIndex={0}>
<Box className={clsx(classes.tree)} id={'treeContainer'} tabIndex={0}>
{
useMemo(() => (prefTreeData && props.renderTree(prefTreeData)), [prefTreeData])
}

View File

@ -7,7 +7,6 @@
@import 'node_modules/backgrid-filter/backgrid-filter.css';
@import 'node_modules/jquery-contextmenu/dist/jquery.contextMenu.css';
@import 'node_modules/webcabin-docker/Build/wcDocker.css';
@import 'node_modules/acitree/css/aciTree.css';
@import 'node_modules/select2/dist/css/select2.min.css';
@import 'node_modules/leaflet/dist/leaflet.css';

View File

@ -34,8 +34,8 @@ export class Dialog {
retrieveAncestorOfTypeServer(item) {
let serverInformation = null;
let aciTreeItem = item || this.pgBrowser.tree.selected();
let treeNode = this.pgBrowser.tree.findNodeByDomElement(aciTreeItem);
let treeItem = item || this.pgBrowser.tree.selected();
let treeNode = this.pgBrowser.tree.findNodeByDomElement(treeItem);
if (treeNode) {
let nodeData;
@ -105,8 +105,8 @@ export class Dialog {
return factory.create(dialogTitle, typeOfDialog);
}
canExecuteOnCurrentDatabase(aciTreeItem) {
const treeInfo = this.pgBrowser.tree.getTreeNodeHierarchy(aciTreeItem);
canExecuteOnCurrentDatabase(treeItem) {
const treeInfo = this.pgBrowser.tree.getTreeNodeHierarchy(treeItem);
if (treeInfo.database && treeInfo.database._label.indexOf('=') >= 0) {
this.alertify.alert(

View File

@ -15,8 +15,8 @@ function getBrowserInstance() {
return pgWindow.pgAdmin.Browser;
}
function modifyAcitreeAnimation(pgBrowser, tree) {
let enableAcitreeAnimation = pgBrowser.get_preference(
function modifyTreeAnimation(pgBrowser, tree) {
let enableTreeAnimation = pgBrowser.get_preference(
'browser', 'enable_acitree_animation'
).value;
@ -24,7 +24,7 @@ function modifyAcitreeAnimation(pgBrowser, tree) {
tree = pgBrowser.tree;
}
if(enableAcitreeAnimation) {
if(enableTreeAnimation) {
tree.options({
animateRoot: true,
unanimated: false,
@ -48,11 +48,11 @@ function modifyAlertifyAnimation(pgBrowser) {
pgBrowser = getBrowserInstance();
}
let enableAcitreeAnimation = pgBrowser.get_preference(
let enableTreeAnimation = pgBrowser.get_preference(
'browser', 'enable_alertify_animation'
).value;
if(enableAcitreeAnimation) {
if(enableTreeAnimation) {
$(document).find('body').removeClass('alertify-no-animation');
_.each(document.getElementsByTagName('iframe'), function(frame) {
$(frame.contentDocument).find('body').removeClass('alertify-no-animation');
@ -66,6 +66,6 @@ function modifyAlertifyAnimation(pgBrowser) {
}
module.exports = {
modifyAcitreeAnimation : modifyAcitreeAnimation,
modifyTreeAnimation : modifyTreeAnimation,
modifyAlertifyAnimation: modifyAlertifyAnimation,
};

View File

@ -430,8 +430,8 @@ export class Tree {
return node;
}
translateTreeNodeIdFromReactTree(aciTreeNode) {
let currentTreeNode = aciTreeNode;
translateTreeNodeIdFromReactTree(treeNode) {
let currentTreeNode = treeNode;
let path = [];
while (currentTreeNode !== null && currentTreeNode !== undefined) {
if (currentTreeNode.path !== '/browser') path.unshift(currentTreeNode.path);

View File

@ -12,8 +12,8 @@ import Notify from '../helpers/Notifier';
export function retrieveAncestorOfTypeServer(pgBrowser, item, errorAlertTitle) {
let serverInformation = null;
let aciTreeItem = item || pgBrowser.tree.selected();
let treeNode = pgBrowser.tree.findNodeByDomElement(aciTreeItem);
let treeItem = item || pgBrowser.tree.selected();
let treeNode = pgBrowser.tree.findNodeByDomElement(treeItem);
if (treeNode) {
let nodeData;
@ -59,8 +59,8 @@ export function retrieveAncestorOfTypeServer(pgBrowser, item, errorAlertTitle) {
export function retrieveAncestorOfTypeDatabase(pgBrowser, item, errorAlertTitle) {
let databaseInfo = null;
let aciTreeItem = item || pgBrowser.tree.selected();
let treeNode = pgBrowser.tree.findNodeByDomElement(aciTreeItem);
let treeItem = item || pgBrowser.tree.selected();
let treeNode = pgBrowser.tree.findNodeByDomElement(treeItem);
if (treeNode) {
if(treeNode.getData()._type === 'database') {
databaseInfo = treeNode.getData();

View File

@ -97,8 +97,8 @@ export function initialize(gettext, url_for, $, _, pgAdmin, csrfToken, pgBrowser
},
// Callback to draw ERD Tool for objects
showErdTool: function(data, aciTreeIdentifier, gen=false) {
if (aciTreeIdentifier === undefined) {
showErdTool: function(data, treeIdentifier, gen=false) {
if (treeIdentifier === undefined) {
Notify.alert(
gettext('ERD Error'),
gettext('No object selected.')
@ -106,7 +106,7 @@ export function initialize(gettext, url_for, $, _, pgAdmin, csrfToken, pgBrowser
return;
}
const parentData = pgBrowser.tree.getTreeNodeHierarchy(aciTreeIdentifier);
const parentData = pgBrowser.tree.getTreeNodeHierarchy(treeIdentifier);
if(_.isUndefined(parentData.database)) {
Notify.alert(
@ -117,7 +117,7 @@ export function initialize(gettext, url_for, $, _, pgAdmin, csrfToken, pgBrowser
}
const transId = getRandomInt(1, 9999999);
const panelTitle = getPanelTitle(pgBrowser, aciTreeIdentifier);
const panelTitle = getPanelTitle(pgBrowser, treeIdentifier);
const [panelUrl, panelCloseUrl] = this.getPanelUrls(transId, panelTitle, parentData, gen);
let erdToolForm = `

View File

@ -113,13 +113,13 @@ export function initialize(gettext, url_for, $, _, pgAdmin, csrfToken, Browser)
enable(gettext('PSQL Tool'), isEnabled);
return isEnabled;
},
psql_tool: function(data, aciTreeIdentifier, gen=false) {
const serverInformation = retrieveAncestorOfTypeServer(pgBrowser, aciTreeIdentifier, gettext('PSQL Error'));
psql_tool: function(data, treeIdentifier, gen=false) {
const serverInformation = retrieveAncestorOfTypeServer(pgBrowser, treeIdentifier, gettext('PSQL Error'));
if (!hasBinariesConfiguration(pgBrowser, serverInformation)) {
return;
}
const node = pgBrowser.tree.findNodeByDomElement(aciTreeIdentifier);
const node = pgBrowser.tree.findNodeByDomElement(treeIdentifier);
if (node === undefined || !node.getData()) {
Notify.alert(
gettext('PSQL Error'),
@ -128,7 +128,7 @@ export function initialize(gettext, url_for, $, _, pgAdmin, csrfToken, Browser)
return;
}
parentData = pgBrowser.tree.getTreeNodeHierarchy(aciTreeIdentifier);
parentData = pgBrowser.tree.getTreeNodeHierarchy(treeIdentifier);
if(_.isUndefined(parentData.server)) {
Notify.alert(

View File

@ -24,13 +24,13 @@ export default class SearchObjectsDialog extends Dialog {
return 'search_objects';
}
draw(action, aciTreeItem, params, width=0, height=0) {
let dbInfo = retrieveAncestorOfTypeDatabase(this.pgBrowser, aciTreeItem, gettext('Search Objects Error'), this.alertify);
draw(action, treeItem, params, width=0, height=0) {
let dbInfo = retrieveAncestorOfTypeDatabase(this.pgBrowser, treeItem, gettext('Search Objects Error'), this.alertify);
if (!dbInfo) {
return;
}
let dialogTitle = getPanelTitle(this.pgBrowser, aciTreeItem);
let dialogTitle = getPanelTitle(this.pgBrowser, treeItem);
dialogTitle = gettext('Search Objects - ') + dialogTitle;
const dialog = this.createOrGetDialog(
gettext('Search Objects...'),

View File

@ -45,15 +45,15 @@ function hasServerInformations(parentData) {
return parentData.server === undefined;
}
function generateTitle(pgBrowser, aciTreeIdentifier) {
return getPanelTitle(pgBrowser, aciTreeIdentifier);
function generateTitle(pgBrowser, treeIdentifier) {
return getPanelTitle(pgBrowser, treeIdentifier);
}
export function showQueryTool(queryToolMod, pgBrowser, url, aciTreeIdentifier, transId) {
export function showQueryTool(queryToolMod, pgBrowser, url, treeIdentifier, transId) {
const sURL = url || '';
const queryToolTitle = generateTitle(pgBrowser, aciTreeIdentifier);
const queryToolTitle = generateTitle(pgBrowser, treeIdentifier);
const currentNode = pgBrowser.tree.findNodeByDomElement(aciTreeIdentifier);
const currentNode = pgBrowser.tree.findNodeByDomElement(treeIdentifier);
if (currentNode === undefined) {
Notify.alert(
gettext('Query Tool Error'),

View File

@ -32,7 +32,7 @@ describe('modifyAnimation', function () {
describe('When browser tree animation is disabled', () => {
beforeEach(() => {
pgBrowser.get_preference.and.returnValue({value: false});
modifyAnimation.modifyAcitreeAnimation(pgBrowser);
modifyAnimation.modifyTreeAnimation(pgBrowser);
});
it('tree options to animate should be disabled', function() {
expect(pgBrowser.get_preference).toHaveBeenCalled();
@ -50,7 +50,7 @@ describe('modifyAnimation', function () {
describe('When browser tree animation is enabled', () => {
beforeEach(() => {
pgBrowser.get_preference.and.returnValue({value: true});
modifyAnimation.modifyAcitreeAnimation(pgBrowser);
modifyAnimation.modifyTreeAnimation(pgBrowser);
});
it('tree options to animate should be enabled', function() {
expect(pgBrowser.get_preference).toHaveBeenCalled();

View File

@ -51,15 +51,15 @@ export class TreeFake extends Tree {
});
super(tree, manageTree, pgBrowser);
this.aciTreeToOurTreeTranslator = {};
this.treeToOurTreeTranslator = {};
}
addNewNode(id, data, domNode, path) {
this.aciTreeToOurTreeTranslator[id] = id;
this.treeToOurTreeTranslator[id] = id;
if (path !== null && path !== undefined) {
if (typeof(path) === 'object') path = path.join('/');
this.aciTreeToOurTreeTranslator[id] = path != '' ? path + '/' + id : id;
this.treeToOurTreeTranslator[id] = path != '' ? path + '/' + id : id;
if (path.indexOf('/browser/') != 0) path = path != '' ? '/browser/' + path : undefined;
}
return super.addNewNode(id, data, domNode, path);
@ -67,29 +67,29 @@ export class TreeFake extends Tree {
addChild(parent, child) {
child.setParent(parent);
this.aciTreeToOurTreeTranslator[child.id] = this.aciTreeToOurTreeTranslator[parent.id] + '/' + child.id;
this.treeToOurTreeTranslator[child.id] = this.treeToOurTreeTranslator[parent.id] + '/' + child.id;
parent.children.push(child);
}
hasParent(aciTreeNode) {
let parents = this.translateTreeNodeIdFromReactTree(aciTreeNode).split('/');
hasParent(treeNode) {
let parents = this.translateTreeNodeIdFromReactTree(treeNode).split('/');
return parents.length > 1;
}
parent(aciTreeNode) {
if (this.hasParent(aciTreeNode)) {
let path = this.translateTreeNodeIdFromReactTree(aciTreeNode);
parent(treeNode) {
if (this.hasParent(treeNode)) {
let path = this.translateTreeNodeIdFromReactTree(treeNode);
return [{id: this.findNode('/browser/' + path).parent().id}];
}
return null;
}
translateTreeNodeIdFromReactTree(aciTreeNode) {
if (aciTreeNode === undefined || aciTreeNode[0] === undefined) {
translateTreeNodeIdFromReactTree(treeNode) {
if (treeNode === undefined || treeNode[0] === undefined) {
return null;
}
return this.aciTreeToOurTreeTranslator[aciTreeNode[0].id];
return this.treeToOurTreeTranslator[treeNode[0].id];
}
findNodeByDomElement(domElement) {
@ -134,8 +134,8 @@ export class TreeFake extends Tree {
return result;
}
itemData(aciTreeNode) {
let node = this.findNodeByDomElement(aciTreeNode);
itemData(treeNode) {
let node = this.findNodeByDomElement(treeNode);
if (node === undefined || node === null) {
return undefined;
}

View File

@ -524,22 +524,6 @@ module.exports = [{
},
},
},{
test: require.resolve('./node_modules/acitree/js/jquery.aciTree.min'),
use: {
loader: 'imports-loader',
options: {
wrapper: 'window',
},
},
}, {
test: require.resolve('./node_modules/acitree/js/jquery.aciPlugin.min'),
use: {
loader: 'imports-loader',
options: {
wrapper: 'window',
},
},
}, {
test: require.resolve('./pgadmin/static/bundle/browser'),
use: {
loader: 'imports-loader',

View File

@ -97,10 +97,6 @@ var webpackShimConfig = {
'deps': ['jquery'],
'exports': 'aciPluginClass',
},
'jquery.acitree': {
'deps': ['jquery', 'jquery.aciplugin'],
'exports': 'aciPluginClass.plugins.aciTree',
},
'jquery.acisortable': {
'deps': ['jquery', 'jquery.aciplugin'],
'exports': 'aciPluginClass.plugins.aciSortable',
@ -158,12 +154,6 @@ var webpackShimConfig = {
'popper.js': path.join(__dirname, 'node_modules/popper.js'),
'pgadmin4-tree': path.join(__dirname, 'node_modules/pgadmin4-tree'),
// AciTree
'jquery.acitree': path.join(__dirname, './node_modules/acitree/js/jquery.aciTree.min'),
'jquery.aciplugin': path.join(__dirname, './node_modules/acitree/js/jquery.aciPlugin.min'),
'jquery.acisortable': path.join(__dirname, './node_modules/acitree/js/jquery.aciSortable.min'),
'jquery.acifragment': path.join(__dirname, './node_modules/acitree/js/jquery.aciFragment.min'),
//xterm
'xterm': path.join(__dirname, './node_modules/xterm/lib/xterm.js'),
'xterm-addon-fit': path.join(__dirname, './node_modules/xterm-addon-fit/lib/xterm-addon-fit.js'),

View File

@ -2510,10 +2510,6 @@ ace-builds@^1.4.12:
resolved "https://registry.yarnpkg.com/ace-builds/-/ace-builds-1.4.13.tgz#186f42d3849ebcc6a48b93088a058489897514c1"
integrity sha512-SOLzdaQkY6ecPKYRDDg+MY1WoGgXA34cIvYJNNoBMGGUswHmlauU2Hy0UL96vW0Fs/LgFbMUjD+6vqzWTldIYQ==
"acitree@git+https://github.com/imsurinder90/jquery-aciTree.git#rc.7":
version "4.5.0-rc.7"
resolved "git+https://github.com/imsurinder90/jquery-aciTree.git#24dcd7536a008abe25da6adb7bfde8eeb53892f1"
acorn-import-assertions@^1.7.6:
version "1.8.0"
resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz#ba2b5939ce62c238db6d93d81c9b111b29b855e9"