mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-16 18:26:16 +01:00
added api for repository information panels
This commit is contained in:
@@ -161,10 +161,10 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
|
||||
console.debug( item.name + ' selected' );
|
||||
}
|
||||
|
||||
var panels = [{
|
||||
item: item,
|
||||
xtype: 'repositoryInfoPanel'
|
||||
}];
|
||||
var infoPanel = main.getInfoPanel(item.type);
|
||||
infoPanel.item = item;
|
||||
|
||||
var panels = [infoPanel];
|
||||
|
||||
if ( Sonia.repository.isOwner(item) ){
|
||||
Ext.getCmp('repoRmButton').setDisabled(false);
|
||||
@@ -211,6 +211,8 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
|
||||
// register xtype
|
||||
Ext.reg('repositoryGrid', Sonia.repository.Grid);
|
||||
|
||||
// default repository information panel
|
||||
|
||||
Sonia.repository.InfoPanel = Ext.extend(Ext.Panel, {
|
||||
|
||||
linkTemplate: '<a target="_blank" href="{0}">{0}</a>',
|
||||
@@ -250,27 +252,21 @@ Sonia.repository.InfoPanel = Ext.extend(Ext.Panel, {
|
||||
},{
|
||||
xtype: 'box',
|
||||
html: String.format(this.linkTemplate, this.item.url)
|
||||
},{
|
||||
xtype: 'box',
|
||||
height: 10,
|
||||
colspan: 2
|
||||
},{
|
||||
xtype: 'link',
|
||||
colspan: 2,
|
||||
text: 'ChangesetViewer',
|
||||
listeners: {
|
||||
click: {
|
||||
fn: this.openChangesetViewer,
|
||||
scope: this
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
||||
console.debug(config);
|
||||
this.modifyDefaultConfig(config);
|
||||
console.debug(config);
|
||||
|
||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||
Sonia.repository.InfoPanel.superclass.initComponent.apply(this, arguments);
|
||||
},
|
||||
|
||||
modifyDefaultConfig: function(config){
|
||||
|
||||
},
|
||||
|
||||
getRepositoryTypeText: function(t){
|
||||
var text = null;
|
||||
for ( var i=0; i<state.repositoryTypes.length; i++ ){
|
||||
@@ -283,14 +279,42 @@ Sonia.repository.InfoPanel = Ext.extend(Ext.Panel, {
|
||||
return text;
|
||||
},
|
||||
|
||||
openChangesetViewer: function(){
|
||||
var changesetViewer = {
|
||||
createSpacer: function(){
|
||||
return {
|
||||
xtype: 'box',
|
||||
height: 10,
|
||||
colspan: 2
|
||||
};
|
||||
},
|
||||
|
||||
createChangesetViewerLink: function(){
|
||||
return {
|
||||
xtype: 'link',
|
||||
colspan: 2,
|
||||
text: 'ChangesetViewer',
|
||||
listeners: {
|
||||
click: {
|
||||
fn: this.openChangesetViewer,
|
||||
scope: this
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
createChangesetViewer: function(){
|
||||
return {
|
||||
id: this.item.id + '-changesetViewer',
|
||||
title: 'ChangesetViewer ' + this.item.name,
|
||||
repository: this.item,
|
||||
xtype: 'repositoryChangesetViewerPanel',
|
||||
closable: true,
|
||||
autoScroll: true
|
||||
};
|
||||
},
|
||||
|
||||
openChangesetViewer: function(changesetViewer){
|
||||
if ( changesetViewer == null ){
|
||||
changesetViewer = this.createChangesetViewer();
|
||||
}
|
||||
main.addTab(changesetViewer);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,8 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
||||
|
||||
mainTabPanel: null,
|
||||
|
||||
infoPanels: [],
|
||||
|
||||
constructor : function(config) {
|
||||
this.addEvents('login', 'logout', 'init');
|
||||
this.mainTabPanel = Ext.getCmp('mainTabPanel');
|
||||
@@ -69,7 +71,24 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
||||
},
|
||||
|
||||
init: function(){
|
||||
this.fireEvent('load', this);
|
||||
this.fireEvent('init', this);
|
||||
},
|
||||
|
||||
registerInfoPanel: function(type, panel){
|
||||
this.infoPanels[type] = panel;
|
||||
},
|
||||
|
||||
getInfoPanel: function(type){
|
||||
var rp = null;
|
||||
var panel = this.infoPanels[type];
|
||||
if ( panel == null ){
|
||||
rp = {
|
||||
xtype: 'repositoryInfoPanel'
|
||||
};
|
||||
} else {
|
||||
rp = Sonia.util.clone( panel );
|
||||
}
|
||||
return rp;
|
||||
},
|
||||
|
||||
postLogin: function(){
|
||||
|
||||
@@ -138,6 +138,18 @@
|
||||
|
||||
Ext.ns('Sonia.util');
|
||||
|
||||
// clone method
|
||||
|
||||
Sonia.util.clone = function(obj) {
|
||||
var newObj = (this instanceof Array) ? [] : {};
|
||||
for (i in obj) {
|
||||
if (i == 'clone') continue;
|
||||
if (obj[i] && typeof obj[i] == "object") {
|
||||
newObj[i] = Sonia.util.clone(obj[i]);
|
||||
} else newObj[i] = obj[i]
|
||||
} return newObj;
|
||||
};
|
||||
|
||||
// link
|
||||
|
||||
Sonia.util.Link = Ext.extend(Ext.BoxComponent, {
|
||||
|
||||
Reference in New Issue
Block a user