diff --git a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.changesetviewerpanel.js b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.changesetviewerpanel.js index 1b221a0e0a..8469c89451 100644 --- a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.changesetviewerpanel.js +++ b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.changesetviewerpanel.js @@ -110,7 +110,7 @@ Sonia.repository.ChangesetViewerPanel = Ext.extend(Ext.Panel, { }, updateHistory: function(store, records, options){ - if ( options && options.params ){ + if ( ! this.inline && options && options.params ){ this.start = options.params.start; this.pageSize = options.params.limit; var token = Sonia.History.createToken( diff --git a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.contentpanel.js b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.contentpanel.js index 9ff464c24c..50bbcd8473 100644 --- a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.contentpanel.js +++ b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.contentpanel.js @@ -35,6 +35,9 @@ Sonia.repository.ContentPanel = Ext.extend(Ext.Panel, { path: null, contentUrl: null, + // view content/blame/history + view: 'content', + initComponent: function(){ var name = Sonia.util.getName(this.path); this.contentUrl = Sonia.repository.createContentUrl( @@ -44,6 +47,19 @@ Sonia.repository.ContentPanel = Ext.extend(Ext.Panel, { var bottomBar = [this.path]; this.appendRepositoryProperties(bottomBar); + var panel = null; + + switch (this.view){ + case 'blame': + panel = this.createBlamePanel(); + break; + case 'history': + panel = this.createHistoryPanel(); + break; + default: + panel = this.createSyntaxPanel(); + } + var config = { title: name, tbar: [{ @@ -64,19 +80,29 @@ Sonia.repository.ContentPanel = Ext.extend(Ext.Panel, { scope: this }], bbar: bottomBar, - items: [{ - xtype: 'syntaxHighlighterPanel', - syntax: Sonia.util.getExtension(this.path), - contentUrl: this.contentUrl - }] + items: [panel] } Ext.apply(this, Ext.apply(this.initialConfig, config)); Sonia.repository.ContentPanel.superclass.initComponent.apply(this, arguments); }, - openHistoryPanel: function(){ - this.openPanel({ + loadPanel: function(view){ + switch (view){ + case 'blame': + this.openBlamePanel(); + break; + case 'history': + this.openHistoryPanel(); + break; + default: + this.openSyntaxPanel(); + } + + }, + + createHistoryPanel: function(){ + return { xtype: 'repositoryChangesetViewerPanel', repository: this.repository, revision: this.revision, @@ -84,24 +110,53 @@ Sonia.repository.ContentPanel = Ext.extend(Ext.Panel, { inline: true, // TODO find a better way pageSize: 9999 - }); + } }, - openSyntaxPanel: function(){ - this.openPanel({ + openHistoryPanel: function(){ + this.openPanel(this.createHistoryPanel()); + this.view = 'history'; + this.updateHistory(); + }, + + createSyntaxPanel: function(){ + return { xtype: 'syntaxHighlighterPanel', syntax: Sonia.util.getExtension(this.path), contentUrl: this.contentUrl - }); + } }, - openBlamePanel: function(){ - this.openPanel({ + openSyntaxPanel: function(){ + this.openPanel(this.createSyntaxPanel()); + this.view = 'content'; + this.updateHistory(); + }, + + createBlamePanel: function(){ + return { xtype: 'blamePanel', repository: this.repository, revision: this.revision, path: this.path - }); + } + }, + + openBlamePanel: function(){ + this.openPanel(this.createBlamePanel()); + this.view = 'blame'; + this.updateHistory(); + }, + + updateHistory: function(){ + var token = Sonia.History.createToken( + 'contentPanel', + this.repository.id, + this.revision, + this.path, + this.view + ); + Sonia.History.add(token); }, downlaodFile: function(){ @@ -132,5 +187,47 @@ Sonia.repository.ContentPanel = Ext.extend(Ext.Panel, { }); +// register xtype +Ext.reg('contentPanel', Sonia.repository.ContentPanel); -Ext.reg('contentPanel', Sonia.repository.ContentPanel); \ No newline at end of file +// register history handler +Sonia.History.register('contentPanel', { + + onActivate: function(panel){ + return Sonia.History.createToken( + 'contentPanel', + panel.repository.id, + panel.revision, + panel.path, + panel.view + ); + }, + + onChange: function(repoId, revision, path, view){ + if (revision == 'null'){ + revision = null; + } + if (!view || view == 'null'){ + view = 'content'; + } + var id = 'contentPanel|' + repoId + '|' + revision + '|' + path; + Sonia.repository.get(repoId, function(repository){ + var panel = Ext.getCmp(id); + if (! panel){ + panel = { + id: id, + xtype: 'contentPanel', + repository : repository, + revision: revision, + path: path, + view: view, + closable: true, + autoScroll: true + } + } else { + panel.loadPanel(view); + } + main.addTab(panel); + }); + } +}); \ No newline at end of file