mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-16 18:25:12 -06:00
Prevent creation of packages and rules in catalogs. Fixes #1682
This commit is contained in:
parent
70ea03a872
commit
28b7a033bc
@ -46,13 +46,13 @@ function($, _, S, pgAdmin, pgBrowser, alertify, Function) {
|
|||||||
applies: ['object', 'context'], callback: 'show_obj_properties',
|
applies: ['object', 'context'], callback: 'show_obj_properties',
|
||||||
category: 'create', priority: 4, label: '{{ _('Procedure...') }}',
|
category: 'create', priority: 4, label: '{{ _('Procedure...') }}',
|
||||||
icon: 'wcTabIcon icon-procedure', data: {action: 'create', check:
|
icon: 'wcTabIcon icon-procedure', data: {action: 'create', check:
|
||||||
false}
|
false}, enable: 'canCreateProc'
|
||||||
},{
|
},{
|
||||||
name: 'create_procedure', node: 'procedure', module: this,
|
name: 'create_procedure', node: 'procedure', module: this,
|
||||||
applies: ['object', 'context'], callback: 'show_obj_properties',
|
applies: ['object', 'context'], callback: 'show_obj_properties',
|
||||||
category: 'create', priority: 4, label: '{{ _('Procedure...') }}',
|
category: 'create', priority: 4, label: '{{ _('Procedure...') }}',
|
||||||
icon: 'wcTabIcon icon-procedure', data: {action: 'create', check:
|
icon: 'wcTabIcon icon-procedure', data: {action: 'create', check:
|
||||||
true},
|
true}, enable: 'canCreateProc'
|
||||||
},{
|
},{
|
||||||
name: 'create_procedure', node: 'schema', module: this,
|
name: 'create_procedure', node: 'schema', module: this,
|
||||||
applies: ['object', 'context'], callback: 'show_obj_properties',
|
applies: ['object', 'context'], callback: 'show_obj_properties',
|
||||||
@ -64,6 +64,19 @@ function($, _, S, pgAdmin, pgBrowser, alertify, Function) {
|
|||||||
},
|
},
|
||||||
canDrop: pgSchemaNode.canChildDrop,
|
canDrop: pgSchemaNode.canChildDrop,
|
||||||
canDropCascade: false,
|
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({
|
model: Function.model.extend({
|
||||||
defaults: _.extend({},
|
defaults: _.extend({},
|
||||||
Function.model.prototype.defaults,
|
Function.model.prototype.defaults,
|
||||||
@ -166,22 +179,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify, Function) {
|
|||||||
|
|
||||||
return null;
|
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;
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import re
|
|||||||
import simplejson as json
|
import simplejson as json
|
||||||
from functools import wraps
|
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 import render_template, make_response, request, jsonify
|
||||||
from flask_babel import gettext as _
|
from flask_babel import gettext as _
|
||||||
from pgadmin.browser.server_groups.servers.databases.schemas.utils \
|
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
|
Load the module script for schema, when any of the database node is
|
||||||
initialized.
|
initialized.
|
||||||
"""
|
"""
|
||||||
return schemas.SchemaModule.NODE_TYPE
|
return database.DatabaseModule.NODE_TYPE
|
||||||
|
|
||||||
|
|
||||||
blueprint = PackageModule(__name__)
|
blueprint = PackageModule(__name__)
|
||||||
|
@ -9,7 +9,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
|||||||
node: 'package',
|
node: 'package',
|
||||||
label: '{{ _('Packages') }}',
|
label: '{{ _('Packages') }}',
|
||||||
type: 'coll-package',
|
type: 'coll-package',
|
||||||
columns: ['name', ,'owner', 'description']
|
columns: ['name' ,'owner', 'description']
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
|||||||
collection_type: 'coll-package',
|
collection_type: 'coll-package',
|
||||||
hasSQL: true,
|
hasSQL: true,
|
||||||
hasDepends: true,
|
hasDepends: true,
|
||||||
parent_type: ['schema'],
|
parent_type: ['schema', 'catalog'],
|
||||||
Init: function() {
|
Init: function() {
|
||||||
/* Avoid mulitple registration of menus */
|
/* Avoid mulitple registration of menus */
|
||||||
if (this.initialized)
|
if (this.initialized)
|
||||||
|
@ -240,7 +240,7 @@ function($, _, S, pgAdmin, pgBrowser, CodeMirror) {
|
|||||||
Check if it is view and its parent node is schema
|
Check if it is view and its parent node is schema
|
||||||
then allow to create Rule
|
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_i = t.hasParent(i) ? t.parent(i) : null;
|
||||||
prev_d = prev_i ? t.itemData(prev_i) : null;
|
prev_d = prev_i ? t.itemData(prev_i) : null;
|
||||||
prev_j = t.hasParent(prev_i) ? t.parent(prev_i) : null;
|
prev_j = t.hasParent(prev_i) ? t.parent(prev_i) : null;
|
||||||
|
Loading…
Reference in New Issue
Block a user