forked from p15670423/monkey
Island UI: change report UI to sort tabs according to island mode. In ransomware mode, ransomware tab is the first on the right.
This commit is contained in:
parent
28e14b4c4c
commit
0ee3e7be5e
|
@ -33,7 +33,7 @@ import _ from "lodash";
|
||||||
|
|
||||||
let notificationIcon = require('../images/notification-logo-512x512.png');
|
let notificationIcon = require('../images/notification-logo-512x512.png');
|
||||||
|
|
||||||
const Routes = {
|
export const Routes = {
|
||||||
LandingPage: '/landing-page',
|
LandingPage: '/landing-page',
|
||||||
GettingStartedPage: '/',
|
GettingStartedPage: '/',
|
||||||
Report: '/report',
|
Report: '/report',
|
||||||
|
|
|
@ -16,6 +16,7 @@ class ReportPageComponent extends AuthComponent {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.sections = ['security', 'zeroTrust', 'attack', 'ransomware'];
|
this.sections = ['security', 'zeroTrust', 'attack', 'ransomware'];
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
securityReport: {},
|
securityReport: {},
|
||||||
attackReport: {},
|
attackReport: {},
|
||||||
|
@ -28,6 +29,7 @@ class ReportPageComponent extends AuthComponent {
|
||||||
{key: 'zeroTrust', title: 'Zero trust report'},
|
{key: 'zeroTrust', title: 'Zero trust report'},
|
||||||
{key: 'attack', title: 'ATT&CK report'}]
|
{key: 'attack', title: 'ATT&CK report'}]
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static selectReport(reports) {
|
static selectReport(reports) {
|
||||||
|
@ -65,9 +67,6 @@ class ReportPageComponent extends AuthComponent {
|
||||||
ransomwareReport: res
|
ransomwareReport: res
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
if (this.shouldShowRansomwareReport(this.state.ransomwareReport)) {
|
|
||||||
this.addRansomwareReportTab();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,32 +95,6 @@ class ReportPageComponent extends AuthComponent {
|
||||||
return ztReport
|
return ztReport
|
||||||
};
|
};
|
||||||
|
|
||||||
shouldShowRansomwareReport(report) { // TODO: Add proper check
|
|
||||||
if (report) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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() {
|
componentWillUnmount() {
|
||||||
clearInterval(this.state.ztReportRefreshInterval);
|
clearInterval(this.state.ztReportRefreshInterval);
|
||||||
}
|
}
|
||||||
|
@ -187,9 +160,32 @@ class ReportPageComponent extends AuthComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addRansomwareTab() {
|
||||||
|
let ransomwareTab = {key: 'ransomware', title: 'Ransomware report'};
|
||||||
|
if(this.isRansomwareTabMissing(ransomwareTab)){
|
||||||
|
if (this.props.islandMode === 'ransomware') {
|
||||||
|
this.state.orderedSections.splice(0, 0, ransomwareTab);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.state.orderedSections.push(ransomwareTab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
isRansomwareTabMissing(ransomwareTab) {
|
||||||
|
return (
|
||||||
|
this.props.islandMode !== undefined &&
|
||||||
|
!this.state.orderedSections.some(tab =>
|
||||||
|
(tab.key === ransomwareTab.key
|
||||||
|
&& tab.title === ransomwareTab.title)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let content;
|
let content;
|
||||||
|
|
||||||
|
this.addRansomwareTab();
|
||||||
|
|
||||||
if (this.state.runStarted) {
|
if (this.state.runStarted) {
|
||||||
content = this.getReportContent();
|
content = this.getReportContent();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue