Fix various inconsistencies with databases and tablespaces:

- Display the ACL string in properties, not the subnode panel.
- Offer default values for the owner of new objects.
- Add missing context menu option to create a tablespace from a server node.
This commit is contained in:
Dave Page 2016-03-10 16:14:26 +00:00
parent f95b9f06ca
commit 2b6c8dff0b
5 changed files with 38 additions and 4 deletions

View File

@ -205,6 +205,18 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
defseqacl: [],
deftypeacl: []
},
// Default values!
initialize: function(attrs, args) {
var isNew = (_.size(attrs) === 0);
if (isNew) {
var userInfo = pgBrowser.serverInfo[args.node_info.server._id].user;
this.set({'datowner': userInfo.name}, {silent: true});
}
pgAdmin.Browser.Node.Model.prototype.initialize.apply(this, arguments);
},
schema: [{
id: 'name', label: '{{ _('Database') }}', cell: 'string',
editable: false, type: 'text'

View File

@ -57,6 +57,11 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
this.initialized = true;
pgBrowser.add_menus([{
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'}
},{
name: 'create_tablespace_on_coll', node: 'coll-tablespace', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: '{{ _('Tablespace...') }}',
@ -79,6 +84,18 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
spcacl: [],
seclabels:[]
},
// Default values!
initialize: function(attrs, args) {
var isNew = (_.size(attrs) === 0);
if (isNew) {
var userInfo = pgBrowser.serverInfo[args.node_info.server._id].user;
this.set({'spcuser': userInfo.name}, {silent: true});
}
pgAdmin.Browser.Node.Model.prototype.initialize.apply(this, arguments);
},
schema: [{
id: 'name', label: '{{ _('Name') }}', cell: 'string',
type: 'text'
@ -96,6 +113,9 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
},{
id: 'spcuser', label:'{{ _('Owner') }}', cell: 'string',
type: 'text', control: 'node-list-by-name', node: 'role'
},{
id: 'acl', label: '{{ _('Privileges') }}', type: 'text',
mode: ['properties'], disabled: true
},{
id: 'description', label:'{{ _('Comment') }}', cell: 'string',
type: 'multiline'
@ -109,7 +129,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
id: 'spcacl', label: 'Privileges', type: 'collection',
group: '{{ _('Security') }}', control: 'unique-col-collection',
model: pgAdmin.Browser.Node.PrivilegeRoleModel.extend({privileges: ['C']}),
mode: ['properties', 'edit', 'create'], canAdd: true, canDelete: true,
mode: ['edit', 'create'], canAdd: true, canDelete: true,
uniqueCol : ['grantee'],
columns: ['grantee', 'grantor', 'privileges']
},{

View File

@ -2,7 +2,8 @@
SELECT
ts.oid, spcname AS name, spclocation, spcoptions,
pg_get_userbyid(spcowner) as spcuser, spcacl,
pg_catalog.shobj_description(oid, 'pg_tablespace') AS description
pg_catalog.shobj_description(oid, 'pg_tablespace') AS description,
spcacl as acl
FROM
pg_tablespace ts
{% if tsid %}

View File

@ -6,7 +6,8 @@ SELECT
(SELECT
array_agg(provider || '=' || label)
FROM pg_shseclabel sl1
WHERE sl1.objoid=ts.oid) AS seclabels
WHERE sl1.objoid=ts.oid) AS seclabels,
spcacl as acl
FROM
pg_tablespace ts
{% if tsid %}

View File

@ -1,5 +1,5 @@
{### SQL to fetch tablespace object properties ###}
SELECT ts.oid, spcname AS name, spclocation, spcoptions, pg_get_userbyid(spcowner) as spcuser, spcacl,
SELECT ts.oid, spcname AS name, spclocation, spcoptions, pg_get_userbyid(spcowner) as spcuser, spcacl, spcacl as acl
pg_catalog.shobj_description(oid, 'pg_tablespace') AS description
FROM pg_tablespace ts
{% if tsid %}