mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-12-22 00:09:47 +01:00
migrate core plugins from flow to typescript
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import { Links } from "@scm-manager/ui-types";
|
||||
|
||||
import { InputField, Checkbox } from "@scm-manager/ui-components";
|
||||
|
||||
type Configuration = {
|
||||
repositoryDirectory?: string;
|
||||
gcExpression?: string;
|
||||
nonFastForwardDisallowed: boolean;
|
||||
_links: Links;
|
||||
};
|
||||
|
||||
type Props = {
|
||||
initialConfiguration: Configuration;
|
||||
readOnly: boolean;
|
||||
|
||||
onConfigurationChange: (p1: Configuration, p2: boolean) => void;
|
||||
|
||||
// context props
|
||||
t: (p: string) => string;
|
||||
};
|
||||
|
||||
type State = Configuration & {};
|
||||
|
||||
class GitConfigurationForm extends React.Component<Props, State> {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
...props.initialConfiguration
|
||||
};
|
||||
}
|
||||
|
||||
onGcExpressionChange = (value: string) => {
|
||||
this.setState(
|
||||
{
|
||||
gcExpression: value
|
||||
},
|
||||
() => this.props.onConfigurationChange(this.state, true)
|
||||
);
|
||||
};
|
||||
|
||||
onNonFastForwardDisallowed = (value: boolean) => {
|
||||
this.setState(
|
||||
{
|
||||
nonFastForwardDisallowed: value
|
||||
},
|
||||
() => this.props.onConfigurationChange(this.state, true)
|
||||
);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { gcExpression, nonFastForwardDisallowed } = this.state;
|
||||
const { readOnly, t } = this.props;
|
||||
|
||||
return (
|
||||
<>
|
||||
<InputField
|
||||
name="gcExpression"
|
||||
label={t("scm-git-plugin.config.gcExpression")}
|
||||
helpText={t("scm-git-plugin.config.gcExpressionHelpText")}
|
||||
value={gcExpression}
|
||||
onChange={this.onGcExpressionChange}
|
||||
disabled={readOnly}
|
||||
/>
|
||||
<Checkbox
|
||||
name="nonFastForwardDisallowed"
|
||||
label={t("scm-git-plugin.config.nonFastForwardDisallowed")}
|
||||
helpText={t("scm-git-plugin.config.nonFastForwardDisallowedHelpText")}
|
||||
checked={nonFastForwardDisallowed}
|
||||
onChange={this.onNonFastForwardDisallowed}
|
||||
disabled={readOnly}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default translate("plugins")(GitConfigurationForm);
|
||||
Reference in New Issue
Block a user