From abe530344805b0a9dfbb3b1d58ba67f6dfc03902 Mon Sep 17 00:00:00 2001 From: Yogesh Mahajan Date: Sun, 28 Nov 2021 13:32:30 +0530 Subject: [PATCH] Fixed an issue where the error is thrown while creating a new server using Add New Server from the dashboard while tree item is not selected. Fixes #7015 --- docs/en_US/release_notes_6_3.rst | 1 + web/pgadmin/dashboard/static/js/dashboard.js | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/en_US/release_notes_6_3.rst b/docs/en_US/release_notes_6_3.rst index 65152f028..c10f250c5 100644 --- a/docs/en_US/release_notes_6_3.rst +++ b/docs/en_US/release_notes_6_3.rst @@ -28,3 +28,4 @@ Bug fixes | `Issue #7005 `_ - Fixed an issue where On-demand rows throw an error when any row cell is edited and saved it then scroll to get more rows. | `Issue #7006 `_ - Ensure that Python 3.10 and the latest eventlet dependency should not break the application. | `Issue #7013 `_ - Fix an RPM build issue that could lead to a conflict with python3 at installation. +| `Issue #7015 `_ - Fixed an issue where the error is thrown while creating a new server using Add New Server from the dashboard while tree item is not selected. diff --git a/web/pgadmin/dashboard/static/js/dashboard.js b/web/pgadmin/dashboard/static/js/dashboard.js index 6e6228304..51425a679 100644 --- a/web/pgadmin/dashboard/static/js/dashboard.js +++ b/web/pgadmin/dashboard/static/js/dashboard.js @@ -394,9 +394,9 @@ define('pgadmin.dashboard', [ // Handler function to support the "Add Server" link add_new_server: function() { if (pgBrowser && pgBrowser.tree) { - var i = pgBrowser.tree.selected().length != 0 ? - pgBrowser.tree.selected() : - pgBrowser.tree.first(null, false), + var i = _.isUndefined(pgBrowser.tree.selected()) ? + pgBrowser.tree.first(null, false): + pgBrowser.tree.selected(), serverModule = require('pgadmin.node.server'), itemData = pgBrowser.tree.itemData(i); @@ -1141,7 +1141,7 @@ define('pgadmin.dashboard', [ this.chartsDomObj && this.chartsDomObj.unmount(); } else { var t = pgBrowser.tree, - i = t.selected(), + i = t ? t.selected() : 0, d = i && t.itemData(i); this.chartsDomObj && this.chartsDomObj.setPageVisible(dashboardVisible);