diff options
Diffstat (limited to 'app/assets/javascripts/ide/stores/actions.js')
-rw-r--r-- | app/assets/javascripts/ide/stores/actions.js | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/app/assets/javascripts/ide/stores/actions.js b/app/assets/javascripts/ide/stores/actions.js index 2765acada48..aa02dfbddc4 100644 --- a/app/assets/javascripts/ide/stores/actions.js +++ b/app/assets/javascripts/ide/stores/actions.js @@ -186,13 +186,39 @@ export const openNewEntryModal = ({ commit }, { type, path = '' }) => { }; export const deleteEntry = ({ commit, dispatch, state }, path) => { - dispatch('burstUnusedSeal'); - dispatch('closeFile', state.entries[path]); + const entry = state.entries[path]; + + if (state.unusedSeal) dispatch('burstUnusedSeal'); + if (entry.opened) dispatch('closeFile', entry); + + if (entry.type === 'tree') { + entry.tree.forEach(f => dispatch('deleteEntry', f.path)); + } + commit(types.DELETE_ENTRY, path); + + if (entry.parentPath && state.entries[entry.parentPath].tree.length === 0) { + dispatch('deleteEntry', entry.parentPath); + } }; export const resetOpenFiles = ({ commit }) => commit(types.RESET_OPEN_FILES); +export const renameEntry = ({ dispatch, commit, state }, { path, name, entryPath = null }) => { + const entry = state.entries[entryPath || path]; + commit(types.RENAME_ENTRY, { path, name, entryPath }); + + if (entry.type === 'tree') { + state.entries[entryPath || path].tree.forEach(f => + dispatch('renameEntry', { path, name, entryPath: f.path }), + ); + } + + if (!entryPath) { + dispatch('deleteEntry', path); + } +}; + export * from './actions/tree'; export * from './actions/file'; export * from './actions/project'; |