prepare for blame support

This commit is contained in:
Sebastian Sdorra
2011-09-16 15:40:31 +02:00
parent 9514f0397e
commit 52480b72f1
3 changed files with 106 additions and 3 deletions

View File

@@ -109,6 +109,7 @@
<script type="text/javascript" src="resources/js/repository/sonia.repository.propertiesformpanel.js"></script>
<script type="text/javascript" src="resources/js/repository/sonia.repository.changesetviewergrid.js"></script>
<script type="text/javascript" src="resources/js/repository/sonia.repository.changesetviewerpanel.js"></script>
<script type="text/javascript" src="resources/js/repository/sonia.repository.blamepanel.js"></script>
<script type="text/javascript" src="resources/js/repository/sonia.repository.contentpanel.js"></script>
<script type="text/javascript" src="resources/js/repository/sonia.repository.repositorybrowser.js"></script>

View File

@@ -0,0 +1,85 @@
/* *
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
Sonia.repository.BlamePanel = Ext.extend(Ext.grid.GridPanel, {
blameUrl: null,
initComponent: function(){
var blameStore = new Sonia.rest.JsonStore({
proxy: new Ext.data.HttpProxy({
url: this.blameUrl,
disableCaching: false
}),
root: 'blamelines',
idProperty: 'lineNumber',
fields: [ 'lineNumber', 'author', 'revision', 'when', 'code'],
sortInfo: {
field: 'lineNumber'
}
});
var blameColModel = new Ext.grid.ColumnModel({
columns: [{
id: 'lineNumber',
dataIndex: 'lineNumber',
width: 20
},{
id: 'code',
dataIndex: 'code',
renderer: this.renderCode,
width: 400
}]
});
var config = {
hideHeaders: true,
autoExpandColumn: 'code',
store: blameStore,
colModel: blameColModel,
autoHeight: true,
viewConfig: {
forceFit: true
}
}
Ext.apply(this, Ext.apply(this.initialConfig, config));
Sonia.repository.BlamePanel.superclass.initComponent.apply(this, arguments);
},
renderCode: function(value){
return '<pre>' + Ext.util.Format.htmlEncode(value) + '</pre>';
}
});
Ext.reg('blamePanel', Sonia.repository.BlamePanel);

View File

@@ -35,13 +35,19 @@ Sonia.repository.ContentPanel = Ext.extend(Ext.Panel, {
revision: null,
path: null,
contentUrl: null,
blameUrl: null,
initComponent: function(){
var name = this.getName(this.path);
this.contentUrl = restUrl + 'repositories/' + this.repository.id + '/content?path=' + this.path;
var repositoryUrl = restUrl + 'repositories/' + this.repository.id + '/';
this.contentUrl = repositoryUrl + 'content?path=' + this.path;
this.blameUrl = repositoryUrl + 'blame.json?path=' + this.path;
if ( this.revision ){
this.contentUrl += "&revision=" + this.revision;
this.blameUrl += "&revision=" + this.revision;
}
var bottomBar = [this.path];
@@ -55,8 +61,10 @@ Sonia.repository.ContentPanel = Ext.extend(Ext.Panel, {
text: 'Raw',
handler: this.downlaodFile,
scope: this
//},{
// text: 'Blame'
},{
text: 'Blame',
handler: this.openBlamePanel,
scope: this
}],
bbar: bottomBar,
items: [{
@@ -70,6 +78,15 @@ Sonia.repository.ContentPanel = Ext.extend(Ext.Panel, {
Sonia.repository.ContentPanel.superclass.initComponent.apply(this, arguments);
},
openBlamePanel: function(){
this.removeAll();
this.add({
xtype: 'blamePanel',
blameUrl: this.blameUrl
});
this.doLayout();
},
downlaodFile: function(){
window.open(this.contentUrl);
},