diff --git a/scm-ui/public/locales/en/config.json b/scm-ui/public/locales/en/config.json index 5f1db2a549..2779b3c28c 100644 --- a/scm-ui/public/locales/en/config.json +++ b/scm-ui/public/locales/en/config.json @@ -9,7 +9,8 @@ "error-subtitle": "Unknown Config Error" }, "config-form": { - "submit": "Submit" + "submit": "Submit", + "no-permission-notification": "Please note: You do not have the permission to edit the config!" }, "proxy-settings": { "name": "Proxy Settings", diff --git a/scm-ui/src/config/components/form/ConfigForm.js b/scm-ui/src/config/components/form/ConfigForm.js index db0a79e7bf..bc4a94b501 100644 --- a/scm-ui/src/config/components/form/ConfigForm.js +++ b/scm-ui/src/config/components/form/ConfigForm.js @@ -7,6 +7,7 @@ import ProxySettings from "./ProxySettings"; import GeneralSettings from "./GeneralSettings"; import BaseUrlSettings from "./BaseUrlSettings"; import AdminSettings from "./AdminSettings"; +import Notification from "../../../components/Notification"; type Props = { submitForm: Config => void, @@ -17,7 +18,8 @@ type Props = { }; type State = { - config: Config + config: Config, + showNotification: boolean }; class ConfigForm extends React.Component { @@ -48,15 +50,18 @@ class ConfigForm extends React.Component { enabledXsrfProtection: true, defaultNamespaceStrategy: "", _links: {} - } + }, + showNotification: false }; } componentDidMount() { - const { config } = this.props; - console.log(config); + const { config, configUpdatePermission } = this.props; if (config) { - this.setState({ config: { ...config } }); + this.setState({ ...this.state, config: { ...config } }); + } + if (!configUpdatePermission) { + this.setState({ ...this.state, showNotification: true }); } } @@ -67,9 +72,23 @@ class ConfigForm extends React.Component { render() { const { loading, t, configUpdatePermission } = this.props; - let config = this.state.config; + const config = this.state.config; + + let noPermissionNotification = null; + + if (this.state.showNotification) { + noPermissionNotification = ( + this.onClose()} + /> + ); + } + return (
+ {noPermissionNotification} { onChange = (isValid: boolean, changedValue: any, name: string) => { if (isValid) { this.setState({ + ...this.state, config: { ...this.state.config, [name]: changedValue @@ -139,6 +159,13 @@ class ConfigForm extends React.Component { }); } }; + + onClose = () => { + this.setState({ + ...this.state, + showNotification: false + }); + }; } export default translate("config")(ConfigForm);