// @flow import React from "react"; import { translate } from "react-i18next"; import { SubmitButton } from "../../../components/buttons/index"; import type { Config } from "../../types/Config"; import ProxySettings from "./ProxySettings"; import GeneralSettings from "./GeneralSettings"; import BaseUrlSettings from "./BaseUrlSettings"; type Props = { submitForm: Config => void, config?: Config, loading?: boolean, t: string => string }; type State = { config: Config }; class ConfigForm extends React.Component { constructor(props: Props) { super(props); this.state = { config: { proxyPassword: null, proxyPort: 0, proxyServer: "", proxyUser: null, enableProxy: false, realmDescription: "", enableRepositoryArchive: false, disableGroupingGrid: false, dateFormat: "", anonymousAccessEnabled: false, adminGroups: [], adminUsers: [], baseUrl: "", forceBaseUrl: false, loginAttemptLimit: 0, proxyExcludes: [], skipFailedAuthenticators: false, pluginUrl: "", loginAttemptLimitTimeout: 0, enabledXsrfProtection: true, defaultNamespaceStrategy: "", _links: {} } }; } componentDidMount() { const { config } = this.props; console.log(config); if (config) { this.setState({ config: { ...config } }); } } submit = (event: Event) => { event.preventDefault(); this.props.submitForm(this.state.config); }; render() { const { loading, t } = this.props; let config = this.state.config; return (
this.onChange(isValid, changedValue, name) } /> this.onChange(isValid, changedValue, name) } /> this.onChange(isValid, changedValue, name) } /> ); } onChange = (isValid: boolean, changedValue: any, name: string) => { if (isValid) { this.setState({ config: { ...this.state.config, [name]: changedValue } }); } }; } export default translate("config")(ConfigForm);