mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Don't append new objects to the wrong parent, if the correct one isn't loaded. Fixes #1838
This commit is contained in:
parent
e31ba5873b
commit
b9571df4de
@ -936,13 +936,25 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
|
||||
});
|
||||
} else {
|
||||
var _append = function() {
|
||||
var ctx = this;
|
||||
var ctx = this,
|
||||
is_parent_loaded_before = ctx.t.wasLoad(ctx.i),
|
||||
_parent_data = ctx.t.itemData(ctx.i);
|
||||
|
||||
ctx.t.append(ctx.i, {
|
||||
itemData: _data,
|
||||
success: function(item, options) {
|
||||
var i = $(options.items[0]);
|
||||
ctx.t.openPath(i);
|
||||
ctx.t.select(i);
|
||||
// Open the item path only if its parent is loaded
|
||||
// or parent type is same as nodes
|
||||
if(_parent_data._type.search(_data._type) > -1 ||
|
||||
is_parent_loaded_before) {
|
||||
ctx.t.openPath(i);
|
||||
ctx.t.select(i);
|
||||
} else {
|
||||
// Unload the parent node so that we'll get
|
||||
// latest data when we try to expand it
|
||||
ctx.t.unload(ctx.i);
|
||||
}
|
||||
if (
|
||||
ctx.o && ctx.o.success &&
|
||||
typeof(ctx.o.success) == 'function'
|
||||
|
@ -170,9 +170,16 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
|
||||
if (itemData.type == 'role' &&
|
||||
parentData.server.user.can_create_role) {
|
||||
return true;
|
||||
} else if (parentData.server.user.is_superuser ||
|
||||
parentData.server.user.can_create_db ||
|
||||
(parentData.schema && parentData.schema.can_create)) {
|
||||
} else if (
|
||||
(
|
||||
parentData.server && (
|
||||
parentData.server.user.is_superuser ||
|
||||
parentData.server.user.can_create_db)
|
||||
) ||
|
||||
(
|
||||
parentData.schema && parentData.schema.can_create
|
||||
)
|
||||
) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user