ui: Fix bug where we can't change tab from attack to another tab in

configure
This commit is contained in:
Ilija Lazoroski 2021-07-16 13:12:02 +02:00 committed by VakarisZ
parent c760e06f03
commit f574af4225
1 changed files with 19 additions and 5 deletions

View File

@ -59,6 +59,8 @@ class ConfigurePageComponent extends AuthComponent {
getSectionsOrder() { getSectionsOrder() {
let islandMode = this.props.islandMode ? this.props.islandMode : 'advanced' let islandMode = this.props.islandMode ? this.props.islandMode : 'advanced'
// TODO delete the following line before merging
islandMode = 'advanced'
return CONFIGURATION_TABS_PER_MODE[islandMode]; return CONFIGURATION_TABS_PER_MODE[islandMode];
} }
@ -234,7 +236,11 @@ class ConfigurePageComponent extends AuthComponent {
updateConfigSection = () => { updateConfigSection = () => {
let newConfig = this.state.configuration; let newConfig = this.state.configuration;
if (Object.keys(this.state.currentFormData).length > 0) {
if (this.currentSection === 'attack' && this.state.currentFormData === undefined) {
this.state.currentFormData = this.state.attackConfig;
}
else if (Object.keys(this.state.currentFormData).length > 0) {
newConfig[this.currentSection] = this.state.currentFormData; newConfig[this.currentSection] = this.state.currentFormData;
} }
this.setState({configuration: newConfig, lastAction: 'none'}); this.setState({configuration: newConfig, lastAction: 'none'});
@ -309,10 +315,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;
@ -330,10 +342,12 @@ class ConfigurePageComponent extends AuthComponent {
} }
this.updateConfigSection(); this.updateConfigSection();
this.currentSection = key; this.currentSection = key;
this.setState({ this.setState({
selectedSection: key, selectedSection: key,
currentFormData: this.state.configuration[key] currentFormData: this.state.configuration[key]
}); });
}; };
resetConfig = () => { resetConfig = () => {