cc: Don't try rendering any monkey config tab if length of `this.state.configuration` is 0

The config is fetched in `componentDidMount()` (which is called
after `render()` finishes successfully). If you attempt to render
the configuration (i.e. call `renderConfigContent()`) before the
config is fetched, it throws an error.
This commit is contained in:
Shreya 2021-07-14 18:24:04 +05:30 committed by Mike Salvatore
parent 917d7dfb15
commit 6e3053cfc0
1 changed files with 2 additions and 1 deletions

View File

@ -105,6 +105,7 @@ class ConfigurePageComponent extends AuthComponent {
componentDidMount = () => {
let urls = [CONFIG_URL, ATTACK_URL];
// ??? Why fetch config here and not in `render()`?
Promise.all(urls.map(url => this.authFetch(url).then(res => res.json())))
.then(data => {
let sections = [];
@ -521,7 +522,7 @@ class ConfigurePageComponent extends AuthComponent {
let content = '';
if (this.state.selectedSection === 'attack' && Object.entries(this.state.attackConfig).length !== 0) {
content = this.renderMatrix()
} else if (this.state.selectedSection !== 'attack') {
} else if (this.state.selectedSection !== 'attack' && Object.entries(this.state.configuration).length !== 0) {
content = this.renderConfigContent(displayedSchema)
}
return (