From 28e14b4c4c2acf2bb151989984ced2c0e5dec938 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Fri, 16 Jul 2021 14:12:29 +0300 Subject: [PATCH] Island UI: change report side nav button to show ransomware report as default report when ransomware scenario is chosen --- .../cc/ui/src/components/Main.tsx | 67 +++++++++++-------- .../cc/ui/src/components/SideNavComponent.tsx | 21 +++--- .../layouts/SidebarLayoutComponent.tsx | 5 +- 3 files changed, 54 insertions(+), 39 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/Main.tsx b/monkey/monkey_island/cc/ui/src/components/Main.tsx index fb2733301..ea584f088 100644 --- a/monkey/monkey_island/cc/ui/src/components/Main.tsx +++ b/monkey/monkey_island/cc/ui/src/components/Main.tsx @@ -178,7 +178,21 @@ class AppComponent extends AuthComponent { clearInterval(this.interval); } + getDefaultReport() { + if(this.state.islandMode === 'ransomware'){ + return Routes.RansomwareReport + } else { + return Routes.SecurityReport + } + } + render() { + + let defaultSideNavProps = {completedSteps: this.state.completedSteps, + onStatusChange: this.updateStatus, + islandMode: this.state.islandMode, + defaultReport: this.getDefaultReport()} + return ( @@ -191,50 +205,39 @@ class AppComponent extends AuthComponent { completedSteps={new CompletedSteps()} onStatusChange={this.updateStatus}/>)} {this.renderRoute(Routes.GettingStartedPage, - , + , true)} {this.renderRoute(Routes.ConfigurePage, - )} + )} {this.renderRoute(Routes.RunMonkeyPage, - )} + )} {this.renderRoute(Routes.MapPage, - )} + )} {this.renderRoute(Routes.TelemetryPage, - )} + )} {this.renderRoute(Routes.StartOverPage, - )} - {this.redirectTo(Routes.Report, Routes.SecurityReport)} + )} + {this.redirectToReport()} {this.renderRoute(Routes.SecurityReport, )} + islandMode={this.state.islandMode} + {...defaultSideNavProps}/>)} {this.renderRoute(Routes.AttackReport, )} + islandMode={this.state.islandMode} + {...defaultSideNavProps}/>)} {this.renderRoute(Routes.ZeroTrustReport, )} + islandMode={this.state.islandMode} + {...defaultSideNavProps}/>)} {this.renderRoute(Routes.RansomwareReport, )} + islandMode={this.state.islandMode} + {...defaultSideNavProps}/>)} {this.renderRoute(Routes.LicensePage, )} + islandMode={this.state.islandMode} + {...defaultSideNavProps}/>)} @@ -242,6 +245,14 @@ class AppComponent extends AuthComponent { ); } + redirectToReport() { + if (this.state.islandMode === 'ransomware') { + return this.redirectTo(Routes.Report, Routes.RansomwareReport) + } else { + return this.redirectTo(Routes.Report, Routes.SecurityReport) + } + } + showInfectionDoneNotification() { if (this.shouldShowNotification()) { const hostname = window.location.hostname; diff --git a/monkey/monkey_island/cc/ui/src/components/SideNavComponent.tsx b/monkey/monkey_island/cc/ui/src/components/SideNavComponent.tsx index bd0bde5a1..450103bb9 100644 --- a/monkey/monkey_island/cc/ui/src/components/SideNavComponent.tsx +++ b/monkey/monkey_island/cc/ui/src/components/SideNavComponent.tsx @@ -7,7 +7,7 @@ import {faExternalLinkAlt} from '@fortawesome/free-solid-svg-icons'; import VersionComponent from './side-menu/VersionComponent'; import '../styles/components/SideNav.scss'; import {CompletedSteps} from "./side-menu/CompletedSteps"; -import {isReportRoute} from "./Main"; +import {isReportRoute, Routes} from "./Main"; const guardicoreLogoImage = require('../images/guardicore-logo.png'); @@ -17,15 +17,16 @@ const infectionMonkeyImage = require('../images/infection-monkey.svg'); type Props = { disabled?: boolean, - completedSteps: CompletedSteps + completedSteps: CompletedSteps, + defaultReport: string } -const SideNavComponent = ({disabled=false, completedSteps}: Props) => { +const SideNavComponent = ({disabled, completedSteps, defaultReport}: Props) => { return ( <> - +
logo Infection Monkey @@ -34,7 +35,7 @@ const SideNavComponent = ({disabled=false, completedSteps}: Props) => {
  • - + 1. Run Monkey {completedSteps.runMonkey ? @@ -43,7 +44,7 @@ const SideNavComponent = ({disabled=false, completedSteps}: Props) => {
  • - + 2. Infection Map {completedSteps.infectionDone ? @@ -52,7 +53,7 @@ const SideNavComponent = ({disabled=false, completedSteps}: Props) => {
  • - { return (isReportRoute(location.pathname)) @@ -65,7 +66,7 @@ const SideNavComponent = ({disabled=false, completedSteps}: Props) => {
  • - + Start Over @@ -74,7 +75,7 @@ const SideNavComponent = ({disabled=false, completedSteps}: Props) => {
      -
    • Configuration
    • @@ -96,7 +97,7 @@ const SideNavComponent = ({disabled=false, completedSteps}: Props) => { Documentation
      - License + License
); diff --git a/monkey/monkey_island/cc/ui/src/components/layouts/SidebarLayoutComponent.tsx b/monkey/monkey_island/cc/ui/src/components/layouts/SidebarLayoutComponent.tsx index 45e82e60c..746641958 100644 --- a/monkey/monkey_island/cc/ui/src/components/layouts/SidebarLayoutComponent.tsx +++ b/monkey/monkey_island/cc/ui/src/components/layouts/SidebarLayoutComponent.tsx @@ -6,13 +6,16 @@ import {Col, Row} from 'react-bootstrap'; const SidebarLayoutComponent = ({component: Component, sideNavDisabled = false, completedSteps = null, + defaultReport = '', ...other }) => ( { return ( - + )