mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 09:25:43 +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);
|
||||
|
||||
// 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
|
||||
|
||||
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
|
||||
|
||||
initCallbacks.push(function(main){
|
||||
@@ -117,6 +216,9 @@ initCallbacks.push(function(main){
|
||||
checkoutTemplate: 'git clone <a href="{0}" target="_blank">{0}</a>',
|
||||
xtype: 'repositoryExtendedInfoPanel'
|
||||
});
|
||||
main.registerSettingsForm('git', {
|
||||
xtype: 'gitSettingsForm'
|
||||
});
|
||||
});
|
||||
|
||||
// register panel
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
Sonia.repository.BranchComboBox = Ext.extend(Ext.form.ComboBox, {
|
||||
|
||||
repositoryId: null,
|
||||
useNameAsValue: false,
|
||||
|
||||
initComponent: function(){
|
||||
var branchStore = new Sonia.rest.JsonStore({
|
||||
@@ -47,8 +48,8 @@ Sonia.repository.BranchComboBox = Ext.extend(Ext.form.ComboBox, {
|
||||
});
|
||||
|
||||
var config = {
|
||||
valueField: 'revision',
|
||||
displayField: 'name',
|
||||
valueField: this.useNameAsValue ? 'name' : 'revision',
|
||||
typeAhead: false,
|
||||
editable: false,
|
||||
triggerAction: 'all',
|
||||
|
||||
@@ -61,8 +61,15 @@ Sonia.repository.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
||||
Sonia.repository.FormPanel.superclass.initComponent.apply(this, arguments);
|
||||
},
|
||||
|
||||
prepareUpdate: function(item) {
|
||||
|
||||
},
|
||||
|
||||
update: function(item){
|
||||
item = Ext.apply( this.item, item );
|
||||
// allow plugins to modify item
|
||||
this.prepareUpdate(item);
|
||||
|
||||
if ( debug ){
|
||||
console.debug( 'update repository: ' + item.name );
|
||||
}
|
||||
|
||||
@@ -432,21 +432,22 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
|
||||
var infoPanel = main.getInfoPanel(item.type);
|
||||
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];
|
||||
|
||||
if ( owner ){
|
||||
panels.push({
|
||||
item: item,
|
||||
xtype: 'repositorySettingsForm',
|
||||
onUpdate: {
|
||||
fn: this.reload,
|
||||
scope: this
|
||||
},
|
||||
onCreate: {
|
||||
fn: this.reload,
|
||||
scope: this
|
||||
}
|
||||
},{
|
||||
panels.push(
|
||||
settingsForm, {
|
||||
item: item,
|
||||
xtype: 'repositoryPermissionsForm',
|
||||
listeners: {
|
||||
|
||||
@@ -79,8 +79,14 @@ Sonia.repository.SettingsFormPanel = Ext.extend(Sonia.repository.FormPanel, {
|
||||
}]
|
||||
};
|
||||
|
||||
this.modifyDefaultConfig(config);
|
||||
|
||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||
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,
|
||||
|
||||
infoPanels: [],
|
||||
settingsForm: [],
|
||||
scripts: [],
|
||||
stylesheets: [],
|
||||
|
||||
@@ -96,6 +97,23 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
||||
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){
|
||||
var rp = null;
|
||||
var panel = this.infoPanels[type];
|
||||
|
||||
Reference in New Issue
Block a user