mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-22 16:56:30 -06:00
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:
parent
09bdf1fab7
commit
611c9c4ae7
@ -65,17 +65,20 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
|
||||
name: 'create_database_on_server', node: 'server', module: this,
|
||||
applies: ['object', 'context'], callback: 'show_obj_properties',
|
||||
category: 'create', priority: 4, label: '{{ _('Database...') }}',
|
||||
icon: 'wcTabIcon pg-icon-database', data: {action: 'create'}
|
||||
icon: 'wcTabIcon pg-icon-database', data: {action: 'create'},
|
||||
enable: 'can_create_database'
|
||||
},{
|
||||
name: 'create_database_on_coll', node: 'coll-database', module: this,
|
||||
applies: ['object', 'context'], callback: 'show_obj_properties',
|
||||
category: 'create', priority: 4, label: '{{ _('Database...') }}',
|
||||
icon: 'wcTabIcon pg-icon-database', data: {action: 'create'}
|
||||
icon: 'wcTabIcon pg-icon-database', data: {action: 'create'},
|
||||
enable: 'can_create_database'
|
||||
},{
|
||||
name: 'create_database', node: 'database', module: this,
|
||||
applies: ['object', 'context'], callback: 'show_obj_properties',
|
||||
category: 'create', priority: 4, label: '{{ _('Database...') }}',
|
||||
icon: 'wcTabIcon pg-icon-database', data: {action: 'create'}
|
||||
icon: 'wcTabIcon pg-icon-database', data: {action: 'create'},
|
||||
enable: 'can_create_database'
|
||||
},{
|
||||
name: 'connect_database', node: 'database', module: this,
|
||||
applies: ['object', 'context'], callback: 'connect_database',
|
||||
@ -88,6 +91,12 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
|
||||
icon: 'fa fa-chain-broken', enable : 'is_connected'
|
||||
}]);
|
||||
},
|
||||
can_create_database: function(node, item) {
|
||||
var treeData = this.getTreeNodeHierarchy(item),
|
||||
server = treeData['server'];
|
||||
|
||||
return server.connected && server.user.can_create_db;
|
||||
},
|
||||
is_not_connected: function(node) {
|
||||
return (node && node.connected != true);
|
||||
},
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user