mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fix an issue where object explorer tree crashes occasionally. #5306
This commit is contained in:
parent
878c14dec0
commit
466e969776
@ -122,17 +122,11 @@ define('pgadmin.node.compound_trigger', [
|
|||||||
t.removeIcon(i);
|
t.removeIcon(i);
|
||||||
data.icon = 'icon-compound_trigger';
|
data.icon = 'icon-compound_trigger';
|
||||||
t.addIcon(i, {icon: data.icon});
|
t.addIcon(i, {icon: data.icon});
|
||||||
t.unload(i);
|
t.updateAndReselectNode(i, data);
|
||||||
t.setInode(false);
|
|
||||||
t.deselect(i);
|
|
||||||
// Fetch updated data from server
|
|
||||||
setTimeout(function() {
|
|
||||||
t.select(i);
|
|
||||||
}, 10);
|
|
||||||
}
|
}
|
||||||
}).catch(function(error) {
|
}).catch(function(error) {
|
||||||
Notify.pgRespErrorNotify(error);
|
Notify.pgRespErrorNotify(error);
|
||||||
t.unload(i);
|
t.refresh(i);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/* Disable compound trigger */
|
/* Disable compound trigger */
|
||||||
@ -156,17 +150,11 @@ define('pgadmin.node.compound_trigger', [
|
|||||||
t.removeIcon(i);
|
t.removeIcon(i);
|
||||||
data.icon = 'icon-compound_trigger-bad';
|
data.icon = 'icon-compound_trigger-bad';
|
||||||
t.addIcon(i, {icon: data.icon});
|
t.addIcon(i, {icon: data.icon});
|
||||||
t.unload(i);
|
t.updateAndReselectNode(i, data);
|
||||||
t.setInode(false);
|
|
||||||
t.deselect(i);
|
|
||||||
// Fetch updated data from server
|
|
||||||
setTimeout(function() {
|
|
||||||
t.select(i);
|
|
||||||
}, 10);
|
|
||||||
}
|
}
|
||||||
}).catch(function(error) {
|
}).catch(function(error) {
|
||||||
Notify.pgRespErrorNotify(error);
|
Notify.pgRespErrorNotify(error);
|
||||||
t.unload(i);
|
t.refresh(i);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -133,13 +133,7 @@ function(
|
|||||||
t.removeIcon(i);
|
t.removeIcon(i);
|
||||||
data.icon = 'icon-partition';
|
data.icon = 'icon-partition';
|
||||||
t.addIcon(i, {icon: data.icon});
|
t.addIcon(i, {icon: data.icon});
|
||||||
t.unload(i);
|
t.updateAndReselectNode(i, data);
|
||||||
t.setInode(i);
|
|
||||||
t.deselect(i);
|
|
||||||
// Fetch updated data from server
|
|
||||||
setTimeout(function() {
|
|
||||||
t.select(i);
|
|
||||||
}, 10);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
canDrop: SchemaChildTreeNode.isTreeItemOfChildOfSchema,
|
canDrop: SchemaChildTreeNode.isTreeItemOfChildOfSchema,
|
||||||
@ -171,17 +165,12 @@ function(
|
|||||||
.then(({data: res})=>{
|
.then(({data: res})=>{
|
||||||
if (res.success == 1) {
|
if (res.success == 1) {
|
||||||
Notify.success(res.info);
|
Notify.success(res.info);
|
||||||
t.unload(i);
|
t.updateAndReselectNode(i, d);
|
||||||
t.setInode(i);
|
|
||||||
t.deselect(i);
|
|
||||||
setTimeout(function() {
|
|
||||||
t.select(i);
|
|
||||||
}, 10);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error)=>{
|
.catch((error)=>{
|
||||||
Notify.pgRespErrorNotify(error);
|
Notify.pgRespErrorNotify(error);
|
||||||
t.unload(i);
|
t.refresh(i);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/* Truncate table */
|
/* Truncate table */
|
||||||
|
@ -141,16 +141,11 @@ define('pgadmin.node.rule', [
|
|||||||
t.removeIcon(i);
|
t.removeIcon(i);
|
||||||
data.icon = 'icon-rule';
|
data.icon = 'icon-rule';
|
||||||
t.addIcon(i, {icon: data.icon});
|
t.addIcon(i, {icon: data.icon});
|
||||||
t.unload(i);
|
t.updateAndReselectNode(i, data);
|
||||||
t.setInode(false);
|
|
||||||
t.deselect(i);
|
|
||||||
// Fetch updated data from server
|
|
||||||
setTimeout(function() {
|
|
||||||
t.select(i);
|
|
||||||
}, 10);
|
|
||||||
})
|
})
|
||||||
.catch((error)=>{
|
.catch((error)=>{
|
||||||
Notify.pgRespErrorNotify(error);
|
Notify.pgRespErrorNotify(error);
|
||||||
|
t.refresh(i);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/* Disable rule */
|
/* Disable rule */
|
||||||
@ -171,16 +166,11 @@ define('pgadmin.node.rule', [
|
|||||||
t.removeIcon(i);
|
t.removeIcon(i);
|
||||||
data.icon = 'icon-rule-bad';
|
data.icon = 'icon-rule-bad';
|
||||||
t.addIcon(i, {icon: data.icon});
|
t.addIcon(i, {icon: data.icon});
|
||||||
t.unload(i);
|
t.updateAndReselectNode(i, data);
|
||||||
t.setInode(false);
|
|
||||||
t.deselect(i);
|
|
||||||
// Fetch updated data from server
|
|
||||||
setTimeout(function() {
|
|
||||||
t.select(i);
|
|
||||||
}, 10);
|
|
||||||
})
|
})
|
||||||
.catch((error)=>{
|
.catch((error)=>{
|
||||||
Notify.pgRespErrorNotify(error);
|
Notify.pgRespErrorNotify(error);
|
||||||
|
t.refresh(i);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -195,13 +195,7 @@ define('pgadmin.node.table', [
|
|||||||
t.removeIcon(i);
|
t.removeIcon(i);
|
||||||
data.icon = data.is_partitioned ? 'icon-partition': 'icon-table';
|
data.icon = data.is_partitioned ? 'icon-partition': 'icon-table';
|
||||||
t.addIcon(i, {icon: data.icon});
|
t.addIcon(i, {icon: data.icon});
|
||||||
t.unload(i);
|
t.updateAndReselectNode(i, data);
|
||||||
t.setInode(i);
|
|
||||||
t.deselect(i);
|
|
||||||
// Fetch updated data from server
|
|
||||||
setTimeout(function() {
|
|
||||||
t.select(i);
|
|
||||||
}, 10);
|
|
||||||
}
|
}
|
||||||
if (res.success == 2) {
|
if (res.success == 2) {
|
||||||
Notify.error(res.info);
|
Notify.error(res.info);
|
||||||
@ -209,7 +203,7 @@ define('pgadmin.node.table', [
|
|||||||
})
|
})
|
||||||
.catch((error)=>{
|
.catch((error)=>{
|
||||||
Notify.pgRespErrorNotify(error);
|
Notify.pgRespErrorNotify(error);
|
||||||
t.unload(i);
|
t.refresh(i);
|
||||||
});
|
});
|
||||||
}, function() {/*This is intentional (SonarQube)*/}
|
}, function() {/*This is intentional (SonarQube)*/}
|
||||||
);
|
);
|
||||||
@ -236,18 +230,12 @@ define('pgadmin.node.table', [
|
|||||||
t.removeIcon(i);
|
t.removeIcon(i);
|
||||||
data.icon = data.is_partitioned ? 'icon-partition': 'icon-table';
|
data.icon = data.is_partitioned ? 'icon-partition': 'icon-table';
|
||||||
t.addIcon(i, {icon: data.icon});
|
t.addIcon(i, {icon: data.icon});
|
||||||
t.unload(i);
|
t.updateAndReselectNode(i, d);
|
||||||
t.setInode(i);
|
|
||||||
t.deselect(i);
|
|
||||||
// Fetch updated data from server
|
|
||||||
setTimeout(function() {
|
|
||||||
t.select(i);
|
|
||||||
}, 10);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error)=>{
|
.catch((error)=>{
|
||||||
Notify.pgRespErrorNotify(error);
|
Notify.pgRespErrorNotify(error);
|
||||||
t.unload(i);
|
t.refresh(i);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function() {/*This is intentional (SonarQube)*/}
|
function() {/*This is intentional (SonarQube)*/}
|
||||||
@ -271,16 +259,11 @@ define('pgadmin.node.table', [
|
|||||||
.then(({data: res})=>{
|
.then(({data: res})=>{
|
||||||
Notify.success(res.info, null);
|
Notify.success(res.info, null);
|
||||||
d.rows_cnt = res.data.total_rows;
|
d.rows_cnt = res.data.total_rows;
|
||||||
t.unload(i);
|
t.updateAndReselectNode(i, d);
|
||||||
t.setInode(i);
|
|
||||||
t.deselect(i);
|
|
||||||
setTimeout(function() {
|
|
||||||
t.select(i);
|
|
||||||
}, 10);
|
|
||||||
})
|
})
|
||||||
.catch((error)=>{
|
.catch((error)=>{
|
||||||
Notify.pgRespErrorNotify(error);
|
Notify.pgRespErrorNotify(error);
|
||||||
t.unload(i);
|
t.refresh(i);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/* Generate the ERD */
|
/* Generate the ERD */
|
||||||
|
@ -115,20 +115,14 @@ define('pgadmin.node.trigger', [
|
|||||||
Notify.success(res.info);
|
Notify.success(res.info);
|
||||||
t.removeIcon(i);
|
t.removeIcon(i);
|
||||||
data.icon = 'icon-trigger';
|
data.icon = 'icon-trigger';
|
||||||
|
data.has_enable_triggers = res.data.has_enable_triggers;
|
||||||
t.addIcon(i, {icon: data.icon});
|
t.addIcon(i, {icon: data.icon});
|
||||||
t.unload(i);
|
t.updateAndReselectNode(i, data);
|
||||||
t.setInode(false);
|
|
||||||
t.deselect(i);
|
|
||||||
i.parent.parent._metadata.data.has_enable_triggers = res.data.has_enable_triggers;
|
|
||||||
// Fetch updated data from server
|
|
||||||
setTimeout(function() {
|
|
||||||
t.select(i);
|
|
||||||
}, 10);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error)=>{
|
.catch((error)=>{
|
||||||
Notify.pgRespErrorNotify(error);
|
Notify.pgRespErrorNotify(error);
|
||||||
t.unload(i);
|
t.refresh(i);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/* Disable trigger */
|
/* Disable trigger */
|
||||||
@ -149,20 +143,14 @@ define('pgadmin.node.trigger', [
|
|||||||
Notify.success(res.info);
|
Notify.success(res.info);
|
||||||
t.removeIcon(i);
|
t.removeIcon(i);
|
||||||
data.icon = 'icon-trigger-bad';
|
data.icon = 'icon-trigger-bad';
|
||||||
|
data.has_enable_triggers = res.data.has_enable_triggers;
|
||||||
t.addIcon(i, {icon: data.icon});
|
t.addIcon(i, {icon: data.icon});
|
||||||
t.unload(i);
|
t.updateAndReselectNode(i, data);
|
||||||
t.setInode(false);
|
|
||||||
t.deselect(i);
|
|
||||||
i.parent.parent._metadata.data.has_enable_triggers = res.data.has_enable_triggers;
|
|
||||||
// Fetch updated data from server
|
|
||||||
setTimeout(function() {
|
|
||||||
t.select(i);
|
|
||||||
}, 10);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error)=>{
|
.catch((error)=>{
|
||||||
Notify.pgRespErrorNotify(error);
|
Notify.pgRespErrorNotify(error);
|
||||||
t.unload(i);
|
t.refresh(i);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -197,10 +197,9 @@ define('pgadmin.node.database', [
|
|||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
d.is_connecting = false;
|
d.is_connecting = false;
|
||||||
t.unload(i);
|
|
||||||
t.setInode(i);
|
|
||||||
let dbIcon = d.isTemplate ? 'icon-database-template-not-connected':'icon-database-not-connected';
|
let dbIcon = d.isTemplate ? 'icon-database-template-not-connected':'icon-database-not-connected';
|
||||||
t.addIcon(i, {icon: dbIcon});
|
t.addIcon(i, {icon: dbIcon});
|
||||||
|
t.updateAndReselectNode(i, d);
|
||||||
pgBrowser.Events.trigger(
|
pgBrowser.Events.trigger(
|
||||||
'pgadmin:database:connect:cancelled', i, d, self
|
'pgadmin:database:connect:cancelled', i, d, self
|
||||||
);
|
);
|
||||||
@ -473,11 +472,10 @@ define('pgadmin.node.database', [
|
|||||||
onCancel = function(_tree, _item, _data) {
|
onCancel = function(_tree, _item, _data) {
|
||||||
_data.is_connecting = false;
|
_data.is_connecting = false;
|
||||||
let server = _tree.parent(_item);
|
let server = _tree.parent(_item);
|
||||||
_tree.unload(_item);
|
|
||||||
_tree.setInode(_item);
|
|
||||||
_tree.removeIcon(_item);
|
_tree.removeIcon(_item);
|
||||||
let dbIcon = data.isTemplate ? 'icon-database-template-not-connected':'icon-database-not-connected';
|
let dbIcon = data.isTemplate ? 'icon-database-template-not-connected':'icon-database-not-connected';
|
||||||
_tree.addIcon(_item, {icon: dbIcon});
|
_tree.addIcon(_item, {icon: dbIcon});
|
||||||
|
_tree.updateAndReselectNode(_item, _data);
|
||||||
obj.trigger('connect:cancelled', obj, _item, _data);
|
obj.trigger('connect:cancelled', obj, _item, _data);
|
||||||
pgBrowser.Events.trigger(
|
pgBrowser.Events.trigger(
|
||||||
'pgadmin:database:connect:cancelled', _item, _data, obj
|
'pgadmin:database:connect:cancelled', _item, _data, obj
|
||||||
|
@ -551,7 +551,6 @@ define('pgadmin.node.server', [
|
|||||||
function() {
|
function() {
|
||||||
d.is_connecting = false;
|
d.is_connecting = false;
|
||||||
t.unload(i);
|
t.unload(i);
|
||||||
t.setInode(i);
|
|
||||||
t.addIcon(i, {icon: 'icon-database-not-connected'});
|
t.addIcon(i, {icon: 'icon-database-not-connected'});
|
||||||
pgBrowser.Events.trigger(
|
pgBrowser.Events.trigger(
|
||||||
'pgadmin:server:connect:cancelled', i, d, self
|
'pgadmin:server:connect:cancelled', i, d, self
|
||||||
@ -588,13 +587,11 @@ define('pgadmin.node.server', [
|
|||||||
);
|
);
|
||||||
data.is_connecting = false;
|
data.is_connecting = false;
|
||||||
tree.unload(item);
|
tree.unload(item);
|
||||||
tree.setInode(item);
|
|
||||||
tree.addIcon(item, {icon: 'icon-shared-server-not-connected'});
|
tree.addIcon(item, {icon: 'icon-shared-server-not-connected'});
|
||||||
Notify.info('Please enter the server details to connect to the server. This server is a shared server.');
|
Notify.info('Please enter the server details to connect to the server. This server is a shared server.');
|
||||||
} else {
|
} else {
|
||||||
data.is_connecting = false;
|
data.is_connecting = false;
|
||||||
tree.unload(item);
|
tree.unload(item);
|
||||||
tree.setInode(item);
|
|
||||||
tree.addIcon(item, {icon: 'icon-shared-server-not-connected'});
|
tree.addIcon(item, {icon: 'icon-shared-server-not-connected'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -707,7 +704,6 @@ define('pgadmin.node.server', [
|
|||||||
let onCancel = function(_tree, _item, _data, _status) {
|
let onCancel = function(_tree, _item, _data, _status) {
|
||||||
_data.is_connecting = false;
|
_data.is_connecting = false;
|
||||||
_tree.unload(_item);
|
_tree.unload(_item);
|
||||||
_tree.setInode(_item);
|
|
||||||
_tree.removeIcon(_item);
|
_tree.removeIcon(_item);
|
||||||
if (_data.shared && pgAdmin.server_mode == 'True'){
|
if (_data.shared && pgAdmin.server_mode == 'True'){
|
||||||
_tree.addIcon(_item, {icon: 'icon-shared-server-not-connected'});
|
_tree.addIcon(_item, {icon: 'icon-shared-server-not-connected'});
|
||||||
|
@ -223,8 +223,8 @@ export class Tree {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deselect(item) {
|
async deselect(item) {
|
||||||
this.tree.deSelectActiveFile(item);
|
await this.tree.deSelectActiveFile(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
wasInit() {
|
wasInit() {
|
||||||
@ -455,6 +455,12 @@ export class Tree {
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async updateAndReselectNode(item, data) {
|
||||||
|
await this.update(item, data);
|
||||||
|
await this.deselect(item);
|
||||||
|
await this.select(item);
|
||||||
|
}
|
||||||
|
|
||||||
translateTreeNodeIdFromReactTree(treeNode) {
|
translateTreeNodeIdFromReactTree(treeNode) {
|
||||||
let currentTreeNode = treeNode;
|
let currentTreeNode = treeNode;
|
||||||
let path = [];
|
let path = [];
|
||||||
|
Loading…
Reference in New Issue
Block a user