diff options
author | Phil Hughes <me@iamphill.com> | 2018-07-26 14:56:56 +0000 |
---|---|---|
committer | Tim Zallmann <tzallmann@gitlab.com> | 2018-07-26 14:56:56 +0000 |
commit | cded268ca1d49fe93b8e0940586e9792347c88c3 (patch) | |
tree | 9d84a5e8ae38e53514b6ab1f4e99d38ddf2fe138 /app/assets/javascripts/ide/stores/actions | |
parent | 8873840839811948b2f29175177b91bcf806a3f8 (diff) | |
download | gitlab-ce-cded268ca1d49fe93b8e0940586e9792347c88c3.tar.gz |
Enable deleting files in the Web IDE
Diffstat (limited to 'app/assets/javascripts/ide/stores/actions')
-rw-r--r-- | app/assets/javascripts/ide/stores/actions/file.js | 8 | ||||
-rw-r--r-- | app/assets/javascripts/ide/stores/actions/tree.js | 6 |
2 files changed, 8 insertions, 6 deletions
diff --git a/app/assets/javascripts/ide/stores/actions/file.js b/app/assets/javascripts/ide/stores/actions/file.js index 6c0887e11ee..b343750f789 100644 --- a/app/assets/javascripts/ide/stores/actions/file.js +++ b/app/assets/javascripts/ide/stores/actions/file.js @@ -61,7 +61,11 @@ export const setFileActive = ({ commit, state, getters, dispatch }, path) => { export const getFileData = ({ state, commit, dispatch }, { path, makeFileActive = true }) => { const file = state.entries[path]; + + if (file.raw || file.tempFile) return Promise.resolve(); + commit(types.TOGGLE_LOADING, { entry: file }); + return service .getFileData( `${gon.relative_url_root ? gon.relative_url_root : ''}${file.url.replace('/-/', '/')}`, @@ -71,7 +75,7 @@ export const getFileData = ({ state, commit, dispatch }, { path, makeFileActive setPageTitle(decodeURI(normalizedHeaders['PAGE-TITLE'])); commit(types.SET_FILE_DATA, { data, file }); - commit(types.TOGGLE_FILE_OPEN, path); + if (makeFileActive) commit(types.TOGGLE_FILE_OPEN, path); if (makeFileActive) dispatch('setFileActive', path); commit(types.TOGGLE_LOADING, { entry: file }); }) @@ -97,7 +101,7 @@ export const getRawFileData = ({ state, commit, dispatch }, { path, baseSha }) = service .getRawFileData(file) .then(raw => { - commit(types.SET_FILE_RAW_DATA, { file, raw }); + if (!file.tempFile) commit(types.SET_FILE_RAW_DATA, { file, raw }); if (file.mrChange && file.mrChange.new_file === false) { service .getBaseRawFileData(file, baseSha) diff --git a/app/assets/javascripts/ide/stores/actions/tree.js b/app/assets/javascripts/ide/stores/actions/tree.js index ffaaaabff17..acb6ef5e6d4 100644 --- a/app/assets/javascripts/ide/stores/actions/tree.js +++ b/app/assets/javascripts/ide/stores/actions/tree.js @@ -21,14 +21,12 @@ export const showTreeEntry = ({ commit, dispatch, state }, path) => { export const handleTreeEntryAction = ({ commit, dispatch }, row) => { if (row.type === 'tree') { dispatch('toggleTreeOpen', row.path); - } else if (row.type === 'blob' && (row.opened || row.changed)) { - if (row.changed && !row.opened) { + } else if (row.type === 'blob') { + if (!row.opened) { commit(types.TOGGLE_FILE_OPEN, row.path); } dispatch('setFileActive', row.path); - } else { - dispatch('getFileData', { path: row.path }); } dispatch('showTreeEntry', row.path); |