public inbox for [email protected]  
help / color / mirror / Atom feed
From: Pradip Parkale <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin][RM6355]: pgAdmin is able to open external files that are dragged into it.
Date: Tue, 27 Apr 2021 20:11:57 +0530
Message-ID: <CAJ9T6Su6_JrFaqy7y9mKGpYWwav=TcvH_kJs1NKm=4pzeXE6ug@mail.gmail.com> (raw)

Hi Hackers,

Please find the attached patch for #6355. I have added the event to prevent
the browser from opening the dragged file.


-- 
Thanks & Regards,
Pradip Parkale
Software Engineer | EnterpriseDB Corporation


Attachments:

  [application/octet-stream] RM6355.patch (1.8K, 3-RM6355.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/static/js/panel.js b/web/pgadmin/browser/static/js/panel.js
index bf9e874ce..8c0fd3b03 100644
--- a/web/pgadmin/browser/static/js/panel.js
+++ b/web/pgadmin/browser/static/js/panel.js
@@ -97,6 +97,17 @@ define(
                 that.onCreate.apply(that, [myPanel, $container]);
               }
 
+              // Prevent browser from opening the drag file.
+              $('.pg-panel-content').bind('dragover', function (event) {
+                event.stopPropagation();
+                event.preventDefault();
+              });
+              $('.pg-panel-content').bind('drop', function (event) {
+                event.stopPropagation();
+                event.preventDefault();
+
+              });
+
               if (that.elContainer) {
                 myPanel.pgElContainer = $container;
                 $container.addClass('pg-el-container');
diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
index b5503255c..4486832c2 100644
--- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
@@ -491,6 +491,17 @@ define('tools.querytool', [
         }, 200);
       });
 
+      // Prevent browser from opening the drag file.
+      $('#datagrid').bind('dragover', function (event) {
+        event.stopPropagation();
+        event.preventDefault();
+      });
+      $('#datagrid').bind('drop', function (event) {
+        event.stopPropagation();
+        event.preventDefault();
+
+      });
+
       var open_new_tab = self.browser_preferences.new_browser_tab_open;
       if (_.isNull(open_new_tab) || _.isUndefined(open_new_tab) || !open_new_tab.includes('qt')) {
         // Listen on the panel closed event and notify user to save modifications.


view thread (5+ 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]
  Subject: Re: [pgAdmin][RM6355]: pgAdmin is able to open external files that are dragged into it.
  In-Reply-To: <CAJ9T6Su6_JrFaqy7y9mKGpYWwav=TcvH_kJs1NKm=4pzeXE6ug@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