mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 17:26:22 +01:00
#873 added default branch chooser to git settings
This commit is contained in:
@@ -90,6 +90,93 @@ Sonia.git.ConfigPanel = Ext.extend(Sonia.config.SimpleConfigForm, {
|
|||||||
|
|
||||||
Ext.reg("gitConfigPanel", Sonia.git.ConfigPanel);
|
Ext.reg("gitConfigPanel", Sonia.git.ConfigPanel);
|
||||||
|
|
||||||
|
// add default branch chooser to settings panel
|
||||||
|
Sonia.git.GitSettingsFormPanel = Ext.extend(Sonia.repository.SettingsFormPanel, {
|
||||||
|
|
||||||
|
defaultBranchText: 'Default Branch',
|
||||||
|
defaultBranchHelpText: 'The default branch which is show first on source or commit view.',
|
||||||
|
|
||||||
|
modifyDefaultConfig: function(config){
|
||||||
|
if (this.item) {
|
||||||
|
var position = -1;
|
||||||
|
for ( var i=0; i<config.items.length; i++ ) {
|
||||||
|
var field = config.items[i];
|
||||||
|
if (field.name === 'public') {
|
||||||
|
position = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var defaultBranchComboxBox = {
|
||||||
|
fieldLabel: this.defaultBranchText,
|
||||||
|
name: 'defaultBranch',
|
||||||
|
repositoryId: this.item.id,
|
||||||
|
value: this.getDefaultBranch(this.item),
|
||||||
|
useNameAsValue: true,
|
||||||
|
xtype: 'repositoryBranchComboBox',
|
||||||
|
helpText: this.defaultBranchHelpText
|
||||||
|
};
|
||||||
|
|
||||||
|
if (position >= 0) {
|
||||||
|
config.items.splice(position, 0, defaultBranchComboxBox);
|
||||||
|
} else {
|
||||||
|
config.items.push(defaultBranchComboxBox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getDefaultBranch: function(item){
|
||||||
|
if (item.properties) {
|
||||||
|
for ( var i=0; i<item.properties.length; i++ ) {
|
||||||
|
var prop = item.properties[i];
|
||||||
|
if (prop.key === 'git.default-branch') {
|
||||||
|
return prop.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
},
|
||||||
|
|
||||||
|
setDefaultBranch: function(item, defaultBranch){
|
||||||
|
if (!item.properties) {
|
||||||
|
item.properties = [{
|
||||||
|
key: 'git.default-branch',
|
||||||
|
value: defaultBranch
|
||||||
|
}];
|
||||||
|
} else {
|
||||||
|
|
||||||
|
var found = false;
|
||||||
|
for ( var i=0; i<item.properties.length; i++ ) {
|
||||||
|
var prop = item.properties[i];
|
||||||
|
if (prop.key === 'git.default-branch') {
|
||||||
|
prop.value = defaultBranch;
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
item.properties.push({
|
||||||
|
key: 'git.default-branch',
|
||||||
|
value: defaultBranch
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
prepareUpdate: function(item) {
|
||||||
|
if (item.defaultBranch) {
|
||||||
|
var defaultBranch = item.defaultBranch;
|
||||||
|
delete item.defaultBranch;
|
||||||
|
this.setDefaultBranch(item, defaultBranch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
Ext.reg("gitSettingsForm", Sonia.git.GitSettingsFormPanel);
|
||||||
|
|
||||||
|
|
||||||
// i18n
|
// i18n
|
||||||
|
|
||||||
if ( i18n && i18n.country === 'de' ){
|
if ( i18n && i18n.country === 'de' ){
|
||||||
@@ -108,8 +195,20 @@ if ( i18n && i18n.country === 'de' ){
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Ext.override(Sonia.git.GitSettingsFormPanel, {
|
||||||
|
|
||||||
|
// labels
|
||||||
|
defaultBranchText: 'Standard Branch',
|
||||||
|
|
||||||
|
// helpTexts
|
||||||
|
defaultBranchHelpText: 'Der Standard Branch wird für die Source und Commit Ansicht verwendet, \n\
|
||||||
|
wenn kein anderer Branch eingestellt wurde.'
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// register information panel
|
// register information panel
|
||||||
|
|
||||||
initCallbacks.push(function(main){
|
initCallbacks.push(function(main){
|
||||||
@@ -117,6 +216,9 @@ initCallbacks.push(function(main){
|
|||||||
checkoutTemplate: 'git clone <a href="{0}" target="_blank">{0}</a>',
|
checkoutTemplate: 'git clone <a href="{0}" target="_blank">{0}</a>',
|
||||||
xtype: 'repositoryExtendedInfoPanel'
|
xtype: 'repositoryExtendedInfoPanel'
|
||||||
});
|
});
|
||||||
|
main.registerSettingsForm('git', {
|
||||||
|
xtype: 'gitSettingsForm'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// register panel
|
// register panel
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
Sonia.repository.BranchComboBox = Ext.extend(Ext.form.ComboBox, {
|
Sonia.repository.BranchComboBox = Ext.extend(Ext.form.ComboBox, {
|
||||||
|
|
||||||
repositoryId: null,
|
repositoryId: null,
|
||||||
|
useNameAsValue: false,
|
||||||
|
|
||||||
initComponent: function(){
|
initComponent: function(){
|
||||||
var branchStore = new Sonia.rest.JsonStore({
|
var branchStore = new Sonia.rest.JsonStore({
|
||||||
@@ -47,8 +48,8 @@ Sonia.repository.BranchComboBox = Ext.extend(Ext.form.ComboBox, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
valueField: 'revision',
|
|
||||||
displayField: 'name',
|
displayField: 'name',
|
||||||
|
valueField: this.useNameAsValue ? 'name' : 'revision',
|
||||||
typeAhead: false,
|
typeAhead: false,
|
||||||
editable: false,
|
editable: false,
|
||||||
triggerAction: 'all',
|
triggerAction: 'all',
|
||||||
|
|||||||
@@ -61,8 +61,15 @@ Sonia.repository.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
|||||||
Sonia.repository.FormPanel.superclass.initComponent.apply(this, arguments);
|
Sonia.repository.FormPanel.superclass.initComponent.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
prepareUpdate: function(item) {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
update: function(item){
|
update: function(item){
|
||||||
item = Ext.apply( this.item, item );
|
item = Ext.apply( this.item, item );
|
||||||
|
// allow plugins to modify item
|
||||||
|
this.prepareUpdate(item);
|
||||||
|
|
||||||
if ( debug ){
|
if ( debug ){
|
||||||
console.debug( 'update repository: ' + item.name );
|
console.debug( 'update repository: ' + item.name );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -432,21 +432,22 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
|
|||||||
var infoPanel = main.getInfoPanel(item.type);
|
var infoPanel = main.getInfoPanel(item.type);
|
||||||
infoPanel.item = item;
|
infoPanel.item = item;
|
||||||
|
|
||||||
|
var settingsForm = main.getSettingsForm(item.type);
|
||||||
|
settingsForm.item = item;
|
||||||
|
settingsForm.onUpdate = {
|
||||||
|
fn: this.reload,
|
||||||
|
scope: this
|
||||||
|
};
|
||||||
|
settingsForm.onCreate = {
|
||||||
|
fn: this.reload,
|
||||||
|
scope: this
|
||||||
|
};
|
||||||
|
|
||||||
var panels = [infoPanel];
|
var panels = [infoPanel];
|
||||||
|
|
||||||
if ( owner ){
|
if ( owner ){
|
||||||
panels.push({
|
panels.push(
|
||||||
item: item,
|
settingsForm, {
|
||||||
xtype: 'repositorySettingsForm',
|
|
||||||
onUpdate: {
|
|
||||||
fn: this.reload,
|
|
||||||
scope: this
|
|
||||||
},
|
|
||||||
onCreate: {
|
|
||||||
fn: this.reload,
|
|
||||||
scope: this
|
|
||||||
}
|
|
||||||
},{
|
|
||||||
item: item,
|
item: item,
|
||||||
xtype: 'repositoryPermissionsForm',
|
xtype: 'repositoryPermissionsForm',
|
||||||
listeners: {
|
listeners: {
|
||||||
|
|||||||
@@ -79,8 +79,14 @@ Sonia.repository.SettingsFormPanel = Ext.extend(Sonia.repository.FormPanel, {
|
|||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.modifyDefaultConfig(config);
|
||||||
|
|
||||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||||
Sonia.repository.SettingsFormPanel.superclass.initComponent.apply(this, arguments);
|
Sonia.repository.SettingsFormPanel.superclass.initComponent.apply(this, arguments);
|
||||||
|
},
|
||||||
|
|
||||||
|
modifyDefaultConfig: function(config){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
|||||||
mainTabPanel: null,
|
mainTabPanel: null,
|
||||||
|
|
||||||
infoPanels: [],
|
infoPanels: [],
|
||||||
|
settingsForm: [],
|
||||||
scripts: [],
|
scripts: [],
|
||||||
stylesheets: [],
|
stylesheets: [],
|
||||||
|
|
||||||
@@ -96,6 +97,23 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
|||||||
this.infoPanels[type] = panel;
|
this.infoPanels[type] = panel;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
registerSettingsForm: function(type, form){
|
||||||
|
this.settingsForm[type] = form;
|
||||||
|
},
|
||||||
|
|
||||||
|
getSettingsForm: function(type){
|
||||||
|
var rp = null;
|
||||||
|
var panel = this.settingsForm[type];
|
||||||
|
if ( ! panel ){
|
||||||
|
rp = {
|
||||||
|
xtype: 'repositorySettingsForm'
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
rp = Sonia.util.clone( panel );
|
||||||
|
}
|
||||||
|
return rp;
|
||||||
|
},
|
||||||
|
|
||||||
getInfoPanel: function(type){
|
getInfoPanel: function(type){
|
||||||
var rp = null;
|
var rp = null;
|
||||||
var panel = this.infoPanels[type];
|
var panel = this.infoPanels[type];
|
||||||
|
|||||||
Reference in New Issue
Block a user