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 }) => {
commit(types.DISCARD_FILE_CHANGES, file.path);
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, {
renameEntry,
getBranchData,
createTempEntry,
discardAllChanges,
} from '~/ide/stores/actions';
import axios from '~/lib/utils/axios_utils';
import { createStore } from '~/ide/stores';
......@@ -60,8 +61,9 @@ describe('Multi-file store actions', () => {
});
describe('discardAllChanges', () => {
let f;
beforeEach(() => {
const f = file('discardAll');
f = file('discardAll');
f.changed = true;
store.state.openFiles.push(f);
......@@ -89,6 +91,27 @@ describe('Multi-file store actions', () => {
.then(done)
.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', () => {
......
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