Commit 21ed2da0 authored by Phil Hughes's avatar Phil Hughes

fixed double scroll

improved variable & prop names
parent 3f650038
...@@ -27,14 +27,14 @@ export default { ...@@ -27,14 +27,14 @@ export default {
'undoFileTemplate', 'undoFileTemplate',
]), ]),
setInitialType() { setInitialType() {
const type = this.templateTypes.find(t => t.name === this.activeFile.name); const initialTemplateType = this.templateTypes.find(t => t.name === this.activeFile.name);
if (type) { if (initialTemplateType) {
this.setSelectedTemplateType(type); this.setSelectedTemplateType(initialTemplateType);
} }
}, },
selectTemplateType(type) { selectTemplateType(templateType) {
this.setSelectedTemplateType(type); this.setSelectedTemplateType(templateType);
}, },
selectTemplate(template) { selectTemplate(template) {
this.fetchTemplate(template); this.fetchTemplate(template);
...@@ -60,7 +60,7 @@ export default { ...@@ -60,7 +60,7 @@ export default {
<dropdown <dropdown
v-if="showTemplatesDropdown" v-if="showTemplatesDropdown"
:label="__('Choose a template...')" :label="__('Choose a template...')"
:async="true" :is-async-data="true"
:searchable="true" :searchable="true"
:title="__('File templates')" :title="__('File templates')"
class="mr-2" class="mr-2"
......
...@@ -24,7 +24,7 @@ export default { ...@@ -24,7 +24,7 @@ export default {
required: false, required: false,
default: null, default: null,
}, },
async: { isAsyncData: {
type: Boolean, type: Boolean,
required: false, required: false,
default: false, default: false,
...@@ -43,14 +43,14 @@ export default { ...@@ -43,14 +43,14 @@ export default {
computed: { computed: {
...mapState('fileTemplates', ['templates', 'isLoading']), ...mapState('fileTemplates', ['templates', 'isLoading']),
outputData() { outputData() {
return (this.async ? this.templates : this.data).filter(t => { return (this.isAsyncData ? this.templates : this.data).filter(t => {
if (!this.searchable) return true; if (!this.searchable) return true;
return t.name.toLowerCase().indexOf(this.search.toLowerCase()) >= 0; return t.name.toLowerCase().indexOf(this.search.toLowerCase()) >= 0;
}); });
}, },
showLoading() { showLoading() {
return this.async ? this.isLoading : false; return this.isAsyncData ? this.isLoading : false;
}, },
}, },
mounted() { mounted() {
...@@ -62,7 +62,7 @@ export default { ...@@ -62,7 +62,7 @@ export default {
methods: { methods: {
...mapActions('fileTemplates', ['fetchTemplateTypes']), ...mapActions('fileTemplates', ['fetchTemplateTypes']),
fetchTemplatesIfAsync() { fetchTemplatesIfAsync() {
if (this.async) { if (this.isAsyncData) {
this.fetchTemplateTypes(); this.fetchTemplateTypes();
} }
}, },
...@@ -79,7 +79,7 @@ export default { ...@@ -79,7 +79,7 @@ export default {
:toggle-text="label" :toggle-text="label"
data-display="static" data-display="static"
/> />
<div class="dropdown-menu"> <div class="dropdown-menu pb-0">
<div <div
v-if="title" v-if="title"
class="dropdown-title ml-0 mr-0" class="dropdown-title ml-0 mr-0"
......
...@@ -1452,8 +1452,7 @@ $ide-tree-text-start: $ide-activity-bar-width + $ide-tree-padding; ...@@ -1452,8 +1452,7 @@ $ide-tree-text-start: $ide-activity-bar-width + $ide-tree-padding;
min-width: 180px; min-width: 180px;
} }
.dropdown-menu { .dropdown-content {
max-height: 222px; max-height: 222px;
overflow: hidden;
} }
} }
...@@ -98,14 +98,16 @@ describe('IDE file templates bar component', () => { ...@@ -98,14 +98,16 @@ describe('IDE file templates bar component', () => {
}); });
it('calls setSelectedTemplateType if activeFile name matches a template', done => { it('calls setSelectedTemplateType if activeFile name matches a template', done => {
const fileName = '.gitlab-ci.yml';
spyOn(vm, 'setSelectedTemplateType'); spyOn(vm, 'setSelectedTemplateType');
vm.$store.state.openFiles[0].name = '.gitlab-ci.yml'; vm.$store.state.openFiles[0].name = fileName;
vm.setInitialType(); vm.setInitialType();
vm.$nextTick(() => { vm.$nextTick(() => {
expect(vm.setSelectedTemplateType).toHaveBeenCalledWith({ expect(vm.setSelectedTemplateType).toHaveBeenCalledWith({
name: '.gitlab-ci.yml', name: fileName,
key: 'gitlab_ci_ymls', key: 'gitlab_ci_ymls',
}); });
......
...@@ -28,7 +28,7 @@ describe('IDE file templates dropdown component', () => { ...@@ -28,7 +28,7 @@ describe('IDE file templates dropdown component', () => {
describe('async', () => { describe('async', () => {
beforeEach(() => { beforeEach(() => {
vm.async = true; vm.isAsyncData = true;
}); });
it('calls async store method on Bootstrap dropdown event', () => { it('calls async store method on Bootstrap dropdown event', () => {
......
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