diff --git a/scm-plugins/scm-hg-plugin/src/main/js/HgConfigurationForm.js b/scm-plugins/scm-hg-plugin/src/main/js/HgConfigurationForm.js index b0935b238e..2049850e8e 100644 --- a/scm-plugins/scm-hg-plugin/src/main/js/HgConfigurationForm.js +++ b/scm-plugins/scm-hg-plugin/src/main/js/HgConfigurationForm.js @@ -5,15 +5,15 @@ import { translate } from "react-i18next"; 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 = { @@ -23,29 +23,26 @@ type Props = { onConfigurationChange: (Configuration, boolean) => void, // context props - t: (string) => string -} + t: string => string +}; type State = Configuration & { validationErrors: string[] }; class HgConfigurationForm extends React.Component { - constructor(props: Props) { super(props); this.state = { ...props.initialConfiguration, validationErrors: [] }; } updateValidationStatus = () => { - const requiredFields = [ - "hgBinary", "pythonBinary", "encoding" - ]; + const requiredFields = ["hgBinary", "pythonBinary", "encoding"]; const validationErrors = []; for (let field of requiredFields) { if (!this.state[field]) { - validationErrors.push( field ); + validationErrors.push(field); } } @@ -56,58 +53,73 @@ class HgConfigurationForm extends React.Component { return validationErrors.length === 0; }; - hasValidationError = (name: string) => { return this.state.validationErrors.indexOf(name) >= 0; }; handleChange = (value: any, name: string) => { - this.setState({ - [name]: value - }, () => this.props.onConfigurationChange(this.state, this.updateValidationStatus())); + this.setState( + { + [name]: value + }, + () => + this.props.onConfigurationChange( + this.state, + this.updateValidationStatus() + ) + ); }; inputField = (name: string) => { const { readOnly, t } = this.props; - return ; + return ( +
+ +
+ ); }; checkbox = (name: string) => { const { readOnly, t } = this.props; - return ; + return ( + + ); }; render() { return ( - <> +
{this.inputField("hgBinary")} {this.inputField("pythonBinary")} {this.inputField("pythonPath")} {this.inputField("encoding")} - {this.checkbox("useOptimizedBytecode")} - {this.checkbox("showRevisionInId")} - {this.checkbox("disableHookSSLValidation")} - {this.checkbox("enableHttpPostArgs")} - +
+ {this.checkbox("useOptimizedBytecode")} + {this.checkbox("showRevisionInId")} +
+
+ {this.checkbox("disableHookSSLValidation")} + {this.checkbox("enableHttpPostArgs")} +
+
); } - } export default translate("plugins")(HgConfigurationForm);