diff --git a/scm-webapp/src/main/webapp/resources/js/sonia.repository.js b/scm-webapp/src/main/webapp/resources/js/sonia.repository.js
index dd1074d7ac..aab73030c2 100644
--- a/scm-webapp/src/main/webapp/resources/js/sonia.repository.js
+++ b/scm-webapp/src/main/webapp/resources/js/sonia.repository.js
@@ -351,6 +351,24 @@ Sonia.repository.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
name: 'public',
xtype: 'checkbox',
helpText: this.publicHelpText
+ },
+ // TODO remove
+ {
+ fieldLabel: 'ChangesetViewer',
+ text: 'ChangesetViewer',
+ xtype: 'button',
+ scope: this,
+ handler: function(){
+ var changesetViewer = {
+ id: 'changesetViewer',
+ title: this.item.name,
+ repository: this.item,
+ xtype: 'repositoryChangesetViewerPanel',
+ closable: true,
+ autoScroll: true
+ }
+ main.addTab(changesetViewer);
+ }
}
]
},{
@@ -658,3 +676,83 @@ Sonia.repository.Panel = Ext.extend(Ext.Panel, {
// register xtype
Ext.reg('repositoryPanel', Sonia.repository.Panel);
+
+
+// changeset viewer
+
+Sonia.repository.ChangesetViewerGrid = Ext.extend(Ext.grid.GridPanel, {
+
+ repository: null,
+ /**
+ * 0 - id
+ * 1 - date
+ * 2 - author
+ * 3 - description
+ */
+ changesetTemplate: '
{0}: {3}
{2}
{1}
',
+
+ initComponent: function(){
+
+ var changesetStore = new Ext.data.JsonStore({
+ id: 'changesetStore',
+ url: restUrl + 'repositories/' + this.repository.id + '/changesets.json',
+ fields: ['id', 'date', 'author', 'description'],
+ idProperty: 'id',
+ autoLoad: true,
+ autoDestroy: true
+ });
+
+ var changesetColModel = new Ext.grid.ColumnModel({
+ defaults: {
+ sortable: false
+ },
+ columns: [
+ {id: 'changeset', dataIndex: 'id', header: 'Changeset', renderer: this.renderChangeset, scope: this},
+ {id: 'date', dataIndex: 'date', header: 'Date', hidden: true},
+ {id: 'author', dataIndex: 'author', header: 'Author', hidden: true},
+ {id: 'description', dataIndex: 'description', header: 'Description', hidden: true}
+ ]
+ });
+
+ var config = {
+ autoExpandColumn: 'changeset',
+ autoHeight: true,
+ store: changesetStore,
+ colModel: changesetColModel
+ }
+
+ Ext.apply(this, Ext.apply(this.initialConfig, config));
+ Sonia.repository.ChangesetViewerGrid.superclass.initComponent.apply(this, arguments);
+ },
+
+ renderChangeset: function(value, p, record){
+ var data = record.data;
+ return String.format(this.changesetTemplate, data.id, data.date, data.author, data.description);
+ }
+
+});
+
+// register xtype
+Ext.reg('repositoryChangesetViewerGrid', Sonia.repository.ChangesetViewerGrid);
+
+Sonia.repository.ChangesetViewerPanel = Ext.extend(Ext.Panel, {
+
+ repository: null,
+
+ initComponent: function(){
+
+ var config = {
+ items: [{
+ xtype: 'repositoryChangesetViewerGrid',
+ repository: this.repository
+ }]
+ };
+
+ Ext.apply(this, Ext.apply(this.initialConfig, config));
+ Sonia.repository.ChangesetViewerPanel.superclass.initComponent.apply(this, arguments);
+ }
+
+});
+
+// register xtype
+Ext.reg('repositoryChangesetViewerPanel', Sonia.repository.ChangesetViewerPanel);
\ No newline at end of file
diff --git a/scm-webapp/src/main/webapp/resources/js/sonia.scm.js b/scm-webapp/src/main/webapp/resources/js/sonia.scm.js
index 8674d49907..6b1ba1ed5f 100644
--- a/scm-webapp/src/main/webapp/resources/js/sonia.scm.js
+++ b/scm-webapp/src/main/webapp/resources/js/sonia.scm.js
@@ -198,17 +198,22 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
},
addTabPanel: function(id, xtype, title){
- var tab = this.mainTabPanel.findById( id );
+ var panel = {
+ id: id,
+ xtype: xtype,
+ title: title,
+ closable: true,
+ autoScroll: true
+ };
+ this.addTab(panel);
+ },
+
+ addTab: function(panel){
+ var tab = this.mainTabPanel.findById(panel.id);
if ( tab == null ){
- this.mainTabPanel.add({
- id: id,
- xtype: xtype,
- title: title,
- closable: true,
- autoScroll: true
- });
+ this.mainTabPanel.add(panel);
}
- this.mainTabPanel.setActiveTab(id);
+ this.mainTabPanel.setActiveTab(panel.id);
},
loadState: function(s){