mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-07-06 14:49:32 +02:00
reset error when loading config again
This commit is contained in:
@@ -9,7 +9,8 @@ import {
|
||||
modifyConfig,
|
||||
isModifyConfigPending,
|
||||
getConfigUpdatePermission,
|
||||
getModifyConfigFailure
|
||||
getModifyConfigFailure,
|
||||
modifyConfigReset
|
||||
} from "../modules/config";
|
||||
import connect from "react-redux/es/connect/connect";
|
||||
import ErrorPage from "../../components/ErrorPage";
|
||||
@@ -28,6 +29,7 @@ type Props = {
|
||||
// context objects
|
||||
t: string => string,
|
||||
fetchConfig: void => void,
|
||||
configReset: void => void,
|
||||
history: History
|
||||
};
|
||||
|
||||
@@ -38,6 +40,7 @@ class GlobalConfig extends React.Component<Props> {
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
this.props.configReset();
|
||||
this.props.fetchConfig();
|
||||
}
|
||||
|
||||
@@ -83,6 +86,9 @@ const mapDispatchToProps = dispatch => {
|
||||
},
|
||||
modifyConfig: (config: Config, callback?: () => void) => {
|
||||
dispatch(modifyConfig(config, callback));
|
||||
},
|
||||
configReset: () => {
|
||||
dispatch(modifyConfigReset());
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -16,6 +16,7 @@ export const MODIFY_CONFIG = "scm/config/MODIFY_CONFIG";
|
||||
export const MODIFY_CONFIG_PENDING = `${MODIFY_CONFIG}_${types.PENDING_SUFFIX}`;
|
||||
export const MODIFY_CONFIG_SUCCESS = `${MODIFY_CONFIG}_${types.SUCCESS_SUFFIX}`;
|
||||
export const MODIFY_CONFIG_FAILURE = `${MODIFY_CONFIG}_${types.FAILURE_SUFFIX}`;
|
||||
export const MODIFY_CONFIG_RESET = `${MODIFY_CONFIG}_${types.RESET_SUFFIX}`;
|
||||
|
||||
const CONFIG_URL = "config";
|
||||
const CONTENT_TYPE_CONFIG = "application/vnd.scmm-config+json;v=2";
|
||||
@@ -66,7 +67,7 @@ export function modifyConfig(config: Config, callback?: () => void) {
|
||||
return function(dispatch: Dispatch) {
|
||||
dispatch(modifyConfigPending(config));
|
||||
return apiClient
|
||||
.put(config._links.update.href, config, CONTENT_TYPE_CONFIG)
|
||||
.put(config._links.update.href + "letsfail!", config, CONTENT_TYPE_CONFIG)
|
||||
.then(() => {
|
||||
dispatch(modifyConfigSuccess(config));
|
||||
if (callback) {
|
||||
@@ -108,6 +109,12 @@ export function modifyConfigFailure(config: Config, error: Error): Action {
|
||||
};
|
||||
}
|
||||
|
||||
export function modifyConfigReset() {
|
||||
return {
|
||||
type: MODIFY_CONFIG_RESET
|
||||
};
|
||||
}
|
||||
|
||||
//reducer
|
||||
|
||||
function reducer(state: any = {}, action: any = {}) {
|
||||
|
||||
Reference in New Issue
Block a user