Redux changes and refactoring
This commit is contained in:
@@ -7,20 +7,17 @@ import ConfigurationItem from '../../components/ConfigurationItem/ConfigurationI
|
||||
import Modal from '../../components/UI/Modal/Modal';
|
||||
import IPCContainer from '../IPCContainer/IPCContainer';
|
||||
import {displayConfiguration} from '../../redux/actions/mount_actions';
|
||||
import {notifyError} from '../../redux/actions/error_actions';
|
||||
|
||||
const Constants = require('../../constants');
|
||||
|
||||
class Configuration extends IPCContainer {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.setRequestHandler(Constants.IPC_Get_Config_Template_Reply, this.onGetConfigTemplateReply);
|
||||
this.setRequestHandler(Constants.IPC_Get_Config_Reply, this.onGetConfigReply);
|
||||
this.setRequestHandler(Constants.IPC_Set_Config_Values_Reply, this.onSetConfigValuesReply);
|
||||
|
||||
this.sendRequest(Constants.IPC_Get_Config_Template, {
|
||||
Provider: this.props.DisplayConfiguration,
|
||||
Version: this.props.version,
|
||||
});
|
||||
}
|
||||
|
||||
state = {
|
||||
@@ -72,6 +69,13 @@ class Configuration extends IPCContainer {
|
||||
}
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
this.sendRequest(Constants.IPC_Get_Config_Template, {
|
||||
Provider: this.props.DisplayConfiguration,
|
||||
Version: this.props.version,
|
||||
});
|
||||
}
|
||||
|
||||
createItemList = (config, template) => {
|
||||
const objectList = [];
|
||||
const itemList = Object
|
||||
@@ -142,7 +146,7 @@ class Configuration extends IPCContainer {
|
||||
OriginalObjectLookup: objectLookupCopy,
|
||||
});
|
||||
} else {
|
||||
this.props.errorHandler(arg.data.Error);
|
||||
this.props.notifyError(arg.data.Error);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -157,8 +161,10 @@ class Configuration extends IPCContainer {
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.props.errorHandler(arg.data.Error, () => {
|
||||
this.props.hideConfiguration();
|
||||
this.props.notifyError(arg.data.Error, false, () => {
|
||||
if (this.isMounted()) {
|
||||
this.props.hideConfiguration();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -283,6 +289,7 @@ const mapStateToProps = state => {
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
notifyError: (msg, critical, callback) => dispatch(notifyError(msg, critical, callback)),
|
||||
hideConfiguration: () => dispatch(displayConfiguration(null)),
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user