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

From Joao De Almeida Pereira
Subject Re: [pgadmin4] Hide tabs in create table
Date
Msg-id CAE+jjampW+1FeqQqDhsx34PCkfnEkeczW1qebshrMgbC5_8Lpg@mail.gmail.com
Whole thread Raw
In response to Re: [pgadmin4] Hide tabs in create table  (Ashesh Vashi <ashesh.vashi@enterprisedb.com>)
List pgadmin-hackers
Thanks Ashesh I will give it a try and see if I can me it work.

On Wed, Feb 7, 2018 at 10:04 PM Ashesh Vashi <ashesh.vashi@enterprisedb.com> wrote:
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: [pgAdmin4][RM#2901] Make shortcuts configurable in Debugger
Next
From: Murtuza Zabuawala
Date:
Subject: Re: [pgAdmin4][RM#2901] Make shortcuts configurable in Debugger