Fixed file templates not clearing in Web IDE

This fixes a bug where the file templates would not be cleared
after changing the template type.
Previously the templates would get pushed into the array
creating a list of templates for the different types.
This changes that by clearing the templates array
when the template type gets changed.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/52487
This commit is contained in:
Phil Hughes 2018-10-15 10:02:40 +01:00
parent 05dd7f9718
commit ff55aa7ebb
No known key found for this signature in database
GPG key ID: 32245528C52E0F9F
3 changed files with 14 additions and 0 deletions

View file

@ -13,6 +13,7 @@ export default {
},
[types.SET_SELECTED_TEMPLATE_TYPE](state, type) {
state.selectedTemplateType = type;
state.templates = [];
},
[types.SET_UPDATE_SUCCESS](state, success) {
state.updateSuccess = success;

View file

@ -0,0 +1,5 @@
---
title: Clear fetched file templates when changing template type in Web IDE
merge_request:
author:
type: fixed

View file

@ -49,6 +49,14 @@ describe('IDE file templates mutations', () => {
expect(state.selectedTemplateType).toBe('type');
});
it('clears templates', () => {
state.templates = ['test'];
mutations[types.SET_SELECTED_TEMPLATE_TYPE](state, 'type');
expect(state.templates).toEqual([]);
});
});
describe(types.SET_UPDATE_SUCCESS, () => {