summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-10-15 10:02:40 +0100
committerPhil Hughes <me@iamphill.com>2018-10-15 10:02:40 +0100
commitff55aa7ebb8a54e5dceee845904a8c75b46b3f1b (patch)
tree08043dbad20b1742f79089825fdbdc23a3120d11
parent05dd7f9718cdd74cfd20747e4bea534a1cba2ae1 (diff)
downloadgitlab-ce-ff55aa7ebb8a54e5dceee845904a8c75b46b3f1b.tar.gz
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
-rw-r--r--app/assets/javascripts/ide/stores/modules/file_templates/mutations.js1
-rw-r--r--changelogs/unreleased/ide-file-templates-clear.yml5
-rw-r--r--spec/javascripts/ide/stores/modules/file_templates/mutations_spec.js8
3 files changed, 14 insertions, 0 deletions
diff --git a/app/assets/javascripts/ide/stores/modules/file_templates/mutations.js b/app/assets/javascripts/ide/stores/modules/file_templates/mutations.js
index d519c033769..25a65b047f1 100644
--- a/app/assets/javascripts/ide/stores/modules/file_templates/mutations.js
+++ b/app/assets/javascripts/ide/stores/modules/file_templates/mutations.js
@@ -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;
diff --git a/changelogs/unreleased/ide-file-templates-clear.yml b/changelogs/unreleased/ide-file-templates-clear.yml
new file mode 100644
index 00000000000..7878f2231a7
--- /dev/null
+++ b/changelogs/unreleased/ide-file-templates-clear.yml
@@ -0,0 +1,5 @@
+---
+title: Clear fetched file templates when changing template type in Web IDE
+merge_request:
+author:
+type: fixed
diff --git a/spec/javascripts/ide/stores/modules/file_templates/mutations_spec.js b/spec/javascripts/ide/stores/modules/file_templates/mutations_spec.js
index a51527d699f..8e0e3ae99a1 100644
--- a/spec/javascripts/ide/stores/modules/file_templates/mutations_spec.js
+++ b/spec/javascripts/ide/stores/modules/file_templates/mutations_spec.js
@@ -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, () => {