mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-02-05 22:29:11 +01:00
handle history events for content panel
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
// 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);
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user