Commit 3a283fa8 authored by Phil Hughes's avatar Phil Hughes

Enabled multiple uploads in the Web IDE

Closes #50405
parent 42523a41
...@@ -24,12 +24,6 @@ export default { ...@@ -24,12 +24,6 @@ export default {
default: null, default: null,
}, },
}, },
mounted() {
this.$refs.fileUpload.addEventListener('change', this.openFile);
},
beforeDestroy() {
this.$refs.fileUpload.removeEventListener('change', this.openFile);
},
methods: { methods: {
createFile(target, file, isText) { createFile(target, file, isText) {
const { name } = file; const { name } = file;
...@@ -85,6 +79,8 @@ export default { ...@@ -85,6 +79,8 @@ export default {
ref="fileUpload" ref="fileUpload"
type="file" type="file"
class="hidden" class="hidden"
multiple
@change="openFile"
/> />
</div> </div>
</template> </template>
---
title: Enabled multiple file uploads in the Web IDE
merge_request:
author:
type: added
...@@ -21,6 +21,23 @@ describe('new dropdown upload', () => { ...@@ -21,6 +21,23 @@ describe('new dropdown upload', () => {
vm.$destroy(); vm.$destroy();
}); });
describe('openFile', () => {
it('calls for each file', () => {
const files = ['test', 'test2', 'test3'];
spyOn(vm, 'readFile');
spyOnProperty(vm.$refs.fileUpload, 'files').and.returnValue(files);
vm.openFile();
expect(vm.readFile.calls.count()).toBe(3);
files.forEach((file, i) => {
expect(vm.readFile.calls.argsFor(i)).toEqual([file]);
});
});
});
describe('readFile', () => { describe('readFile', () => {
beforeEach(() => { beforeEach(() => {
spyOn(FileReader.prototype, 'readAsText'); spyOn(FileReader.prototype, 'readAsText');
......
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