diff --git a/client/modules/IDE/actions/projects.js b/client/modules/IDE/actions/projects.js index 43892453..fc6bfd91 100644 --- a/client/modules/IDE/actions/projects.js +++ b/client/modules/IDE/actions/projects.js @@ -1,5 +1,7 @@ import * as ActionTypes from '../../../constants'; import axios from 'axios'; +import { setPreviousPath } from './ide'; +import { resetProject } from './project'; import { showAuthenticationError } from './ide'; const ROOT_URL = location.href.indexOf('localhost') > 0 ? 'http://localhost:8000/api' : '/api'; @@ -27,9 +29,14 @@ export function getProjects(username) { } export function deleteProject(id) { - return (dispatch) => { + return (dispatch, getState) => { axios.delete(`${ROOT_URL}/projects/${id}`, { withCredentials: true }) .then(() => { + const state = getState(); + if (id === state.project.id) { + dispatch(resetProject()); + dispatch(setPreviousPath('/')); + } dispatch({ type: ActionTypes.DELETE_PROJECT, id