added gitbranchinformation binding

This commit is contained in:
Florian Scholdei
2019-04-01 09:52:39 +02:00
parent 442e4c4889
commit bb5e3c9c58
7 changed files with 74 additions and 33 deletions

View File

@@ -8,11 +8,10 @@ type Props = {
repository: Repository, repository: Repository,
// context props // context props
t: (string) => string t: string => string
}; };
class CloneInformation extends React.Component<Props> { class CloneInformation extends React.Component<Props> {
render() { render() {
const { url, repository, t } = this.props; const { url, repository, t } = this.props;
@@ -51,7 +50,6 @@ class CloneInformation extends React.Component<Props> {
</div> </div>
); );
} }
} }
export default translate("plugins")(CloneInformation); export default translate("plugins")(CloneInformation);

View File

@@ -0,0 +1,33 @@
//@flow
import React from "react";
import type { Repository } from "@scm-manager/ui-types";
import { translate } from "react-i18next";
type Props = {
repository: Repository,
t: string => string
};
class GitBranchInformation extends React.Component<Props> {
render() {
const { repository, t } = this.props;
return (
<div>
<h4>{t("scm-git-plugin.information.fetch")}</h4>
<pre>
<code>git fetch</code>
</pre>
<h4>{t("scm-git-plugin.information.checkout")}</h4>
<pre>
<code>
git checkout -placeholder-
<br />
</code>
</pre>
</div>
); // TODO: Placeholder
}
}
export default translate("plugins")(GitBranchInformation);

View File

@@ -10,7 +10,7 @@ type Configuration = {
gcExpression?: string, gcExpression?: string,
nonFastForwardDisallowed: boolean, nonFastForwardDisallowed: boolean,
_links: Links _links: Links
} };
type Props = { type Props = {
initialConfiguration: Configuration, initialConfiguration: Configuration,
@@ -19,25 +19,24 @@ type Props = {
onConfigurationChange: (Configuration, boolean) => void, onConfigurationChange: (Configuration, boolean) => void,
// context props // context props
t: (string) => string t: string => string
} };
type State = Configuration & { type State = Configuration & {};
}
class GitConfigurationForm extends React.Component<Props, State> { class GitConfigurationForm extends React.Component<Props, State> {
constructor(props: Props) { constructor(props: Props) {
super(props); super(props);
this.state = { ...props.initialConfiguration }; this.state = { ...props.initialConfiguration };
} }
handleChange = (value: any, name: string) => { handleChange = (value: any, name: string) => {
this.setState({ this.setState(
[name]: value {
}, () => this.props.onConfigurationChange(this.state, true)); [name]: value
},
() => this.props.onConfigurationChange(this.state, true)
);
}; };
render() { render() {
@@ -46,24 +45,25 @@ class GitConfigurationForm extends React.Component<Props, State> {
return ( return (
<> <>
<InputField name="gcExpression" <InputField
label={t("scm-git-plugin.config.gcExpression")} name="gcExpression"
helpText={t("scm-git-plugin.config.gcExpressionHelpText")} label={t("scm-git-plugin.config.gcExpression")}
value={gcExpression} helpText={t("scm-git-plugin.config.gcExpressionHelpText")}
onChange={this.handleChange} value={gcExpression}
disabled={readOnly} onChange={this.handleChange}
disabled={readOnly}
/> />
<Checkbox name="nonFastForwardDisallowed" <Checkbox
label={t("scm-git-plugin.config.nonFastForwardDisallowed")} name="nonFastForwardDisallowed"
helpText={t("scm-git-plugin.config.nonFastForwardDisallowedHelpText")} label={t("scm-git-plugin.config.nonFastForwardDisallowed")}
checked={nonFastForwardDisallowed} helpText={t("scm-git-plugin.config.nonFastForwardDisallowedHelpText")}
onChange={this.handleChange} checked={nonFastForwardDisallowed}
disabled={readOnly} onChange={this.handleChange}
disabled={readOnly}
/> />
</> </>
); );
} }
} }
export default translate("plugins")(GitConfigurationForm); export default translate("plugins")(GitConfigurationForm);

View File

@@ -6,6 +6,7 @@ import GitAvatar from "./GitAvatar";
import {ConfigurationBinder as cfgBinder} from "@scm-manager/ui-components"; import {ConfigurationBinder as cfgBinder} from "@scm-manager/ui-components";
import GitGlobalConfiguration from "./GitGlobalConfiguration"; import GitGlobalConfiguration from "./GitGlobalConfiguration";
import GitBranchInformation from "./GitBranchInformation";
import GitMergeInformation from "./GitMergeInformation"; import GitMergeInformation from "./GitMergeInformation";
import RepositoryConfig from "./RepositoryConfig"; import RepositoryConfig from "./RepositoryConfig";
@@ -20,6 +21,11 @@ binder.bind(
ProtocolInformation, ProtocolInformation,
gitPredicate gitPredicate
); );
binder.bind(
"repos.branch-details.information",
GitBranchInformation,
gitPredicate
);
binder.bind( binder.bind(
"repos.repository-merge.information", "repos.repository-merge.information",
GitMergeInformation, GitMergeInformation,

View File

@@ -1,9 +1,11 @@
{ {
"scm-git-plugin": { "scm-git-plugin": {
"information": { "information": {
"clone" : "Repository klonen", "clone": "Repository klonen",
"create" : "Neues Repository erstellen", "create": "Neues Repository erstellen",
"replace" : "Ein bestehendes Repository aktualisieren", "replace": "Ein bestehendes Repository aktualisieren",
"fetch": "Remote-Änderungen herunterladen",
"checkout": "Branch wechseln",
"merge": { "merge": {
"heading": "Merge des Source Branch in den Target Branch", "heading": "Merge des Source Branch in den Target Branch",
"checkout": "1. Sicherstellen, dass der Workspace aufgeräumt ist und der Target Branch ausgecheckt wurde.", "checkout": "1. Sicherstellen, dass der Workspace aufgeräumt ist und der Target Branch ausgecheckt wurde.",
@@ -37,7 +39,7 @@
"success": "Der standard Branch wurde geändert!" "success": "Der standard Branch wurde geändert!"
} }
}, },
"permissions" : { "permissions": {
"configuration": { "configuration": {
"read,write": { "read,write": {
"git": { "git": {

View File

@@ -4,6 +4,8 @@
"clone": "Clone the repository", "clone": "Clone the repository",
"create": "Create a new repository", "create": "Create a new repository",
"replace": "Push an existing repository", "replace": "Push an existing repository",
"fetch": "Get remote changes",
"checkout": "Switch branch",
"merge": { "merge": {
"heading": "How to merge source branch into target branch", "heading": "How to merge source branch into target branch",
"checkout": "1. Make sure your workspace is clean and checkout target branch", "checkout": "1. Make sure your workspace is clean and checkout target branch",

View File

@@ -82,8 +82,8 @@ const mapStateToProps = (state, ownProps) => {
const mapDispatchToProps = dispatch => { const mapDispatchToProps = dispatch => {
return { return {
fetchBranchByName: (repository: string, branchName: string) => { fetchBranchByName: (repository: Repository, branchName: string) => {
dispatch(fetchBranchByName(repository, branchName)); dispatch(fetchBranchByName(repository._links.branches.href, branchName));
} }
}; };
}; };