mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25:45 +01:00
add notification message if user has no permission to edit config
This commit is contained in:
@@ -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<Props, State> {
|
||||
@@ -48,15 +50,18 @@ class ConfigForm extends React.Component<Props, State> {
|
||||
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<Props, State> {
|
||||
|
||||
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 = (
|
||||
<Notification
|
||||
type={"info"}
|
||||
children={t("config-form.no-permission-notification")}
|
||||
onClose={() => this.onClose()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={this.submit}>
|
||||
{noPermissionNotification}
|
||||
<GeneralSettings
|
||||
realmDescription={config.realmDescription}
|
||||
enableRepositoryArchive={config.enableRepositoryArchive}
|
||||
@@ -132,6 +151,7 @@ class ConfigForm extends React.Component<Props, State> {
|
||||
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<Props, State> {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
onClose = () => {
|
||||
this.setState({
|
||||
...this.state,
|
||||
showNotification: false
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export default translate("config")(ConfigForm);
|
||||
|
||||
Reference in New Issue
Block a user