public inbox for [email protected]  
help / color / mirror / Atom feed
From: Surinder Kumar <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin4][Patch]: RM1682 - create new Procedure option should not available on System catalog
Date: Mon, 12 Sep 2016 10:42:13 +0530
Message-ID: <CAM5-9D8KtB8xSrL3z90CG_VEPm002oAPA-s3d3CHGR9p6Q3iMw@mail.gmail.com> (raw)
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-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;


view thread (4+ 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: [pgAdmin4][Patch]: RM1682 - create new Procedure option should not available on System catalog
  In-Reply-To: <CAM5-9D8KtB8xSrL3z90CG_VEPm002oAPA-s3d3CHGR9p6Q3iMw@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