Skip to content

Commit ff55aa7

Browse files
committed
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
1 parent 05dd7f9 commit ff55aa7

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

app/assets/javascripts/ide/stores/modules/file_templates/mutations.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default {
1313
},
1414
[types.SET_SELECTED_TEMPLATE_TYPE](state, type) {
1515
state.selectedTemplateType = type;
16+
state.templates = [];
1617
},
1718
[types.SET_UPDATE_SUCCESS](state, success) {
1819
state.updateSuccess = success;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: Clear fetched file templates when changing template type in Web IDE
3+
merge_request:
4+
author:
5+
type: fixed

spec/javascripts/ide/stores/modules/file_templates/mutations_spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ describe('IDE file templates mutations', () => {
4949

5050
expect(state.selectedTemplateType).toBe('type');
5151
});
52+
53+
it('clears templates', () => {
54+
state.templates = ['test'];
55+
56+
mutations[types.SET_SELECTED_TEMPLATE_TYPE](state, 'type');
57+
58+
expect(state.templates).toEqual([]);
59+
});
5260
});
5361

5462
describe(types.SET_UPDATE_SUCCESS, () => {

0 commit comments

Comments
 (0)