Skip to content

Commit

Permalink
Use location build functions, check if workspace is actually running
Browse files Browse the repository at this point in the history
Signed-off-by: David Kwon <dakwon@redhat.com>
  • Loading branch information
dkwon17 committed Jun 15, 2022
1 parent 50abe80 commit 4a4d43c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/dashboard-frontend/src/services/bootstrap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ import { selectDevWorkspacesResourceVersion } from '../../store/Workspaces/devWo
import { AppAlerts } from '../alerts/appAlerts';
import { AlertVariant } from '@patternfly/react-core';
import SessionStorageService, { SessionStorageKey } from '../session-storage';
import { ROUTE } from '../../route.enum';
import { buildDetailsLocation, buildIdeLoaderLocation } from '../helpers/location';
import { selectAllWorkspaces } from '../../store/Workspaces/selectors';

/**
* This class executes a few initial instructions
Expand Down Expand Up @@ -278,20 +279,19 @@ export default class Bootstrap {
}

const state = this.store.getState();
const workspace = state.devWorkspaces.workspaces.find(w => w.status?.mainUrl?.includes(path));

const workspace = selectAllWorkspaces(state).find(w => w.ideUrl?.includes(path));
if (!workspace) {
return;
}

const ideLoader = ROUTE.IDE_LOADER.replace(':namespace', workspace.metadata.namespace).replace(
':workspaceName',
workspace.metadata.name,
);
if (workspace.isRunning) {
window.location.href = workspace.ideUrl!;
return;
}

const workspaceDetails = ROUTE.WORKSPACE_DETAILS.replace(
':namespace',
workspace.metadata.namespace,
).replace(':workspaceName', workspace.metadata.name);
const ideLoader = buildIdeLoaderLocation(workspace).pathname;
const workspaceDetails = buildDetailsLocation(workspace).pathname;

this.issuesReporterService.registerIssue<WorkspaceRoutes>(
'workspaceStopped',
Expand Down

0 comments on commit 4a4d43c

Please sign in to comment.