diff --git a/monkey/monkey_island/cc/ui/src/components/Main.tsx b/monkey/monkey_island/cc/ui/src/components/Main.tsx
index 0727b3e70..3d41c8b54 100644
--- a/monkey/monkey_island/cc/ui/src/components/Main.tsx
+++ b/monkey/monkey_island/cc/ui/src/components/Main.tsx
@@ -79,25 +79,26 @@ class AppComponent extends AuthComponent {
if (res) {
this.checkMode()
.then(() => {
- if(this.state.islandMode === null) {
- return
- }
- this.authFetch('/api')
- .then(res => res.json())
- .then(res => {
- // This check is used to prevent unnecessary re-rendering
- let isChanged = false;
- for (let step in this.state.completedSteps) {
- if (this.state.completedSteps[step] !== res['completed_steps'][step]) {
- isChanged = true;
- break;
+ if (this.state.islandMode === null) {
+ return
+ }
+ this.authFetch('/api')
+ .then(res => res.json())
+ .then(res => {
+ // This check is used to prevent unnecessary re-rendering
+ let isChanged = false;
+ for (let step in this.state.completedSteps) {
+ if (this.state.completedSteps[step] !== res['completed_steps'][step]) {
+ isChanged = true;
+ break;
+ }
}
- }
- if (isChanged) {
- this.setState({completedSteps: res['completed_steps']});
- this.showInfectionDoneNotification();
- }
- });}
+ if (isChanged) {
+ this.setState({completedSteps: res['completed_steps']});
+ this.showInfectionDoneNotification();
+ }
+ });
+ }
)
}
@@ -115,9 +116,9 @@ class AppComponent extends AuthComponent {
let render_func = () => {
switch (this.state.isLoggedIn) {
case true:
- if (this.state.islandMode === null && route_path !== Routes.LandingPage) {
+ if (this.needsRedirectionToLandingPage(route_path)) {
return
- } else if(route_path === Routes.LandingPage && this.state.islandMode !== null){
+ } else if (this.needsRedirectionToGettingStarted(route_path)) {
return
}
return page_component;
@@ -142,6 +143,16 @@ class AppComponent extends AuthComponent {
}
};
+ needsRedirectionToLandingPage = (route_path) => {
+ return (this.state.islandMode === null && route_path !== Routes.LandingPage)
+ }
+
+ needsRedirectionToGettingStarted = (route_path) => {
+ return route_path === Routes.LandingPage &&
+ this.state.islandMode !== null &&
+ this.state.islandMode !== undefined
+ }
+
redirectTo = (userPath, targetPath) => {
let pathQuery = new RegExp(userPath + '[/]?$', 'g');
if (window.location.pathname.match(pathQuery)) {