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' );
|
console.debug( item.name + ' selected' );
|
||||||
}
|
}
|
||||||
|
|
||||||
var panels = [{
|
var infoPanel = main.getInfoPanel(item.type);
|
||||||
item: item,
|
infoPanel.item = item;
|
||||||
xtype: 'repositoryInfoPanel'
|
|
||||||
}];
|
var panels = [infoPanel];
|
||||||
|
|
||||||
if ( Sonia.repository.isOwner(item) ){
|
if ( Sonia.repository.isOwner(item) ){
|
||||||
Ext.getCmp('repoRmButton').setDisabled(false);
|
Ext.getCmp('repoRmButton').setDisabled(false);
|
||||||
@@ -211,6 +211,8 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
|
|||||||
// register xtype
|
// register xtype
|
||||||
Ext.reg('repositoryGrid', Sonia.repository.Grid);
|
Ext.reg('repositoryGrid', Sonia.repository.Grid);
|
||||||
|
|
||||||
|
// default repository information panel
|
||||||
|
|
||||||
Sonia.repository.InfoPanel = Ext.extend(Ext.Panel, {
|
Sonia.repository.InfoPanel = Ext.extend(Ext.Panel, {
|
||||||
|
|
||||||
linkTemplate: '<a target="_blank" href="{0}">{0}</a>',
|
linkTemplate: '<a target="_blank" href="{0}">{0}</a>',
|
||||||
@@ -250,27 +252,21 @@ Sonia.repository.InfoPanel = Ext.extend(Ext.Panel, {
|
|||||||
},{
|
},{
|
||||||
xtype: 'box',
|
xtype: 'box',
|
||||||
html: String.format(this.linkTemplate, this.item.url)
|
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));
|
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||||
Sonia.repository.InfoPanel.superclass.initComponent.apply(this, arguments);
|
Sonia.repository.InfoPanel.superclass.initComponent.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
modifyDefaultConfig: function(config){
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
getRepositoryTypeText: function(t){
|
getRepositoryTypeText: function(t){
|
||||||
var text = null;
|
var text = null;
|
||||||
for ( var i=0; i<state.repositoryTypes.length; i++ ){
|
for ( var i=0; i<state.repositoryTypes.length; i++ ){
|
||||||
@@ -283,14 +279,42 @@ Sonia.repository.InfoPanel = Ext.extend(Ext.Panel, {
|
|||||||
return text;
|
return text;
|
||||||
},
|
},
|
||||||
|
|
||||||
openChangesetViewer: function(){
|
createSpacer: function(){
|
||||||
var changesetViewer = {
|
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',
|
id: this.item.id + '-changesetViewer',
|
||||||
title: 'ChangesetViewer ' + this.item.name,
|
title: 'ChangesetViewer ' + this.item.name,
|
||||||
repository: this.item,
|
repository: this.item,
|
||||||
xtype: 'repositoryChangesetViewerPanel',
|
xtype: 'repositoryChangesetViewerPanel',
|
||||||
closable: true,
|
closable: true,
|
||||||
autoScroll: true
|
autoScroll: true
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
openChangesetViewer: function(changesetViewer){
|
||||||
|
if ( changesetViewer == null ){
|
||||||
|
changesetViewer = this.createChangesetViewer();
|
||||||
}
|
}
|
||||||
main.addTab(changesetViewer);
|
main.addTab(changesetViewer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
|||||||
|
|
||||||
mainTabPanel: null,
|
mainTabPanel: null,
|
||||||
|
|
||||||
|
infoPanels: [],
|
||||||
|
|
||||||
constructor : function(config) {
|
constructor : function(config) {
|
||||||
this.addEvents('login', 'logout', 'init');
|
this.addEvents('login', 'logout', 'init');
|
||||||
this.mainTabPanel = Ext.getCmp('mainTabPanel');
|
this.mainTabPanel = Ext.getCmp('mainTabPanel');
|
||||||
@@ -69,7 +71,24 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
init: function(){
|
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(){
|
postLogin: function(){
|
||||||
|
|||||||
@@ -138,6 +138,18 @@
|
|||||||
|
|
||||||
Ext.ns('Sonia.util');
|
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
|
// link
|
||||||
|
|
||||||
Sonia.util.Link = Ext.extend(Ext.BoxComponent, {
|
Sonia.util.Link = Ext.extend(Ext.BoxComponent, {
|
||||||
|
|||||||
Reference in New Issue
Block a user