mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-08 05:10:20 +01:00
display repository access permissions on info panel, see issue #364
This commit is contained in:
@@ -233,4 +233,4 @@ div.noscript-container h1 {
|
||||
|
||||
.upload-icon {
|
||||
background: url('../images/add.png') no-repeat 0 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user