From eca982e796b12c5a33d90386297ef80629bc009f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Pfeuffer?= Date: Mon, 4 Mar 2019 16:47:44 +0100 Subject: [PATCH] fIX config error if link is missing --- scm-ui/public/locales/de/config.json | 3 ++- scm-ui/public/locales/en/config.json | 3 ++- .../src/config/components/form/ConfigForm.js | 19 +++++++++++++++++-- scm-ui/src/config/containers/GlobalConfig.js | 16 ++++++++++------ 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/scm-ui/public/locales/de/config.json b/scm-ui/public/locales/de/config.json index 5767a2b376..b67bf90262 100644 --- a/scm-ui/public/locales/de/config.json +++ b/scm-ui/public/locales/de/config.json @@ -9,7 +9,8 @@ "config-form": { "submit": "Speichern", "submit-success-notification": "Einstellungen wurden erfolgreich geƤndert!", - "no-permission-notification": "Hinweis: Es fehlen Berechtigungen zum Bearbeiten der Einstellungen!" + "no-read-permission-notification": "Hinweis: Es fehlen Berechtigungen zum Lesen der Einstellungen!", + "no-write-permission-notification": "Hinweis: Es fehlen Berechtigungen zum Bearbeiten der Einstellungen!" }, "proxy-settings": { "name": "Proxy Einstellungen", diff --git a/scm-ui/public/locales/en/config.json b/scm-ui/public/locales/en/config.json index b08c5c2d1b..1b42878015 100644 --- a/scm-ui/public/locales/en/config.json +++ b/scm-ui/public/locales/en/config.json @@ -9,7 +9,8 @@ "config-form": { "submit": "Submit", "submit-success-notification": "Configuration changed successfully!", - "no-permission-notification": "Please note: You do not have the permission to edit the config!" + "no-read-permission-notification": "Please note: You do not have the permission to see the config!", + "no-write-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 dc3f20c95d..7b650ccbfd 100644 --- a/scm-ui/src/config/components/form/ConfigForm.js +++ b/scm-ui/src/config/components/form/ConfigForm.js @@ -14,6 +14,7 @@ type Props = { config?: Config, loading?: boolean, t: string => string, + configReadPermission: boolean, configUpdatePermission: boolean }; @@ -84,16 +85,30 @@ class ConfigForm extends React.Component { }; render() { - const { loading, t, configUpdatePermission } = this.props; + const { + loading, + t, + configReadPermission, + configUpdatePermission + } = this.props; const config = this.state.config; let noPermissionNotification = null; + if (!configReadPermission) { + return ( + + ); + } + if (this.state.showNotification) { noPermissionNotification = ( this.onClose()} /> ); diff --git a/scm-ui/src/config/containers/GlobalConfig.js b/scm-ui/src/config/containers/GlobalConfig.js index de01e98aab..fd3ee04098 100644 --- a/scm-ui/src/config/containers/GlobalConfig.js +++ b/scm-ui/src/config/containers/GlobalConfig.js @@ -1,11 +1,7 @@ // @flow import React from "react"; import { translate } from "react-i18next"; -import { - Title, - Loading, - ErrorNotification -} from "@scm-manager/ui-components"; +import { Title, Loading, ErrorNotification } from "@scm-manager/ui-components"; import { fetchConfig, getFetchConfigFailure, @@ -39,6 +35,7 @@ type Props = { }; type State = { + configReadPermission: boolean, configChanged: boolean }; @@ -47,13 +44,18 @@ class GlobalConfig extends React.Component { super(props); this.state = { + configReadPermission: true, configChanged: false }; } componentDidMount() { this.props.configReset(); - this.props.fetchConfig(this.props.configLink); + if (this.props.configLink) { + this.props.fetchConfig(this.props.configLink); + } else { + this.setState({configReadPermission: false}); + } } modifyConfig = (config: Config) => { @@ -102,6 +104,7 @@ class GlobalConfig extends React.Component { renderContent = () => { const { error, loading, config, configUpdatePermission } = this.props; + const { configReadPermission } = this.state; if (!error) { return ( <> @@ -111,6 +114,7 @@ class GlobalConfig extends React.Component { config={config} loading={loading} configUpdatePermission={configUpdatePermission} + configReadPermission={configReadPermission} /> );