Commit f721c8b8 authored by Himanshu Kapoor's avatar Himanshu Kapoor

Fix console error on discarding new files

In Web IDE, when you "discard all changes" for any newly added
or uploaded file, an error occurs. This is because the Web IDE tries to
close that file, but the closeFile action is called with the wrong type
of parameter.
parent 8a6ea16a
...@@ -20,7 +20,7 @@ export const discardAllChanges = ({ state, commit, dispatch }) => { ...@@ -20,7 +20,7 @@ export const discardAllChanges = ({ state, commit, dispatch }) => {
commit(types.DISCARD_FILE_CHANGES, file.path); commit(types.DISCARD_FILE_CHANGES, file.path);
if (file.tempFile) { if (file.tempFile) {
dispatch('closeFile', file.path); dispatch('closeFile', file);
} }
}); });
......
---
title: "Web IDE: Fix the console error that happens when discarding a newly added/uploaded file."
merge_request: 21537
author:
type: fixed
...@@ -12,6 +12,7 @@ import actions, { ...@@ -12,6 +12,7 @@ import actions, {
renameEntry, renameEntry,
getBranchData, getBranchData,
createTempEntry, createTempEntry,
discardAllChanges,
} from '~/ide/stores/actions'; } from '~/ide/stores/actions';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { createStore } from '~/ide/stores'; import { createStore } from '~/ide/stores';
...@@ -60,8 +61,9 @@ describe('Multi-file store actions', () => { ...@@ -60,8 +61,9 @@ describe('Multi-file store actions', () => {
}); });
describe('discardAllChanges', () => { describe('discardAllChanges', () => {
let f;
beforeEach(() => { beforeEach(() => {
const f = file('discardAll'); f = file('discardAll');
f.changed = true; f.changed = true;
store.state.openFiles.push(f); store.state.openFiles.push(f);
...@@ -89,6 +91,27 @@ describe('Multi-file store actions', () => { ...@@ -89,6 +91,27 @@ describe('Multi-file store actions', () => {
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
}); });
it('closes the temp file if it was open', done => {
f.tempFile = true;
testAction(
discardAllChanges,
undefined,
store.state,
[
{ type: types.DISCARD_FILE_CHANGES, payload: 'discardAll' },
{ type: types.REMOVE_ALL_CHANGES_FILES },
],
[
{
type: 'closeFile',
payload: jasmine.objectContaining({ path: 'discardAll' }),
},
],
done,
);
});
}); });
describe('closeAllFiles', () => { describe('closeAllFiles', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment