mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-12-22 00:09:47 +01:00
Add new default branch option with 'main' as default
This commit is contained in:
committed by
René Pfeuffer
parent
b48bf24834
commit
196ea227d2
@@ -24,12 +24,13 @@
|
||||
import React from "react";
|
||||
import { WithTranslation, withTranslation } from "react-i18next";
|
||||
import { Links } from "@scm-manager/ui-types";
|
||||
import { InputField, Checkbox } from "@scm-manager/ui-components";
|
||||
import { InputField, Checkbox, validation as validator } from "@scm-manager/ui-components";
|
||||
|
||||
type Configuration = {
|
||||
repositoryDirectory?: string;
|
||||
gcExpression?: string;
|
||||
nonFastForwardDisallowed: boolean;
|
||||
defaultBranch: string;
|
||||
_links: Links;
|
||||
};
|
||||
|
||||
@@ -68,8 +69,21 @@ class GitConfigurationForm extends React.Component<Props, State> {
|
||||
);
|
||||
};
|
||||
|
||||
onDefaultBranchChange = (value: string) => {
|
||||
this.setState(
|
||||
{
|
||||
defaultBranch: value
|
||||
},
|
||||
() => this.props.onConfigurationChange(this.state, this.isValidDefaultBranch())
|
||||
);
|
||||
};
|
||||
|
||||
isValidDefaultBranch = () => {
|
||||
return validator.isNameValid(this.state.defaultBranch);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { gcExpression, nonFastForwardDisallowed } = this.state;
|
||||
const { gcExpression, nonFastForwardDisallowed, defaultBranch } = this.state;
|
||||
const { readOnly, t } = this.props;
|
||||
|
||||
return (
|
||||
@@ -90,6 +104,15 @@ class GitConfigurationForm extends React.Component<Props, State> {
|
||||
onChange={this.onNonFastForwardDisallowed}
|
||||
disabled={readOnly}
|
||||
/>
|
||||
<InputField
|
||||
name="defaultBranch"
|
||||
label={t("scm-git-plugin.config.defaultBranch")}
|
||||
value={defaultBranch}
|
||||
onChange={this.onDefaultBranchChange}
|
||||
disabled={readOnly}
|
||||
validationError={!this.isValidDefaultBranch()}
|
||||
errorMessage={t("scm-git-plugin.config.defaultBranchValidationError")}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user