Skip to content

Commit

Permalink
fix: fix workspace update flow
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksii Orel <oorel@redhat.com>
  • Loading branch information
olexii4 committed Jun 24, 2021
1 parent 37f6166 commit e2142fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

import React from 'react';
import { Action, Store } from 'redux';
import { Store } from 'redux';
import { render, screen, RenderResult, fireEvent, waitFor } from '@testing-library/react';
import mockAxios from 'axios';
import SamplesListGallery from '../SamplesListGallery';
Expand Down
18 changes: 11 additions & 7 deletions src/store/Workspaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ import { Reducer } from 'redux';
import { AppThunk } from '../';
import { createState } from '../helpers';
import { IDevWorkspace, IDevWorkspaceDevfile } from '@eclipse-che/devworkspace-client';
import { convertWorkspace, isWorkspaceV2, isDevfileV2, Workspace } from '../../services/workspaceAdapter';
import {
convertWorkspace,
isWorkspaceV2,
isDevfileV2,
Workspace,
isWorkspaceV1,
} from '../../services/workspaceAdapter';
import * as CheWorkspacesStore from './cheWorkspaces';
import * as DevWorkspacesStore from './devWorkspaces';

Expand Down Expand Up @@ -213,15 +219,13 @@ export const actionCreators: ActionCreators = {
}
},

updateWorkspace: (workspace: Workspace): AppThunk<KnownAction, Promise<void>> => async (dispatch, getState): Promise<void> => {
updateWorkspace: (workspace: Workspace): AppThunk<KnownAction, Promise<void>> => async (dispatch): Promise<void> => {
dispatch({ type: 'REQUEST_WORKSPACES' });
try {
const state = getState();
const cheDevworkspaceEnabled = state.workspacesSettings.settings['che.devworkspaces.enabled'] === 'true';
if (cheDevworkspaceEnabled) {
await dispatch(DevWorkspacesStore.actionCreators.updateWorkspace(workspace.ref as IDevWorkspace));
} else {
if (isWorkspaceV1(workspace.ref)) {
await dispatch(CheWorkspacesStore.actionCreators.updateWorkspace(workspace.ref as che.Workspace));
} else {
await dispatch(DevWorkspacesStore.actionCreators.updateWorkspace(workspace.ref as IDevWorkspace));
}
dispatch({ type: 'UPDATE_WORKSPACE' });
} catch (e) {
Expand Down

0 comments on commit e2142fa

Please sign in to comment.