migrate core plugins from flow to typescript

This commit is contained in:
Sebastian Sdorra
2019-10-21 12:13:08 +02:00
parent 85703161f6
commit 0703f1e2bd
104 changed files with 583 additions and 93542 deletions

View File

@@ -1,16 +1,14 @@
//@flow
import React from "react";
import { repositories } from "@scm-manager/ui-components";
import type { Repository } from "@scm-manager/ui-types";
import { Repository } from "@scm-manager/ui-types";
import { translate } from "react-i18next";
type Props = {
repository: Repository,
t: string => string
}
repository: Repository;
t: (p: string) => string;
};
class ProtocolInformation extends React.Component<Props> {
render() {
const { repository, t } = this.props;
const href = repositories.getProtocolLinkByType(repository, "http");
@@ -26,7 +24,6 @@ class ProtocolInformation extends React.Component<Props> {
</div>
);
}
}
export default translate("plugins")(ProtocolInformation);

View File

@@ -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 SvnAvatar extends React.Component<Props> {
render() {
return <Image src="/images/svn-logo.gif" alt="Subversion Logo" />;
}
}
export default SvnAvatar;

View File

@@ -1,45 +1,51 @@
//@flow
import React from "react";
import type { Links } from "@scm-manager/ui-types";
import { Links } from "@scm-manager/ui-types";
import { translate } from "react-i18next";
import { InputField, Checkbox, Select } from "@scm-manager/ui-components";
import { Checkbox, Select } from "@scm-manager/ui-components";
type Configuration = {
compatibility: string,
enabledGZip: boolean,
_links: Links
compatibility: string;
enabledGZip: boolean;
_links: Links;
};
type Props = {
initialConfiguration: Configuration,
readOnly: boolean,
initialConfiguration: Configuration;
readOnly: boolean;
onConfigurationChange: (Configuration, boolean) => void,
onConfigurationChange: (p1: Configuration, p2: boolean) => void;
// context props
t: (string) => string
}
t: (p: string) => string;
};
type State = Configuration;
class SvnConfigurationForm extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = { ...props.initialConfiguration, validationErrors: [] };
this.state = {
...props.initialConfiguration
};
}
handleChange = (value: any, name: string) => {
this.setState({
[name]: value
}, () => this.props.onConfigurationChange(this.state, true));
handleChange = (value: any, name?: string) => {
if (!name) {
throw new Error("required name not set");
}
this.setState(
// @ts-ignore
{
[name]: value
},
() => this.props.onConfigurationChange(this.state, true)
);
};
compatibilityOptions = (values: string[]) => {
const options = [];
for (let value of values) {
options.push( this.compatibilityOption(value) );
for (const value of values) {
options.push(this.compatibilityOption(value));
}
return options;
};
@@ -53,9 +59,7 @@ class SvnConfigurationForm extends React.Component<Props, State> {
render() {
const { readOnly, t } = this.props;
const compatibilityOptions = this.compatibilityOptions([
"NONE", "PRE14", "PRE15", "PRE16", "PRE17", "WITH17"
]);
const compatibilityOptions = this.compatibilityOptions(["NONE", "PRE14", "PRE15", "PRE16", "PRE17", "WITH17"]);
return (
<>
@@ -78,7 +82,6 @@ class SvnConfigurationForm extends React.Component<Props, State> {
</>
);
}
}
export default translate("plugins")(SvnConfigurationForm);

View File

@@ -1,28 +1,25 @@
//@flow
import React from "react";
import { translate } from "react-i18next";
import { Title, Configuration } from "@scm-manager/ui-components";
import SvnConfigurationForm from "./SvnConfigurationForm";
type Props = {
link: string,
link: string;
// context props
t: (string) => string
}
t: (p: string) => string;
};
class SvnGlobalConfiguration extends React.Component<Props> {
render() {
const { link, t } = this.props;
const { link, t } = this.props;
return (
<div>
<Title title={t("scm-svn-plugin.config.title")}/>
<Configuration link={link} render={props => <SvnConfigurationForm {...props} />}/>
<Title title={t("scm-svn-plugin.config.title")} />
<Configuration link={link} render={(props: any) => <SvnConfigurationForm {...props} />} />
</div>
);
}
}
export default translate("plugins")(SvnGlobalConfiguration);

View File

@@ -1,11 +1,10 @@
// @flow
import { binder } from "@scm-manager/ui-extensions";
import { ConfigurationBinder as cfgBinder } from "@scm-manager/ui-components";
import ProtocolInformation from "./ProtocolInformation";
import SvnAvatar from "./SvnAvatar";
import SvnGlobalConfiguration from "./SvnGlobalConfiguration";
const svnPredicate = (props: Object) => {
const svnPredicate = (props: any) => {
return props.repository && props.repository.type === "svn";
};