From 27ae4dac1a192c67ef4f7db609c881245fa110c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maren=20S=C3=BCwer?= Date: Mon, 13 Aug 2018 16:33:56 +0200 Subject: [PATCH] show settings and let them modify --- .../config/components/form/AdminSettings.js | 29 ++++ .../config/components/form/BaseUrlSettings.js | 43 ++++++ .../src/config/components/form/ConfigForm.js | 126 ++++++++++++++++ .../config/components/form/GeneralSettings.js | 135 ++++++++++++++++++ .../config/components/form/ProxySettings.js | 82 +++++++++++ 5 files changed, 415 insertions(+) create mode 100644 scm-ui/src/config/components/form/AdminSettings.js create mode 100644 scm-ui/src/config/components/form/BaseUrlSettings.js create mode 100644 scm-ui/src/config/components/form/ConfigForm.js create mode 100644 scm-ui/src/config/components/form/GeneralSettings.js create mode 100644 scm-ui/src/config/components/form/ProxySettings.js diff --git a/scm-ui/src/config/components/form/AdminSettings.js b/scm-ui/src/config/components/form/AdminSettings.js new file mode 100644 index 0000000000..5079addca1 --- /dev/null +++ b/scm-ui/src/config/components/form/AdminSettings.js @@ -0,0 +1,29 @@ +// @flow +import React from "react"; +import { translate } from "react-i18next"; +import { Checkbox, InputField } from "../../../components/forms/index"; +import Subtitle from "../../../components/layout/Subtitle"; + +type Props = { + adminGroups: string[], + adminUsers: string[], + t: string => string, + onChange: (boolean, any, string) => void +}; +//TODO: Einbauen! +class AdminSettings extends React.Component { + render() { + const { + t, + adminGroups, + adminUsers + } = this.props; + + return ( + null + ); + } + +} + +export default translate("config")(AdminSettings); diff --git a/scm-ui/src/config/components/form/BaseUrlSettings.js b/scm-ui/src/config/components/form/BaseUrlSettings.js new file mode 100644 index 0000000000..cde4680b48 --- /dev/null +++ b/scm-ui/src/config/components/form/BaseUrlSettings.js @@ -0,0 +1,43 @@ +// @flow +import React from "react"; +import { translate } from "react-i18next"; +import { Checkbox, InputField } from "../../../components/forms/index"; +import Subtitle from "../../../components/layout/Subtitle"; + +type Props = { + baseUrl: string, + forceBaseUrl: boolean, + t: string => string, + onChange: (boolean, any, string) => void +}; + +class BaseUrlSettings extends React.Component { + render() { + const { t, baseUrl, forceBaseUrl } = this.props; + + return ( +
+ + + +
+ ); + } + + handleBaseUrlChange = (value: string) => { + this.props.onChange(true, value, "baseUrl"); + }; + handleForceBaseUrlChange = (value: boolean) => { + this.props.onChange(true, value, "forceBaseUrl"); + }; +} + +export default translate("config")(BaseUrlSettings); diff --git a/scm-ui/src/config/components/form/ConfigForm.js b/scm-ui/src/config/components/form/ConfigForm.js new file mode 100644 index 0000000000..ac7325e6fc --- /dev/null +++ b/scm-ui/src/config/components/form/ConfigForm.js @@ -0,0 +1,126 @@ +// @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); diff --git a/scm-ui/src/config/components/form/GeneralSettings.js b/scm-ui/src/config/components/form/GeneralSettings.js new file mode 100644 index 0000000000..29db1e5288 --- /dev/null +++ b/scm-ui/src/config/components/form/GeneralSettings.js @@ -0,0 +1,135 @@ +// @flow +import React from "react"; +import { translate } from "react-i18next"; +import { Checkbox, InputField } from "../../../components/forms/index"; + +type Props = { + realmDescription: string, + enableRepositoryArchive: boolean, + disableGroupingGrid: boolean, + dateFormat: string, + anonymousAccessEnabled: boolean, + loginAttemptLimit: number, + skipFailedAuthenticators: boolean, + pluginUrl: string, + loginAttemptLimitTimeout: number, + enabledXsrfProtection: boolean, + defaultNamespaceStrategy: string, + t: string => string, + onChange: (boolean, any, string) => void +}; + +class GeneralSettings extends React.Component { + render() { + const { + t, + realmDescription, + enableRepositoryArchive, + disableGroupingGrid, + dateFormat, + anonymousAccessEnabled, + loginAttemptLimit, + skipFailedAuthenticators, + pluginUrl, + loginAttemptLimitTimeout, + enabledXsrfProtection, + defaultNamespaceStrategy + } = this.props; + + return ( +
+ + + + + + + + + + + +
+ ); + } + + handleRealmDescriptionChange = (value: string) => { + this.props.onChange(true, value, "realmDescription"); + }; + handleEnableRepositoryArchiveChange = (value: boolean) => { + this.props.onChange(true, value, "enableRepositoryArchive"); + }; + handleDisableGroupingGridChange = (value: boolean) => { + this.props.onChange(true, value, "disableGroupingGrid"); + }; + handleDateFormatChange = (value: string) => { + this.props.onChange(true, value, "dateFormat"); + }; + handleAnonymousAccessEnabledChange = (value: string) => { + this.props.onChange(true, value, "anonymousAccessEnabled"); + }; + handleLoginAttemptLimitChange = (value: string) => { + this.props.onChange(true, value, "loginAttemptLimit"); + }; + handleSkipFailedAuthenticatorsChange = (value: string) => { + this.props.onChange(true, value, "skipFailedAuthenticators"); + }; + handlePluginUrlChange = (value: string) => { + this.props.onChange(true, value, "pluginUrl"); + }; + handleLoginAttemptLimitTimeoutChange = (value: string) => { + this.props.onChange(true, value, "loginAttemptLimitTimeout"); + }; + handleEnabledXsrfProtectionChange = (value: boolean) => { + this.props.onChange(true, value, "enabledXsrfProtection"); + }; + handleDefaultNamespaceStrategyChange = (value: string) => { + this.props.onChange(true, value, "defaultNamespaceStrategy"); + }; +} + +export default translate("config")(GeneralSettings); diff --git a/scm-ui/src/config/components/form/ProxySettings.js b/scm-ui/src/config/components/form/ProxySettings.js new file mode 100644 index 0000000000..2938c08a71 --- /dev/null +++ b/scm-ui/src/config/components/form/ProxySettings.js @@ -0,0 +1,82 @@ +// @flow +import React from "react"; +import { translate } from "react-i18next"; +import { Checkbox, InputField } from "../../../components/forms/index"; +import Subtitle from "../../../components/layout/Subtitle"; + +type Props = { + proxyPassword: string, + proxyPort: number, + proxyServer: string, + proxyUser: string, + enableProxy: boolean, + proxyExcludes: string[], //TODO: einbauen! + t: string => string, + onChange: (boolean, any, string) => void +}; + +class ProxySettings extends React.Component { + render() { + const { + t, + proxyPassword, + proxyPort, + proxyServer, + proxyUser, + enableProxy + } = this.props; + + return ( +
+ + + + + + +
+ ); + } + + handleProxyPasswordChange = (value: string) => { + this.props.onChange(true, value, "proxyPassword"); + }; + handleProxyPortChange = (value: string) => { + this.props.onChange(true, value, "proxyPort"); + }; + handleProxyServerChange = (value: string) => { + this.props.onChange(true, value, "proxyServer"); + }; + handleProxyUserChange = (value: string) => { + this.props.onChange(true, value, "proxyUser"); + }; + handleEnableProxyChange = (value: string) => { + this.props.onChange(true, value, "enableProxy"); + }; +} + +export default translate("config")(ProxySettings);