From 6e3053cfc0e84b45373f6f46d6049663a3ce66a3 Mon Sep 17 00:00:00 2001 From: Shreya Date: Wed, 14 Jul 2021 18:24:04 +0530 Subject: [PATCH] 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. --- .../monkey_island/cc/ui/src/components/pages/ConfigurePage.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js index 00deb8e60..594b0ad08 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -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 (