public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin4][Patch]: RM1682 - create new Procedure option should not available on System catalog
4+ messages / 3 participants
[nested] [flat]

* [pgAdmin4][Patch]: RM1682 - create new Procedure option should not available on System catalog
@ 2016-09-12 05:12 Surinder Kumar <[email protected]>
  2016-09-12 05:43 ` Re: [pgAdmin4][Patch]: RM1682 - create new Procedure option should not available on System catalog Murtuza Zabuawala <[email protected]>
  2016-09-12 10:37 ` Re: [pgAdmin4][Patch]: RM1682 - create new Procedure option should not available on System catalog Dave Page <[email protected]>
  0 siblings, 2 replies; 4+ messages in thread

From: Surinder Kumar @ 2016-09-12 05:12 UTC (permalink / raw)
  To: pgadmin-hackers

Hi

*Please find attached with following fixes:*

1) The function '*canCreateProc*' that checks if package is auth to create
under catalog gets failed due to improper check of 'type'. Instead check
should be like
node_hierarchy['server'].*server_type* == "ppas" not
node_hierarchy['server'].*type* == "ppas"

2) Also found, *package.js* was loading at schema level, due to this,
context menu doesn't popup under catalog. Now it is load at database level.

3) In *package.js*, remove extra comma from columns array.

4) Rule create option should not available on table under catalogs. Fixed.

Please review.

Thanks,
Surinder Kumar


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Attachments:

  [application/octet-stream] RM1682.patch (5.7K, 3-RM1682.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedure/js/procedures.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedure/js/procedures.js
index af61946..a3cfc5d 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedure/js/procedures.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedure/js/procedures.js
@@ -46,13 +46,13 @@ function($, _, S, pgAdmin, pgBrowser, alertify, Function) {
           applies: ['object', 'context'], callback: 'show_obj_properties',
           category: 'create', priority: 4, label: '{{ _('Procedure...') }}',
           icon: 'wcTabIcon icon-procedure', data: {action: 'create', check:
-          false}
+          false}, enable: 'canCreateProc'
         },{
           name: 'create_procedure', node: 'procedure', module: this,
           applies: ['object', 'context'], callback: 'show_obj_properties',
           category: 'create', priority: 4, label: '{{ _('Procedure...') }}',
           icon: 'wcTabIcon icon-procedure', data: {action: 'create', check:
-          true},
+          true}, enable: 'canCreateProc'
         },{
           name: 'create_procedure', node: 'schema', module: this,
           applies: ['object', 'context'], callback: 'show_obj_properties',
@@ -64,6 +64,19 @@ function($, _, S, pgAdmin, pgBrowser, alertify, Function) {
       },
       canDrop: pgSchemaNode.canChildDrop,
       canDropCascade: false,
+      canCreateProc: function(itemData, item, data) {
+        var node_hierarchy = this.getTreeNodeHierarchy.apply(this, [item]);
+
+        // Do not provide Create option in catalog
+        if ('catalog' in node_hierarchy)
+          return false;
+
+        // Procedures supported only in PPAS
+        if ('server' in node_hierarchy && node_hierarchy['server'].server_type == "ppas")
+          return true;
+
+        return false;
+      },
       model: Function.model.extend({
         defaults: _.extend({},
           Function.model.prototype.defaults,
@@ -166,22 +179,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify, Function) {

           return null;
         },
-      }
-      ),
-      canCreateProc: function(itemData, item, data) {
-        var node_hierarchy = this.getTreeNodeHierarchy.apply(this, [item]);
-
-        // Do not provide Create option in catalog
-        if ('catalog' in node_hierarchy)
-          return false;
-
-        // Procedures supported only in PPAS
-        if ('server' in node_hierarchy && node_hierarchy['server'].type == "ppas")
-          return true;
-
-        return false;
-
-      }
+      })
   });

   }
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/__init__.py
index 2d90234..77482a9 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/__init__.py
@@ -12,7 +12,7 @@ import re
 import simplejson as json
 from functools import wraps

-import pgadmin.browser.server_groups.servers.databases.schemas as schemas
+import pgadmin.browser.server_groups.servers.databases as database
 from flask import render_template, make_response, request, jsonify
 from flask_babel import gettext as _
 from pgadmin.browser.server_groups.servers.databases.schemas.utils \
@@ -72,7 +72,7 @@ class PackageModule(SchemaChildModule):
         Load the module script for schema, when any of the database node is
         initialized.
         """
-        return schemas.SchemaModule.NODE_TYPE
+        return database.DatabaseModule.NODE_TYPE


 blueprint = PackageModule(__name__)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/package/js/package.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/package/js/package.js
index e269c60..eeca349 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/package/js/package.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/package/js/package.js
@@ -9,7 +9,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
         node: 'package',
         label: '{{ _('Packages') }}',
         type: 'coll-package',
-        columns: ['name', ,'owner', 'description']
+        columns: ['name' ,'owner', 'description']
       });
   };

@@ -22,7 +22,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
       collection_type: 'coll-package',
       hasSQL: true,
       hasDepends: true,
-      parent_type: ['schema'],
+      parent_type: ['schema', 'catalog'],
       Init: function() {
         /* Avoid mulitple registration of menus */
         if (this.initialized)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/templates/rules/js/rules.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/templates/rules/js/rules.js
index dfc32c4..d34e3ce 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/templates/rules/js/rules.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/templates/rules/js/rules.js
@@ -240,7 +240,7 @@ function($, _, S, pgAdmin, pgBrowser, CodeMirror) {
             Check if it is view and its parent node is schema
             then allow to create Rule
            */
-          else if('view' == d._type){
+          else if('view' == d._type || 'table' == d._type){
             prev_i = t.hasParent(i) ? t.parent(i) : null;
             prev_d = prev_i ? t.itemData(prev_i) : null;
             prev_j = t.hasParent(prev_i) ? t.parent(prev_i) : null;


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [pgAdmin4][Patch]: RM1682 - create new Procedure option should not available on System catalog
  2016-09-12 05:12 [pgAdmin4][Patch]: RM1682 - create new Procedure option should not available on System catalog Surinder Kumar <[email protected]>
@ 2016-09-12 05:43 ` Murtuza Zabuawala <[email protected]>
  2016-09-12 06:21   ` Re: [pgAdmin4][Patch]: RM1682 - create new Procedure option should not available on System catalog Surinder Kumar <[email protected]>
  1 sibling, 1 reply; 4+ messages in thread

From: Murtuza Zabuawala @ 2016-09-12 05:43 UTC (permalink / raw)
  To: Surinder Kumar <[email protected]>; +Cc: pgadmin-hackers

Hi Surinder,

Just a heads up, When server is not connected and listed down in browser
tree then node has attribute 'type' instead of 'server_type'.
I have fixed similar issue few days ago Ref. link
<https://git.postgresql.org/gitweb/?p=pgadmin4.git;a=commit;h=013ff1090e4b084166077a9e43196a91d7e17e2...;

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Mon, Sep 12, 2016 at 10:42 AM, Surinder Kumar <
[email protected]> wrote:

> Hi
>
> *Please find attached with following fixes:*
>
> 1) The function '*canCreateProc*' that checks if package is auth to
> create under catalog gets failed due to improper check of 'type'. Instead
> check should be like
> node_hierarchy['server'].*server_type* == "ppas" not
> node_hierarchy['server'].*type* == "ppas"
>
> 2) Also found, *package.js* was loading at schema level, due to this,
> context menu doesn't popup under catalog. Now it is load at database level.
>
> 3) In *package.js*, remove extra comma from columns array.
>
> 4) Rule create option should not available on table under catalogs. Fixed.
>
> Please review.
>
> Thanks,
> Surinder Kumar
>
>
> --
> Sent via pgadmin-hackers mailing list ([email protected])
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>
>


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [pgAdmin4][Patch]: RM1682 - create new Procedure option should not available on System catalog
  2016-09-12 05:12 [pgAdmin4][Patch]: RM1682 - create new Procedure option should not available on System catalog Surinder Kumar <[email protected]>
  2016-09-12 05:43 ` Re: [pgAdmin4][Patch]: RM1682 - create new Procedure option should not available on System catalog Murtuza Zabuawala <[email protected]>
@ 2016-09-12 06:21   ` Surinder Kumar <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Surinder Kumar @ 2016-09-12 06:21 UTC (permalink / raw)
  To: Murtuza Zabuawala <[email protected]>; +Cc: pgadmin-hackers

On Mon, Sep 12, 2016 at 11:13 AM, Murtuza Zabuawala <murtuza.zabuawala@
enterprisedb.com> wrote:

> Hi Surinder,
>
> Just a heads up, When server is not connected and listed down in browser
> tree then node has attribute 'type' instead of 'server_type'.
> I have fixed similar issue few days ago Ref. link
> <https://git.postgresql.org/gitweb/?p=pgadmin4.git;a=commit;h=013ff1090e4b084166077a9e43196a91d7e17e2...;
>
 Yup this was a
​bug
.
​ Previously, *server_type* was not returned​ on listing down after
disconnect then connect.
 And
​
it has already been taken care in this commit​
<https://www.postgresql.org/message-id/[email protected];
.
 So, the check will work fine with *server_type​. *

>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Mon, Sep 12, 2016 at 10:42 AM, Surinder Kumar <
> [email protected]> wrote:
>
>> Hi
>>
>> *Please find attached with following fixes:*
>>
>> 1) The function '*canCreateProc*' that checks if package is auth to
>> create under catalog gets failed due to improper check of 'type'. Instead
>> check should be like
>> node_hierarchy['server'].*server_type* == "ppas" not
>> node_hierarchy['server'].*type* == "ppas"
>>
>> 2) Also found, *package.js* was loading at schema level, due to this,
>> context menu doesn't popup under catalog. Now it is load at database level.
>>
>> 3) In *package.js*, remove extra comma from columns array.
>>
>> 4) Rule create option should not available on table under catalogs. Fixed.
>>
>> Please review.
>>
>> Thanks,
>> Surinder Kumar
>>
>>
>> --
>> Sent via pgadmin-hackers mailing list ([email protected])
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>
>>
>


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [pgAdmin4][Patch]: RM1682 - create new Procedure option should not available on System catalog
  2016-09-12 05:12 [pgAdmin4][Patch]: RM1682 - create new Procedure option should not available on System catalog Surinder Kumar <[email protected]>
@ 2016-09-12 10:37 ` Dave Page <[email protected]>
  1 sibling, 0 replies; 4+ messages in thread

From: Dave Page @ 2016-09-12 10:37 UTC (permalink / raw)
  To: Surinder Kumar <[email protected]>; +Cc: pgadmin-hackers

Thanks, applied.

On Mon, Sep 12, 2016 at 6:12 AM, Surinder Kumar
<[email protected]> wrote:
> Hi
>
> Please find attached with following fixes:
>
> 1) The function 'canCreateProc' that checks if package is auth to create
> under catalog gets failed due to improper check of 'type'. Instead check
> should be like
> node_hierarchy['server'].server_type == "ppas" not
> node_hierarchy['server'].type == "ppas"
>
> 2) Also found, package.js was loading at schema level, due to this, context
> menu doesn't popup under catalog. Now it is load at database level.
>
> 3) In package.js, remove extra comma from columns array.
>
> 4) Rule create option should not available on table under catalogs. Fixed.
>
> Please review.
>
> Thanks,
> Surinder Kumar
>
>
> --
> Sent via pgadmin-hackers mailing list ([email protected])
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>



-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2016-09-12 10:37 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-09-12 05:12 [pgAdmin4][Patch]: RM1682 - create new Procedure option should not available on System catalog Surinder Kumar <[email protected]>
2016-09-12 05:43 ` Murtuza Zabuawala <[email protected]>
2016-09-12 06:21   ` Surinder Kumar <[email protected]>
2016-09-12 10:37 ` Dave Page <[email protected]>

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