display repository access permissions on info panel, see issue #364

This commit is contained in:
Sebastian Sdorra
2013-05-26 14:01:45 +02:00
parent ea39ecb365
commit 08918d8e50
3 changed files with 38 additions and 1 deletions

View File

@@ -233,4 +233,4 @@ div.noscript-container h1 {
.upload-icon {
background: url('../images/add.png') no-repeat 0 0 !important;
}
}

View File

@@ -43,6 +43,11 @@ Sonia.repository.InfoPanel = Ext.extend(Ext.Panel, {
contactText: 'Contact: ',
urlText: 'Url: ',
changesetViewerText: 'Commits',
// TODO i18n
accessText: 'Access:',
accessReadOnly: 'Read-Only access',
accessReadWrite: 'Read+Write access',
initComponent: function(){
@@ -51,6 +56,11 @@ Sonia.repository.InfoPanel = Ext.extend(Ext.Panel, {
contact = String.format(this.mailTemplate, this.item.contact);
}
var access = this.accessReadOnly;
if ( Sonia.repository.getPermissionType(this.item) !== 'READ' ){
access = this.accessReadWrite;
}
var items = [{
xtype: 'label',
text: this.nameText
@@ -69,6 +79,12 @@ Sonia.repository.InfoPanel = Ext.extend(Ext.Panel, {
},{
xtype: 'box',
html: contact
},{
xtype: 'label',
text: this.accessText
},{
xtype: 'box',
html: '<span style="font-weight: bold; color: #747170">' + access + '</span>'
},{
xtype: 'label',
text: this.urlText

View File

@@ -102,6 +102,27 @@ Sonia.repository.getTypeByName = function(name){
return type;
};
Sonia.repository.getPermissionType = function(repository){
var values = [];
values['READ'] = 0;
values['WRITE'] = 10;
values['OWNER'] = 20;
var type = 'READ';
if (state.assignedPermissions){
Ext.each(state.assignedPermissions, function(p){
var parts = p.split(':');
if ( parts[0] === 'repository' && (parts[1] === '*' || parts[1] === repository.id)){
if ( values[parts[2]] > values[type] ){
type = parts[2];
}
}
});
}
return type;
};
/**
* default panel
*/