public inbox for [email protected]  
help / color / mirror / Atom feed
From: Rahul Shirsat <[email protected]>
To: Akshay Joshi <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: [pgAdmin][Patch] #4059 Query Tool button in Query Tool to open a new Query Window
Date: Wed, 9 Sep 2020 18:23:13 +0530
Message-ID: <CAKtn9dOXEObX3ai-1h83ntiqcr+eonFE4juroikNU4n=KUQXtg@mail.gmail.com> (raw)
In-Reply-To: <CANxoLDfA4NnprMEhYtPj9JTDG036L5VOed3Lpk-C20xn0bXSsg@mail.gmail.com>
References: <CAKtn9dPt5BB_vGqxYfbrPx7R=RWgXQsCPr0aCEtVDnN3W5C3-A@mail.gmail.com>
	<CAKtn9dM5woCVYAc5dKAZ=eSuoDCw1HnJFNcX_=mduQ25Q16Bjg@mail.gmail.com>
	<CANxoLDfA4NnprMEhYtPj9JTDG036L5VOed3Lpk-C20xn0bXSsg@mail.gmail.com>

Hi Akshay,

Please find the attached patch which adds / corrects following features /
issues :

1. Added tooltip & keyboard shortcut for query tool button
2. Corrected the *Uncaught TypeError: Cannot read property ā€˜i’ of undefined*
    This issue can be reproduced by :
     *Keeping the click on any node other than database, refresh the page,
open the same server (it should navigate to the previously selected node),
open query tool, now open query tool via sqleditor query tool button, issue
should be reproduced* - *Resolved*
3. Aditya's changes for *popups are blocked* are now extended for the new
tab query tool too.


On Fri, Aug 28, 2020 at 6:24 PM Akshay Joshi <[email protected]>
wrote:

> Thanks, patch applied.
>
> On Thu, Aug 27, 2020 at 8:16 PM Rahul Shirsat <
> [email protected]> wrote:
>
>>
>> Please find the update patch attached here.
>>
>> On Thu, Aug 27, 2020 at 8:10 PM Rahul Shirsat <
>> [email protected]> wrote:
>>
>>> Hi Hackers,
>>>
>>> Please find the attached patch below which adds the functionality of the
>>> query tool button in the query tool sqleditor.
>>>
>>> *Acceptance criteria:*
>>> - For sqleditor on same window & on new tab:
>>>
>>>    - When a query tool connection is initiated, as expected it will
>>>    open the connection based on the selected database in the treeview. Now,
>>>    when the user clicks the query tool connection button on the query tool
>>>    window, irrespective of the selected database in treeview, it should open a
>>>    connection based on the query tool connected database.
>>>    - Similarly, for a new tab, clicking on the query tool connection
>>>    button, it should open a connection based on the query tool connected
>>>    database, instead of selected treeview node.
>>>
>>> [image: query tool button.png]
>>>
>>> Additionally, an error is handled in the form of message dialog
>>> prompting the user to initiate the connection, when sqleditor is opened in
>>> the new tab with the main application window kept closed. This can be
>>> reviewed by refreshing the window as well as clicking on the query tool
>>> connection button.
>>>
>>> A prompt dialog message box is seen as:
>>>
>>> [image: Screen Shot 2020-08-27 at 8.04.33 PM.png]
>>>
>>> --
>>> *Rahul Shirsat*
>>> Software Engineer | EnterpriseDB Corporation.
>>>
>>
>>
>> --
>> *Rahul Shirsat*
>> Software Engineer | EnterpriseDB Corporation.
>>
>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
> *pgAdmin Hacker | Sr. Software Architect*
> *EDB Postgres <http://edbpostgres.com>*
>
> *Mobile: +91 976-788-8246*
>


-- 
*Rahul Shirsat*
Software Engineer | EnterpriseDB Corporation.


Attachments:

  [image/png] query tool button.png (78.2K, 3-query%20tool%20button.png)
  download | view image

  [image/png] Screen Shot 2020-08-27 at 8.04.33 PM.png (47.9K, 4-Screen%20Shot%202020-08-27%20at%208.04.33%20PM.png)
  download | view image

  [application/octet-stream] RM4059_v3.patch (6.8K, 5-RM4059_v3.patch)
  download | inline diff:
diff --git a/web/pgadmin/static/js/keyboard_shortcuts.js b/web/pgadmin/static/js/keyboard_shortcuts.js
index c021d1830..f02851720 100644
--- a/web/pgadmin/static/js/keyboard_shortcuts.js
+++ b/web/pgadmin/static/js/keyboard_shortcuts.js
@@ -199,6 +199,7 @@ function keyboardShortcutsQueryTool(
   let commitKeys = sqlEditorController.preferences.commit_transaction;
   let rollbackKeys = sqlEditorController.preferences.rollback_transaction;
   let saveDataKeys = sqlEditorController.preferences.save_data;
+  let queryToolKeys = sqlEditorController.preferences.show_query_tool;
 
   if (this.validateShortcutKeys(executeKeys, event)) {
     this._stopEventPropagation(event);
@@ -230,6 +231,9 @@ function keyboardShortcutsQueryTool(
   } else if (this.validateShortcutKeys(saveDataKeys, event)) {
     this._stopEventPropagation(event);
     queryToolActions.saveDataChanges(sqlEditorController);
+  } else if (this.validateShortcutKeys(queryToolKeys, event)) {
+    this._stopEventPropagation(event);
+    queryToolActions.openQueryTool(sqlEditorController);
   } else if ((
     (this.isMac() && event.metaKey) ||
      (!this.isMac() && event.ctrlKey)
diff --git a/web/pgadmin/static/js/sqleditor/query_tool_actions.js b/web/pgadmin/static/js/sqleditor/query_tool_actions.js
index a97582e6a..98297cf18 100644
--- a/web/pgadmin/static/js/sqleditor/query_tool_actions.js
+++ b/web/pgadmin/static/js/sqleditor/query_tool_actions.js
@@ -161,6 +161,14 @@ let queryToolActions = {
     sqlEditorController.close_on_save = false;
     sqlEditorController.save_data();
   },
+
+  openQueryTool: function (sqlEditorController) {
+    sqlEditorController.gridView.handler.trigger(
+      'pgadmin-sqleditor:button:show_query_tool',
+      sqlEditorController.gridView,
+      sqlEditorController.gridView.handler
+    );
+  },
 };
 
 module.exports = queryToolActions;
diff --git a/web/pgadmin/static/js/sqleditor/query_tool_preferences.js b/web/pgadmin/static/js/sqleditor/query_tool_preferences.js
index 5a3d15582..ba4e7c882 100644
--- a/web/pgadmin/static/js/sqleditor/query_tool_preferences.js
+++ b/web/pgadmin/static/js/sqleditor/query_tool_preferences.js
@@ -136,6 +136,12 @@ function updateUIPreferences(sqlEditor) {
     .attr('aria-label',
       shortcut_title(gettext('Rollback'),preferences.rollback_transaction));
 
+  $el.find('#btn-show-query-tool')
+    .attr('title',
+      shortcut_title(gettext('Query tool'),preferences.show_query_tool))
+    .attr('aria-label',
+      shortcut_title(gettext('Query tool'),preferences.show_query_tool));
+
   /* Set explain options on query editor */
   if (preferences.explain_verbose){
     $el.find('.explain-verbose').removeClass('visibility-hidden');
diff --git a/web/pgadmin/tools/datagrid/static/js/show_query_tool.js b/web/pgadmin/tools/datagrid/static/js/show_query_tool.js
index 782bf78e3..9e0723665 100644
--- a/web/pgadmin/tools/datagrid/static/js/show_query_tool.js
+++ b/web/pgadmin/tools/datagrid/static/js/show_query_tool.js
@@ -65,7 +65,15 @@ export function showQueryTool(datagrid, pgBrowser, alertify, url, aciTreeIdentif
 
   const gridUrl = generateUrl(transId, queryToolTitle, parentData);
 
-  datagrid.launch_grid(transId, gridUrl, true, queryToolTitle, sURL);
+  let retVal = datagrid.launch_grid(transId, gridUrl, true, queryToolTitle, sURL);
+  if(!retVal) {
+    alertify.alert(
+      gettext('Query tool launch error'),
+      gettext(
+        'Please allow the pop ups if they are blocked for pgAdmin. If the pgAdmin window is closed then close this window and open a new pgAdmin session.'
+      )
+    );
+  }
 }
 
 export function generateScript(parentData, datagrid) {
diff --git a/web/pgadmin/tools/datagrid/templates/datagrid/index.html b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
index ae240cd5c..e81a42a47 100644
--- a/web/pgadmin/tools/datagrid/templates/datagrid/index.html
+++ b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
@@ -17,7 +17,6 @@
             <div class="btn-group mr-1" role="group" aria-label="">
                 <button id="btn-show-query-tool" type="button" class="btn btn-sm btn-primary-icon btn-show-query-tool"
                         title=""
-                        accesskey=""
                         tabindex="0">
                     <i class="pg-font-icon icon-query-tool" aria-hidden="true" role="img"></i>
                 </button>
diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
index 060207202..b0d5a118f 100644
--- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
@@ -7,6 +7,8 @@
 //
 //////////////////////////////////////////////////////////////
 
+import {getTreeNodeHierarchyFromIdentifier} from 'sources/tree/pgadmin_tree_node';
+
 define('tools.querytool', [
   'sources/gettext', 'sources/url_for', 'jquery', 'jquery.ui',
   'jqueryui.position', 'underscore', 'pgadmin.alertifyjs',
@@ -151,7 +153,8 @@ define('tools.querytool', [
 
     reflectPreferences: function() {
       let self = this,
-        browser = pgWindow.default.pgAdmin.Browser;
+        browser = pgWindow.default.pgAdmin.Browser,
+        browser_preferences = browser.get_preferences_for_module('browser');
 
       /* pgBrowser is different obj from pgWindow.default.pgAdmin.Browser
        * Make sure to get only the latest update. Older versions will be discarded
@@ -162,6 +165,7 @@ define('tools.querytool', [
       if(pgBrowser.preference_version() < browser.preference_version()){
         pgBrowser.preference_version(browser.preference_version());
         self.preferences = browser.get_preferences_for_module('sqleditor');
+        self.preferences.show_query_tool = browser_preferences.sub_menu_query_tool;
         self.handler.preferences = self.preferences;
         queryToolPref.updateUIPreferences(self);
       }
@@ -2078,12 +2082,20 @@ define('tools.querytool', [
     if(!d)
       return;
 
+    const parentData = getTreeNodeHierarchyFromIdentifier.call(pgWindow.default.pgAdmin.Browser, i);
+
+    if(!parentData) {
+      return;
+    }
+
+    let conn_param = parentData.database || parentData.server;
+
     var selected_tree_node = { t, i, d };
 
     if(!pgWindow.default.pgAdmin.selected_tree_map)
       pgWindow.default.pgAdmin.selected_tree_map = new Map();
 
-    pgWindow.default.pgAdmin.selected_tree_map.set(d._pid.toString(), selected_tree_node);
+    pgWindow.default.pgAdmin.selected_tree_map.set(conn_param._id.toString(), selected_tree_node);
   };
 
   _.extend(
@@ -4306,7 +4318,7 @@ define('tools.querytool', [
         var self = this;
 
         setTimeout(() => {
-          var tree_node = pgWindow.default.pgAdmin.selected_tree_map.get(self.url_params.did);
+          var tree_node = pgWindow.default.pgAdmin.selected_tree_map.get(self.url_params.did || self.url_params.sid);
           if(self.preferences.new_browser_tab) {
             is_main_window_alive();
           }


view thread (7+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: [pgAdmin][Patch] #4059 Query Tool button in Query Tool to open a new Query Window
  In-Reply-To: <CAKtn9dOXEObX3ai-1h83ntiqcr+eonFE4juroikNU4n=KUQXtg@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox