mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
merge 2.0.0-m3
This commit is contained in:
@@ -1,16 +1,12 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import {Image} from "@scm-manager/ui-components";
|
||||
import { Image } from "@scm-manager/ui-components";
|
||||
|
||||
type Props = {
|
||||
};
|
||||
type Props = {};
|
||||
|
||||
class HgAvatar extends React.Component<Props> {
|
||||
|
||||
render() {
|
||||
return <Image src="/images/hg-logo.png" alt="Mercurial Logo" />;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default HgAvatar;
|
||||
@@ -1,11 +1,9 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import type { Branch } from "@scm-manager/ui-types";
|
||||
import { translate } from "react-i18next";
|
||||
import { WithTranslation, withTranslation } from "react-i18next";
|
||||
import { Branch } from "@scm-manager/ui-types";
|
||||
|
||||
type Props = {
|
||||
branch: Branch,
|
||||
t: string => string
|
||||
type Props = WithTranslation & {
|
||||
branch: Branch;
|
||||
};
|
||||
|
||||
class HgBranchInformation extends React.Component<Props> {
|
||||
@@ -27,4 +25,4 @@ class HgBranchInformation extends React.Component<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
export default translate("plugins")(HgBranchInformation);
|
||||
export default withTranslation("plugins")(HgBranchInformation);
|
||||
@@ -1,46 +1,46 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import type { Links } from "@scm-manager/ui-types";
|
||||
import { translate } from "react-i18next";
|
||||
import { WithTranslation, withTranslation } from "react-i18next";
|
||||
import { Links } from "@scm-manager/ui-types";
|
||||
import { InputField, Checkbox } from "@scm-manager/ui-components";
|
||||
|
||||
type Configuration = {
|
||||
hgBinary: string,
|
||||
pythonBinary: string,
|
||||
pythonPath?: string,
|
||||
encoding: string,
|
||||
useOptimizedBytecode: boolean,
|
||||
showRevisionInId: boolean,
|
||||
disableHookSSLValidation: boolean,
|
||||
enableHttpPostArgs: boolean,
|
||||
_links: Links
|
||||
hgBinary: string;
|
||||
pythonBinary: string;
|
||||
pythonPath?: string;
|
||||
encoding: string;
|
||||
useOptimizedBytecode: boolean;
|
||||
showRevisionInId: boolean;
|
||||
disableHookSSLValidation: boolean;
|
||||
enableHttpPostArgs: boolean;
|
||||
_links: Links;
|
||||
};
|
||||
|
||||
type Props = {
|
||||
initialConfiguration: Configuration,
|
||||
readOnly: boolean,
|
||||
type Props = WithTranslation & {
|
||||
initialConfiguration: Configuration;
|
||||
readOnly: boolean;
|
||||
|
||||
onConfigurationChange: (Configuration, boolean) => void,
|
||||
|
||||
// context props
|
||||
t: string => string
|
||||
onConfigurationChange: (p1: Configuration, p2: boolean) => void;
|
||||
};
|
||||
|
||||
type State = Configuration & {
|
||||
validationErrors: string[]
|
||||
validationErrors: string[];
|
||||
};
|
||||
|
||||
class HgConfigurationForm extends React.Component<Props, State> {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
this.state = { ...props.initialConfiguration, validationErrors: [] };
|
||||
this.state = {
|
||||
...props.initialConfiguration,
|
||||
validationErrors: []
|
||||
};
|
||||
}
|
||||
|
||||
updateValidationStatus = () => {
|
||||
const requiredFields = ["hgBinary", "pythonBinary", "encoding"];
|
||||
|
||||
const validationErrors = [];
|
||||
for (let field of requiredFields) {
|
||||
for (const field of requiredFields) {
|
||||
// @ts-ignore
|
||||
if (!this.state[field]) {
|
||||
validationErrors.push(field);
|
||||
}
|
||||
@@ -57,16 +57,16 @@ class HgConfigurationForm extends React.Component<Props, State> {
|
||||
return this.state.validationErrors.indexOf(name) >= 0;
|
||||
};
|
||||
|
||||
handleChange = (value: any, name: string) => {
|
||||
handleChange = (value: string | boolean, name?: string) => {
|
||||
if (!name) {
|
||||
throw new Error("name not set");
|
||||
}
|
||||
this.setState(
|
||||
// @ts-ignore
|
||||
{
|
||||
[name]: value
|
||||
},
|
||||
() =>
|
||||
this.props.onConfigurationChange(
|
||||
this.state,
|
||||
this.updateValidationStatus()
|
||||
)
|
||||
() => this.props.onConfigurationChange(this.state, this.updateValidationStatus())
|
||||
);
|
||||
};
|
||||
|
||||
@@ -78,6 +78,7 @@ class HgConfigurationForm extends React.Component<Props, State> {
|
||||
name={name}
|
||||
label={t("scm-hg-plugin.config." + name)}
|
||||
helpText={t("scm-hg-plugin.config." + name + "HelpText")}
|
||||
// @ts-ignore
|
||||
value={this.state[name]}
|
||||
onChange={this.handleChange}
|
||||
validationError={this.hasValidationError(name)}
|
||||
@@ -95,6 +96,7 @@ class HgConfigurationForm extends React.Component<Props, State> {
|
||||
name={name}
|
||||
label={t("scm-hg-plugin.config." + name)}
|
||||
helpText={t("scm-hg-plugin.config." + name + "HelpText")}
|
||||
// @ts-ignore
|
||||
checked={this.state[name]}
|
||||
onChange={this.handleChange}
|
||||
disabled={readOnly}
|
||||
@@ -122,4 +124,4 @@ class HgConfigurationForm extends React.Component<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
export default translate("plugins")(HgConfigurationForm);
|
||||
export default withTranslation("plugins")(HgConfigurationForm);
|
||||
@@ -1,28 +0,0 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import { Title, Configuration } from "@scm-manager/ui-components";
|
||||
import { translate } from "react-i18next";
|
||||
import HgConfigurationForm from "./HgConfigurationForm";
|
||||
|
||||
type Props = {
|
||||
link: string,
|
||||
|
||||
// context props
|
||||
t: (string) => string
|
||||
}
|
||||
|
||||
class HgGlobalConfiguration extends React.Component<Props> {
|
||||
|
||||
render() {
|
||||
const { link, t } = this.props;
|
||||
return (
|
||||
<div>
|
||||
<Title title={t("scm-hg-plugin.config.title")}/>
|
||||
<Configuration link={link} render={props => <HgConfigurationForm {...props} />}/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default translate("plugins")(HgGlobalConfiguration);
|
||||
@@ -0,0 +1,22 @@
|
||||
import React from "react";
|
||||
import { WithTranslation, withTranslation } from "react-i18next";
|
||||
import { Title, Configuration } from "@scm-manager/ui-components";
|
||||
import HgConfigurationForm from "./HgConfigurationForm";
|
||||
|
||||
type Props = WithTranslation & {
|
||||
link: string;
|
||||
};
|
||||
|
||||
class HgGlobalConfiguration extends React.Component<Props> {
|
||||
render() {
|
||||
const { link, t } = this.props;
|
||||
return (
|
||||
<div>
|
||||
<Title title={t("scm-hg-plugin.config.title")} />
|
||||
<Configuration link={link} render={(props: any) => <HgConfigurationForm {...props} />} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withTranslation("plugins")(HgGlobalConfiguration);
|
||||
@@ -1,16 +1,13 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import { WithTranslation, withTranslation } from "react-i18next";
|
||||
import { Repository } from "@scm-manager/ui-types";
|
||||
import { repositories } from "@scm-manager/ui-components";
|
||||
import type { Repository } from "@scm-manager/ui-types";
|
||||
import { translate } from "react-i18next";
|
||||
|
||||
type Props = {
|
||||
repository: Repository,
|
||||
t: string => string
|
||||
}
|
||||
type Props = WithTranslation & {
|
||||
repository: Repository;
|
||||
};
|
||||
|
||||
class ProtocolInformation extends React.Component<Props> {
|
||||
|
||||
render() {
|
||||
const { repository, t } = this.props;
|
||||
const href = repositories.getProtocolLinkByType(repository, "http");
|
||||
@@ -32,9 +29,11 @@ class ProtocolInformation extends React.Component<Props> {
|
||||
<br />
|
||||
echo "[paths]" > .hg/hgrc
|
||||
<br />
|
||||
echo "default = {href}" > .hg/hgrc
|
||||
echo "default = {href}
|
||||
" > .hg/hgrc
|
||||
<br />
|
||||
echo "# {repository.name}" > README.md
|
||||
echo "# {repository.name}
|
||||
" > README.md
|
||||
<br />
|
||||
hg add README.md
|
||||
<br />
|
||||
@@ -60,7 +59,6 @@ class ProtocolInformation extends React.Component<Props> {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default translate("plugins")(ProtocolInformation);
|
||||
export default withTranslation("plugins")(ProtocolInformation);
|
||||
@@ -1,4 +1,3 @@
|
||||
// @flow
|
||||
import { binder } from "@scm-manager/ui-extensions";
|
||||
import ProtocolInformation from "./ProtocolInformation";
|
||||
import HgAvatar from "./HgAvatar";
|
||||
@@ -6,27 +5,14 @@ import { ConfigurationBinder as cfgBinder } from "@scm-manager/ui-components";
|
||||
import HgGlobalConfiguration from "./HgGlobalConfiguration";
|
||||
import HgBranchInformation from "./HgBranchInformation";
|
||||
|
||||
const hgPredicate = (props: Object) => {
|
||||
const hgPredicate = (props: any) => {
|
||||
return props.repository && props.repository.type === "hg";
|
||||
};
|
||||
|
||||
binder.bind(
|
||||
"repos.repository-details.information",
|
||||
ProtocolInformation,
|
||||
hgPredicate
|
||||
);
|
||||
binder.bind(
|
||||
"repos.branch-details.information",
|
||||
HgBranchInformation,
|
||||
hgPredicate
|
||||
);
|
||||
binder.bind("repos.repository-details.information", ProtocolInformation, hgPredicate);
|
||||
binder.bind("repos.branch-details.information", HgBranchInformation, hgPredicate);
|
||||
binder.bind("repos.repository-avatar", HgAvatar, hgPredicate);
|
||||
|
||||
// bind global configuration
|
||||
|
||||
cfgBinder.bindGlobal(
|
||||
"/hg",
|
||||
"scm-hg-plugin.config.link",
|
||||
"hgConfig",
|
||||
HgGlobalConfiguration
|
||||
);
|
||||
cfgBinder.bindGlobal("/hg", "scm-hg-plugin.config.link", "hgConfig", HgGlobalConfiguration);
|
||||
Reference in New Issue
Block a user