Re: [pgadmin4] Hide tabs in create table - Mailing list pgadmin-hackers

From Ashesh Vashi
Subject Re: [pgadmin4] Hide tabs in create table
Date
Msg-id CAG7mmoxA7R4OsbkKSKn2xiiCmmLFeHUs30tM8qwe7w3sYAs7vg@mail.gmail.com
Whole thread Raw
In response to [pgadmin4] Hide tabs in create table  (Joao De Almeida Pereira <jdealmeidapereira@pivotal.io>)
Responses Re: [pgadmin4] Hide tabs in create table  (Joao De Almeida Pereira <jdealmeidapereira@pivotal.io>)
List pgadmin-hackers
On Thu, Feb 8, 2018 at 4:01 AM, Joao De Almeida Pereira <jdealmeidapereira@pivotal.io> wrote:
Hi hackers, 
We are trying to hide the advanced tab in the Create Table screen, and we were looking into table.js file, but cannot find a way to hide it .

Does anyone have an idea on how to do this?
Please take a look at the code in foreign_data_wrapper.js (line #151), where we've defined 'group' as:
{
          id: 'security', label: gettext('Security'), type: 'group',
},
 
You can also define 'visible' parameter for this type of schema.
i.e.
{
          id: 'advanced', label: gettext('Advanced'), type: 'group', visible: function() { ... }
},
And, replace "group: gettext('Advanced')" with "group: 'advanced'" in all control schema in table.js.

e.g.
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js
@@ -501,12 +501,22 @@ define('pgadmin.node.table', [
               return tbl_oid;
             },
           }),
+        },{
+          id: 'advanced', label: gettext('Advanced'), type: 'group',
+          visible: function(m) {
+            if(!_.isUndefined(m.node_info) && !_.isUndefined(m.node_info.server)
+              && !_.isUndefined(m.node_info.server.version) &&
+                m.node_info.server.version > 100000)
+              return true;
+
+            return false;
+          },
         },{
           id: 'coll_inherits', label: gettext('Inherited from table(s)'),
-          type: 'text', group: gettext('Advanced'), mode: ['properties'],
+          type: 'text', group: 'advanced', mode: ['properties'],
         },{
           id: 'inherited_tables_cnt', label: gettext('Inherited tables count'),
-          type: 'text', mode: ['properties'], group: gettext('Advanced'),
+          type: 'text', mode: ['properties'], group: 'advanced',
           disabled: 'inSchema',
         }

The example patch - it has defined the 'advanced' group, and hide advanced group for server_version < 10, and then used it for 'coll_inherits', and 'inherited_tables_cnt'.

-- Thanks, Ashesh

Thanks
Joao

pgadmin-hackers by date:

Previous
From: Joao De Almeida Pereira
Date:
Subject: Re: [pgadmin][patch] [GreenPlum] When user press Explain Plan andExplain analyze plan an error is displayed
Next
From: Khushboo Vashi
Date:
Subject: [pgAdmin4][Patch]: RM #2899: Provide access keys/shortcuts to allcommonly used menu options in the main window.