forked from p15670423/monkey
Merge pull request #1331 from guardicore/1293/attack-no-change-tabs
Fix bug where we can't change tab from attack to another tab in Configure
This commit is contained in:
commit
b798e67163
|
@ -64,6 +64,7 @@ class ConfigurePageComponent extends AuthComponent {
|
||||||
|
|
||||||
setInitialConfig(config) {
|
setInitialConfig(config) {
|
||||||
// Sets a reference to know if config was changed
|
// Sets a reference to know if config was changed
|
||||||
|
config['attack'] = {}
|
||||||
this.initialConfig = JSON.parse(JSON.stringify(config));
|
this.initialConfig = JSON.parse(JSON.stringify(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,12 +229,16 @@ class ConfigurePageComponent extends AuthComponent {
|
||||||
|
|
||||||
onChange = ({formData}) => {
|
onChange = ({formData}) => {
|
||||||
let configuration = this.state.configuration;
|
let configuration = this.state.configuration;
|
||||||
|
if (this.state.selectedSection === 'attack'){
|
||||||
|
formData = {};
|
||||||
|
}
|
||||||
configuration[this.state.selectedSection] = formData;
|
configuration[this.state.selectedSection] = formData;
|
||||||
this.setState({currentFormData: formData, configuration: configuration});
|
this.setState({currentFormData: formData, configuration: configuration});
|
||||||
};
|
};
|
||||||
|
|
||||||
updateConfigSection = () => {
|
updateConfigSection = () => {
|
||||||
let newConfig = this.state.configuration;
|
let newConfig = this.state.configuration;
|
||||||
|
|
||||||
if (Object.keys(this.state.currentFormData).length > 0) {
|
if (Object.keys(this.state.currentFormData).length > 0) {
|
||||||
newConfig[this.currentSection] = this.state.currentFormData;
|
newConfig[this.currentSection] = this.state.currentFormData;
|
||||||
}
|
}
|
||||||
|
@ -309,10 +314,16 @@ class ConfigurePageComponent extends AuthComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
userChangedConfig() {
|
userChangedConfig() {
|
||||||
if (JSON.stringify(this.state.configuration) === JSON.stringify(this.initialConfig)) {
|
try {
|
||||||
if (Object.keys(this.state.currentFormData).length === 0 ||
|
if (JSON.stringify(this.state.configuration) === JSON.stringify(this.initialConfig)) {
|
||||||
JSON.stringify(this.initialConfig[this.currentSection]) === JSON.stringify(this.state.currentFormData)) {
|
if (Object.keys(this.state.currentFormData).length === 0 ||
|
||||||
return false;
|
JSON.stringify(this.initialConfig[this.currentSection]) === JSON.stringify(this.state.currentFormData)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (TypeError) {
|
||||||
|
if (JSON.stringify(this.initialConfig[this.currentSection]) === JSON.stringify(this.state.currentFormData)){
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -328,6 +339,7 @@ class ConfigurePageComponent extends AuthComponent {
|
||||||
this.setState({showAttackAlert: true});
|
this.setState({showAttackAlert: true});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateConfigSection();
|
this.updateConfigSection();
|
||||||
this.currentSection = key;
|
this.currentSection = key;
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -345,6 +357,7 @@ class ConfigurePageComponent extends AuthComponent {
|
||||||
})
|
})
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
res.configuration['attack'] = {}
|
||||||
this.setState({
|
this.setState({
|
||||||
lastAction: 'reset',
|
lastAction: 'reset',
|
||||||
schema: res.schema,
|
schema: res.schema,
|
||||||
|
|
Loading…
Reference in New Issue