diff --git a/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js b/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js index 17577fb81..aacc70328 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js @@ -15,7 +15,7 @@ class ReportPageComponent extends AuthComponent { constructor(props) { super(props); - this.sectionsOrder = ['security', 'zeroTrust', 'attack', 'ransomware']; + this.sections = ['security', 'zeroTrust', 'attack', 'ransomware']; this.state = { securityReport: {}, attackReport: {}, @@ -23,8 +23,8 @@ class ReportPageComponent extends AuthComponent { ransomwareReport: {}, allMonkeysAreDead: false, runStarted: true, - selectedSection: ReportPageComponent.selectReport(this.sectionsOrder), - sections: [{key: 'security', title: 'Security report'}, + selectedSection: ReportPageComponent.selectReport(this.sections), + orderedSections: [{key: 'security', title: 'Security report'}, {key: 'zeroTrust', title: 'Zero trust report'}, {key: 'attack', title: 'ATT&CK report'}] }; @@ -66,7 +66,7 @@ class ReportPageComponent extends AuthComponent { }); }); if (this.shouldShowRansomwareReport(this.state.ransomwareReport)) { - this.state.sections.push({key: 'ransomware', title: 'Ransomware report'}) + this.addRansomwareReportTab(); } } } @@ -102,6 +102,26 @@ class ReportPageComponent extends AuthComponent { } } + addRansomwareReportTab() { // TODO: Fetch mode from API endpoint + let ransomwareTab = {key: 'ransomware', title: 'Ransomware report'}; + + // let mode = ""; + // this.authFetch('/api/mode') + // .then(res => res.json()) + // .then(res => { + // mode = res.mode + // } + // ); + + let mode = 'ransomware'; + if (mode === 'ransomware') { + this.state.orderedSections.splice(0, 0, ransomwareTab); + } + else { + this.state.orderedSections.push(ransomwareTab); + } + } + componentWillUnmount() { clearInterval(this.state.ztReportRefreshInterval); } @@ -138,7 +158,7 @@ class ReportPageComponent extends AuthComponent { history.push(key) }} className={'report-nav'}> - {this.state.sections.map(section => this.renderNavButton(section))} + {this.state.orderedSections.map(section => this.renderNavButton(section))} )}/>) };