Merge pull request #512 from guardicore/config_change_warning

Added config won't change warning
This commit is contained in:
VakarisZ 2020-01-21 10:51:19 +02:00 committed by GitHub
commit af8654b24e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 14 deletions

View File

@ -30,7 +30,7 @@ class ConfigurePageComponent extends AuthComponent {
lastAction: 'none', lastAction: 'none',
sections: [], sections: [],
selectedSection: 'attack', selectedSection: 'attack',
allMonkeysAreDead: true, monkeysRan: false,
PBAwinFile: [], PBAwinFile: [],
PBAlinuxFile: [], PBAlinuxFile: [],
showAttackAlert: false showAttackAlert: false
@ -363,13 +363,7 @@ class ConfigurePageComponent extends AuthComponent {
this.authFetch('/api') this.authFetch('/api')
.then(res => res.json()) .then(res => res.json())
.then(res => { .then(res => {
// This check is used to prevent unnecessary re-rendering this.setState({monkeysRan: res['completed_steps']['run_monkey']});
let allMonkeysAreDead = (!res['completed_steps']['run_monkey']) || (res['completed_steps']['infection_done']);
if (allMonkeysAreDead !== this.state.allMonkeysAreDead) {
this.setState({
allMonkeysAreDead: allMonkeysAreDead
});
}
}); });
}; };
@ -470,15 +464,15 @@ class ConfigurePageComponent extends AuthComponent {
</div>) </div>)
}; };
renderRunningMonkeysWarning = () => { renderConfigWontChangeWarning = () => {
return (<div> return (<div>
{this.state.allMonkeysAreDead ? {this.state.monkeysRan ?
'' :
<div className="alert alert-warning"> <div className="alert alert-warning">
<i className="glyphicon glyphicon-warning-sign" style={{'marginRight': '5px'}}/> <i className="glyphicon glyphicon-warning-sign" style={{'marginRight': '5px'}}/>
Some monkeys are currently running. Note that changing the configuration will only apply to new Changed configuration will only apply to new infections.
infections. "Start over" to run again with different configuration.
</div> </div>
: ''
} }
</div>) </div>)
}; };
@ -520,7 +514,7 @@ class ConfigurePageComponent extends AuthComponent {
{this.renderAttackAlertModal()} {this.renderAttackAlertModal()}
<h1 className="page-title">Monkey Configuration</h1> <h1 className="page-title">Monkey Configuration</h1>
{this.renderNav()} {this.renderNav()}
{this.renderRunningMonkeysWarning()} {this.renderConfigWontChangeWarning()}
{content} {content}
<div className="text-center"> <div className="text-center">
<button type="submit" onClick={this.onSubmit} className="btn btn-success btn-lg" style={{margin: '5px'}}> <button type="submit" onClick={this.onSubmit} className="btn btn-success btn-lg" style={{margin: '5px'}}>