Skip to content

Commit d54854c

Browse files
committed
Fix issue with server groups not getting reordered on label update:
- set RECREATE operation for server group updates - call remove -> create => and update tree methods on the updated server group node to force resort on server group siblings
1 parent 8421872 commit d54854c

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

web/pgadmin/browser/static/js/browser.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,20 @@ define('pgadmin.browser', [
783783
) {
784784
let _parent = this.t.parent(this.i) || null;
785785

786+
// if the node is a server group
787+
if (_item_parent.path === '/browser') {
788+
let that = this;
789+
// first remove the node from the tree
790+
this.t.remove(this.i).then(() => {
791+
// then add in the updated node with updated item data
792+
this.t.tree.create(_parent, that.new).then((new_item) => {
793+
// then we need to call update so that item.metadata is populated
794+
this.t.update(new_item, that.new);
795+
});
796+
});
797+
}
786798
// If there is no parent then just update the node
787-
if(this.t.isRootNode(_parent) ||
799+
else if(this.t.isRootNode(_parent) ||
788800
(_parent && _parent.length == 0 && ctx.op == 'UPDATE')) {
789801
//Update node if browser has single child node.
790802
if(this.t.children().length === 1) {
@@ -1189,6 +1201,10 @@ define('pgadmin.browser', [
11891201
) {
11901202
ctx.op = 'RECREATE';
11911203
traversePath();
1204+
// call RECREATE operation for server_groups so that the hierarchy is reordered on server group name update
1205+
} else if (_old._type == 'server_group' && _new._type == 'server_group') {
1206+
ctx.op = 'RECREATE';
1207+
traversePath();
11921208
} else {
11931209
ctx.op = 'UPDATE';
11941210
traversePath();

web/pgadmin/static/js/components/PgTree/FileTreeX/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,6 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
294294
private readonly update = async (item, itemData): Promise<void> => {
295295
item._metadata.data = itemData;
296296
await this.props.update(item.path, itemData);
297-
await this.changeResolvePath(item);
298-
await this.remove(item);
299-
await this.create(item.parent, itemData);
300297
this.events.dispatch(FileTreeXEvent.onTreeEvents, window.event, 'updated', item);
301298
};
302299

web/pgadmin/static/js/components/PgTree/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export interface IFileTreeXProps {
8181
* Amalgam of unix's `mkdir` and `touch` command
8282
*/
8383
create: (path: string, type: FileType) => IFileEntryItem | Promise<IFileEntryItem>
84+
update: (path: string, data: {}) => IFileEntryItem | Promise<boolean>
8485
onReady?: (handle: IFileTreeXHandle) => void
8586
onEvent?: (event: IFileTreeXTriggerEvents) => void
8687
onContextMenu?: (ev: React.MouseEvent, item?: FileOrDir) => void

0 commit comments

Comments
 (0)