diff --git a/monkey/monkey_island/cc/ui/src/components/Main.tsx b/monkey/monkey_island/cc/ui/src/components/Main.tsx index a8d78cdc9..70d424ae4 100644 --- a/monkey/monkey_island/cc/ui/src/components/Main.tsx +++ b/monkey/monkey_island/cc/ui/src/components/Main.tsx @@ -41,6 +41,14 @@ const Routes = { ZeroTrustReport: '/report/zeroTrust', SecurityReport: '/report/security', RansomwareReport: '/report/ransomware', + LoginPage: '/login', + RegisterPage: '/register', + ConfigurePage: '/configure', + RunMonkeyPage: '/run-monkey', + MapPage: '/infection/map', + TelemetryPage: '/infection/telemetry', + StartOverPage: '/start-over', + LicensePage: '/license' } export function isReportRoute(route){ @@ -83,7 +91,7 @@ class AppComponent extends AuthComponent { } if (res) { - this.checkMode() + this.setMode() .then(() => { if (this.state.islandMode === null) { return @@ -106,7 +114,7 @@ class AppComponent extends AuthComponent { }); }; - checkMode = () => { + setMode = () => { return IslandHttpClient.get('/api/island-mode') .then(res => { this.setState({islandMode: res.body.mode}); @@ -126,9 +134,9 @@ class AppComponent extends AuthComponent { case false: switch (this.state.needsRegistration) { case true: - return + return case false: - return ; + return ; default: return ; } @@ -150,8 +158,7 @@ class AppComponent extends AuthComponent { needsRedirectionToGettingStarted = (route_path) => { return route_path === Routes.LandingPage && - this.state.islandMode !== null && - this.state.islandMode !== undefined + this.state.islandMode !== null } redirectTo = (userPath, targetPath) => { @@ -175,8 +182,8 @@ class AppComponent extends AuthComponent { - ()}/> - ()}/> + ()}/> + ()}/> {this.renderRoute(Routes.LandingPage, , true)} - {this.renderRoute('/configure', + {this.renderRoute(Routes.ConfigurePage, )} - {this.renderRoute('/run-monkey', + {this.renderRoute(Routes.RunMonkeyPage, )} - {this.renderRoute('/infection/map', + {this.renderRoute(Routes.MapPage, )} - {this.renderRoute('/infection/telemetry', + {this.renderRoute(Routes.TelemetryPage, )} - {this.renderRoute('/start-over', + {this.renderRoute(Routes.StartOverPage, )} - {this.redirectTo('/report', '/report/security')} - {this.renderRoute('/report/security', + {this.redirectTo(Routes.Report, Routes.SecurityReport)} + {this.renderRoute(Routes.SecurityReport, )} - {this.renderRoute('/report/attack', + {this.renderRoute(Routes.AttackReport, )} - {this.renderRoute('/report/zeroTrust', + {this.renderRoute(Routes.ZeroTrustReport, )} - {this.renderRoute('/report/ransomware', + {this.renderRoute(Routes.RansomwareReport, )} - {this.renderRoute('/license', + {this.renderRoute(Routes.LicensePage, )} @@ -251,7 +258,7 @@ class AppComponent extends AuthComponent { shouldShowNotification() { // No need to show the notification to redirect to the report if we're already in the report page - return (this.state.completedSteps.infection_done && !window.location.pathname.startsWith('/report')); + return (this.state.completedSteps.infection_done && !window.location.pathname.startsWith(Routes.Report)); } }