diff --git a/client/modules/IDE/actions/files.js b/client/modules/IDE/actions/files.js index ff56454a..0bbf292d 100644 --- a/client/modules/IDE/actions/files.js +++ b/client/modules/IDE/actions/files.js @@ -41,14 +41,7 @@ export function updateFileContent(id, content) { export function createFile(formProps) { return (dispatch, getState) => { const state = getState(); - const selectedFile = state.files.find(file => file.isSelectedFile); - const rootFile = state.files.find(file => file.name === 'root'); - let parentId; - if (selectedFile.fileType === 'folder') { - parentId = selectedFile.id; - } else { - parentId = rootFile.id; - } + const { parentId } = state.ide; if (state.project.id) { const postParams = { name: createUniqueName(formProps.name, parentId, state.files), @@ -99,14 +92,7 @@ export function createFile(formProps) { export function createFolder(formProps) { return (dispatch, getState) => { const state = getState(); - const selectedFile = state.files.find(file => file.isSelectedFile); - const rootFile = state.files.find(file => file.name === 'root'); - let parentId; - if (selectedFile.fileType === 'folder') { - parentId = selectedFile.id; - } else { - parentId = rootFile.id; - } + const { parentId } = state.ide; if (state.project.id) { const postParams = { name: createUniqueName(formProps.name, parentId, state.files), diff --git a/client/modules/IDE/actions/ide.js b/client/modules/IDE/actions/ide.js index 1d7c2998..b6351a7d 100644 --- a/client/modules/IDE/actions/ide.js +++ b/client/modules/IDE/actions/ide.js @@ -62,9 +62,10 @@ export function resetSelectedFile(previousId) { }; } -export function newFile() { +export function newFile(parentId) { return { - type: ActionTypes.SHOW_MODAL + type: ActionTypes.SHOW_MODAL, + parentId }; } @@ -122,9 +123,10 @@ export function closeProjectOptions() { }; } -export function newFolder() { +export function newFolder(parentId) { return { - type: ActionTypes.SHOW_NEW_FOLDER_MODAL + type: ActionTypes.SHOW_NEW_FOLDER_MODAL, + parentId }; } diff --git a/client/modules/IDE/components/FileNode.jsx b/client/modules/IDE/components/FileNode.jsx index 1b28bd4e..12496b38 100644 --- a/client/modules/IDE/components/FileNode.jsx +++ b/client/modules/IDE/components/FileNode.jsx @@ -188,7 +188,7 @@ export class FileNode extends React.Component {