Disable the menu to create database and tablespace, if:

* Database server is not connected.
* Do not have adequate permission to create.
This commit is contained in:
Ashesh Vashi
2016-03-18 10:31:54 +05:30
parent 09bdf1fab7
commit 611c9c4ae7
2 changed files with 24 additions and 6 deletions

View File

@@ -62,20 +62,29 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
name: 'create_tablespace_on_server', node: 'server', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: '{{ _('Tablespace...') }}',
icon: 'wcTabIcon icon-tablespace', data: {action: 'create'}
icon: 'wcTabIcon icon-tablespace', data: {action: 'create'},
enable: 'can_create_tablespace'
},{
name: 'create_tablespace_on_coll', node: 'coll-tablespace', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: '{{ _('Tablespace...') }}',
icon: 'wcTabIcon pg-icon-tablespace', data: {action: 'create'}
icon: 'wcTabIcon pg-icon-tablespace', data: {action: 'create'},
enable: 'can_create_tablespace'
},{
name: 'create_tablespace', node: 'tablespace', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: '{{ _('Tablespace...') }}',
icon: 'wcTabIcon pg-icon-tablespace', data: {action: 'create'}
icon: 'wcTabIcon pg-icon-tablespace', data: {action: 'create'},
enable: 'can_create_tablespace'
}
]);
},
can_create_tablespace: function(node, item) {
var treeData = this.getTreeNodeHierarchy(item),
server = treeData['server'];
return server.connected && server.user.is_superuser;
},
model: pgAdmin.Browser.Node.Model.extend({
defaults: {
name: undefined,