diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2018-08-16 08:23:36 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-08-16 08:23:36 +0000 |
commit | 6ac7162395a2651b992cf8c25436e20fde92252d (patch) | |
tree | b89f6079bb98ec7d9ec236107bfcb7eaca9ef793 | |
parent | a2d647b1137821ef87fc177ac85ac775f2ce55c1 (diff) | |
parent | 177a5e69b6d7a5425f4869d200dccf6612890a74 (diff) | |
download | gitlab-ce-6ac7162395a2651b992cf8c25436e20fde92252d.tar.gz |
Merge branch 'ide-delete-new-files-state' into 'master'
Fixed deleting new files creating wrong state in IDE
Closes #50255
See merge request gitlab-org/gitlab-ce!21225
-rw-r--r-- | app/assets/javascripts/ide/stores/mutations.js | 7 | ||||
-rw-r--r-- | changelogs/unreleased/ide-delete-new-files-state.yml | 5 | ||||
-rw-r--r-- | spec/javascripts/ide/stores/mutations_spec.js | 27 |
3 files changed, 38 insertions, 1 deletions
diff --git a/app/assets/javascripts/ide/stores/mutations.js b/app/assets/javascripts/ide/stores/mutations.js index 1eda5768709..56a8d9430c7 100644 --- a/app/assets/javascripts/ide/stores/mutations.js +++ b/app/assets/javascripts/ide/stores/mutations.js @@ -200,6 +200,7 @@ export default { }, [types.DELETE_ENTRY](state, path) { const entry = state.entries[path]; + const { tempFile = false } = entry; const parent = entry.parentPath ? state.entries[entry.parentPath] : state.trees[`${state.currentProjectId}/${state.currentBranchId}`]; @@ -209,7 +210,11 @@ export default { parent.tree = parent.tree.filter(f => f.path !== entry.path); if (entry.type === 'blob') { - state.changedFiles = state.changedFiles.concat(entry); + if (tempFile) { + state.changedFiles = state.changedFiles.filter(f => f.path !== path); + } else { + state.changedFiles = state.changedFiles.concat(entry); + } } }, [types.RENAME_ENTRY](state, { path, name, entryPath = null }) { diff --git a/changelogs/unreleased/ide-delete-new-files-state.yml b/changelogs/unreleased/ide-delete-new-files-state.yml new file mode 100644 index 00000000000..500115d19d0 --- /dev/null +++ b/changelogs/unreleased/ide-delete-new-files-state.yml @@ -0,0 +1,5 @@ +--- +title: Fixed IDE deleting new files creating wrong state +merge_request: +author: +type: fixed diff --git a/spec/javascripts/ide/stores/mutations_spec.js b/spec/javascripts/ide/stores/mutations_spec.js index 1e836dbc3f9..6ce76aaa03b 100644 --- a/spec/javascripts/ide/stores/mutations_spec.js +++ b/spec/javascripts/ide/stores/mutations_spec.js @@ -213,6 +213,33 @@ describe('Multi-file store mutations', () => { expect(localState.changedFiles).toEqual([localState.entries.filePath]); }); + + it('does not add tempFile into changedFiles', () => { + localState.entries.filePath = { + deleted: false, + type: 'blob', + tempFile: true, + }; + + mutations.DELETE_ENTRY(localState, 'filePath'); + + expect(localState.changedFiles).toEqual([]); + }); + + it('removes tempFile from changedFiles when deleted', () => { + localState.entries.filePath = { + path: 'filePath', + deleted: false, + type: 'blob', + tempFile: true, + }; + + localState.changedFiles.push({ ...localState.entries.filePath }); + + mutations.DELETE_ENTRY(localState, 'filePath'); + + expect(localState.changedFiles).toEqual([]); + }); }); describe('UPDATE_FILE_AFTER_COMMIT', () => { |