Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion web/pgadmin/browser/static/js/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,20 @@ define('pgadmin.browser', [
) {
let _parent = this.t.parent(this.i) || null;

// if the node is a server group
if (_item_parent.path === '/browser') {
let that = this;
// first remove the node from the tree
this.t.remove(this.i).then(() => {
// then add in the updated node with updated item data
this.t.tree.create(_parent, that.new).then((new_item) => {
// then we need to call update so that item.metadata is populated
this.t.update(new_item, that.new);
});
});
}
// If there is no parent then just update the node
if(this.t.isRootNode(_parent) ||
else if(this.t.isRootNode(_parent) ||
(_parent && _parent.length == 0 && ctx.op == 'UPDATE')) {
//Update node if browser has single child node.
if(this.t.children().length === 1) {
Expand Down Expand Up @@ -1189,6 +1201,10 @@ define('pgadmin.browser', [
) {
ctx.op = 'RECREATE';
traversePath();
// call RECREATE operation for server_groups so that the hierarchy is reordered on server group name update
} else if (_old._type == 'server_group' && _new._type == 'server_group') {
ctx.op = 'RECREATE';
traversePath();
} else {
ctx.op = 'UPDATE';
traversePath();
Expand Down
1 change: 1 addition & 0 deletions web/pgadmin/static/js/components/PgTree/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export interface IFileTreeXProps {
* Amalgam of unix's `mkdir` and `touch` command
*/
create: (path: string, type: FileType) => IFileEntryItem | Promise<IFileEntryItem>
update: (path: string, data: {}) => IFileEntryItem | Promise<boolean>
onReady?: (handle: IFileTreeXHandle) => void
onEvent?: (event: IFileTreeXTriggerEvents) => void
onContextMenu?: (ev: React.MouseEvent, item?: FileOrDir) => void
Expand Down
2 changes: 1 addition & 1 deletion web/pgadmin/static/js/tree/ObjectExplorer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default function ObjectExplorer() {
return mtree.readNode(path);
},
sortComparator: (a, b) => {
// No nee to sort columns
// No need to sort columns
if (a._metadata && a._metadata.data._type == 'column') return 0;
// Sort alphabetically
if (a.constructor === b.constructor) {
Expand Down
4 changes: 2 additions & 2 deletions web/pgadmin/static/js/tree/tree_nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class ManageTreeNodes {
if (item) {
item.data = {...item.data, ..._data};
item.name = _data.label;
item.metadata.data = _data;
item.metadata = { data: _data, ...item.metadata };
}
res(true);
});
Expand Down Expand Up @@ -81,7 +81,7 @@ export class ManageTreeNodes {
const api = getApiInstance();

if (node && node.children.length > 0) {
if (node.type !== FileType.File) {
if (node.type === FileType.File) {
console.error(node, 'It\'s a leaf node');
return [];
}
Expand Down