From 3f63f656748ea1065a19cf65edcfd9ade4fc4e4f Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Fri, 19 Mar 2021 15:38:40 +0530 Subject: [PATCH] Ensure that the view/edit data panel should not be opened for unsupported nodes using the keyboard shortcut. Fixes #6206 --- docs/en_US/release_notes_5_1.rst | 1 + .../tools/datagrid/static/js/show_data.js | 6 ++++++ .../javascript/datagrid/show_data_spec.js | 17 +++-------------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/docs/en_US/release_notes_5_1.rst b/docs/en_US/release_notes_5_1.rst index 053d49cf4..7b96683c2 100644 --- a/docs/en_US/release_notes_5_1.rst +++ b/docs/en_US/release_notes_5_1.rst @@ -38,6 +38,7 @@ Bug fixes | `Issue #5810 `_ - Ensure that cell content being auto selected when editing the cell data. | `Issue #6018 `_ - Fixed encoding issue when database encoding set to SQL_ASCII and name of the column is in ASCII character. | `Issue #6159 `_ - Ensure that the user should be able to kill the session from Dashboard if the user has a 'pg_signal_backend' role. +| `Issue #6206 `_ - Ensure that the view/edit data panel should not be opened for unsupported nodes using the keyboard shortcut. | `Issue #6227 `_ - Ensure PGADMIN_DEFAULT_EMAIL looks sane when initialising a container deployment. | `Issue #6228 `_ - Improve the web setup script for Linux to make the platform detection more robust and overrideable. | `Issue #6253 `_ - Fixed an issue where the user is unable to create a subscription if the host/IP address for connection is 127.0.0.1. diff --git a/web/pgadmin/tools/datagrid/static/js/show_data.js b/web/pgadmin/tools/datagrid/static/js/show_data.js index 19d4e5f92..e41978876 100644 --- a/web/pgadmin/tools/datagrid/static/js/show_data.js +++ b/web/pgadmin/tools/datagrid/static/js/show_data.js @@ -43,6 +43,12 @@ export function showDataGrid( return; } + let applicable_nodes = ['table', 'view', 'mview', 'foreign_table']; + if (applicable_nodes.indexOf(node.getData()._type) === -1) { + alertify.error(gettext('This feature is not applicable to the selected object.')); + return; + } + const gridUrl = generateUrl(transId, connectionData, node.getData(), parentData); const queryToolTitle = generateDatagridTitle(pgBrowser, aciTreeIdentifier); if(filter) { diff --git a/web/regression/javascript/datagrid/show_data_spec.js b/web/regression/javascript/datagrid/show_data_spec.js index 1817206ea..a5c5e9323 100644 --- a/web/regression/javascript/datagrid/show_data_spec.js +++ b/web/regression/javascript/datagrid/show_data_spec.js @@ -30,7 +30,7 @@ describe('#show_data', () => { let transId = 98765432; beforeEach(() => { pgBrowser.preferences_cache = dummy_cache; - alertify = jasmine.createSpyObj('alertify', ['alert']); + alertify = jasmine.createSpyObj('alertify', ['alert', 'error']); datagrid = { launch_grid: jasmine.createSpy('launch_grid'), }; @@ -138,13 +138,7 @@ describe('#show_data', () => { context('current node is underneath a schema', () => { it('does not create a transaction', () => { showDataGrid(datagrid, pgBrowser, alertify, {mnuid: 11}, [{id: 'schema1'}], transId); - - expect(datagrid.launch_grid).toHaveBeenCalledWith( - 98765432, - '/panel/98765432?is_query_tool=false&cmd_type=11&obj_type=schema&obj_id=4&sgid=1&sid=2&did=3&server_type=pg', - false, - 'schema1.schema1/database1/someuser@server1' - ); + expect(datagrid.launch_grid).not.toHaveBeenCalled(); }); }); @@ -164,12 +158,7 @@ describe('#show_data', () => { context('current node is underneath a catalog', () => { it('does not create a transaction', () => { showDataGrid(datagrid, pgBrowser, alertify, {mnuid: 11}, [{id: 'catalog1'}], transId); - expect(datagrid.launch_grid).toHaveBeenCalledWith( - 98765432, - '/panel/98765432?is_query_tool=false&cmd_type=11&obj_type=catalog&obj_id=6&sgid=1&sid=2&did=3&server_type=pg', - false, - 'catalog1.catalog1/database1/someuser@server1' - ); + expect(datagrid.launch_grid).not.toHaveBeenCalled(); }); }); });