Commit 11e9339d authored by Dennis Tang's avatar Dennis Tang

fix number of form value bugs

parent 7db2ef36
...@@ -85,7 +85,7 @@ export default { ...@@ -85,7 +85,7 @@ export default {
fetchItems() { fetchItems() {
this.isLoading = true; this.isLoading = true;
const request = this.service.machineTypes.list({ const request = this.service.machineTypes.list({
project: this.$store.state.selectedProject, project: this.$store.state.selectedProject.projectId,
zone: this.$store.state.selectedZone, zone: this.$store.state.selectedZone,
}); });
...@@ -143,7 +143,7 @@ export default { ...@@ -143,7 +143,7 @@ export default {
> >
<dropdown-hidden-input <dropdown-hidden-input
:name="fieldName" :name="fieldName"
:value="$store.state.selectedProject" :value="$store.state.selectedMachineType"
/> />
<dropdown-button <dropdown-button
:class="{ 'gl-field-error-outline': hasErrors }" :class="{ 'gl-field-error-outline': hasErrors }"
......
...@@ -11,7 +11,6 @@ import DropdownHiddenInput from '~/vue_shared/components/dropdown/dropdown_hidde ...@@ -11,7 +11,6 @@ import DropdownHiddenInput from '~/vue_shared/components/dropdown/dropdown_hidde
import store from '../stores'; import store from '../stores';
import DropdownButton from './dropdown_button.vue'; import DropdownButton from './dropdown_button.vue';
// TODO: Consolidate dropdown code // TODO: Consolidate dropdown code
// TODO: Account for invalid project settings/errors (project returns error when retrieving zones)
export default { export default {
name: 'GkeProjectIdDropdown', name: 'GkeProjectIdDropdown',
...@@ -43,7 +42,6 @@ export default { ...@@ -43,7 +42,6 @@ export default {
}, },
data() { data() {
return { return {
isDisabled: false,
isLoading: true, isLoading: true,
hasErrors: false, hasErrors: false,
searchQuery: '', searchQuery: '',
...@@ -52,17 +50,24 @@ export default { ...@@ -52,17 +50,24 @@ export default {
}; };
}, },
computed: { computed: {
isDisabled() {
return this.items.length < 2;
},
results() { results() {
return this.items.filter(item => item.name.toLowerCase().indexOf(this.searchQuery) > -1); return this.items.filter(item => item.name.toLowerCase().indexOf(this.searchQuery) > -1);
}, },
toggleText() { toggleText() {
if (this.$store.state.selectedProject) { if (this.$store.state.selectedProject.name) {
return this.$store.state.selectedProject; return this.$store.state.selectedProject.name;
}
if (this.isLoading) {
return s__('ClusterIntegration|Fetching projects');
} }
return this.isLoading return this.items.length
? s__('ClusterIntegration|Fetching projects') ? s__('ClusterIntegration|Select project')
: s__('ClusterIntegration|Select project'); : s__('ClusterIntegration|No projects found');
}, },
placeholderText() { placeholderText() {
return s__('ClusterIntegration|Search projects'); return s__('ClusterIntegration|Search projects');
...@@ -102,26 +107,10 @@ export default { ...@@ -102,26 +107,10 @@ export default {
resp => { resp => {
this.items = resp.result.projects; this.items = resp.result.projects;
// Cause error this.isLoading = false;
// this.items = data;
// Single state
// this.items = [
// {
// create_time: '2018-01-16T15:55:02.992Z',
// lifecycle_state: 'ACTIVE',
// name: 'NaturalInterface',
// item_id: 'naturalinterface-192315',
// item_number: 840816084083,
// },
// ];
if (this.items.length === 1) { if (this.items.length === 1) {
this.isDisabled = true; this.setProject(this.items[0]);
this.setProject(this.items[0].name);
} }
this.isLoading = false;
}, },
resp => { resp => {
this.isLoading = false; this.isLoading = false;
...@@ -150,7 +139,7 @@ export default { ...@@ -150,7 +139,7 @@ export default {
> >
<dropdown-hidden-input <dropdown-hidden-input
:name="fieldName" :name="fieldName"
:value="$store.state.selectedProject" :value="$store.state.selectedProject.projectId"
/> />
<dropdown-button <dropdown-button
:class="{ 'gl-field-error-outline': hasErrors }" :class="{ 'gl-field-error-outline': hasErrors }"
...@@ -171,7 +160,7 @@ export default { ...@@ -171,7 +160,7 @@ export default {
> >
<a <a
href="#" href="#"
@click.prevent="setProject(result.name)" @click.prevent="setProject(result)"
>{{ result.name }}</a> >{{ result.name }}</a>
</li> </li>
</ul> </ul>
......
...@@ -76,7 +76,9 @@ export default { ...@@ -76,7 +76,9 @@ export default {
...mapActions(['setZone']), ...mapActions(['setZone']),
fetchItems() { fetchItems() {
this.isLoading = true; this.isLoading = true;
const request = this.service.zones.list({ project: this.$store.state.selectedProject }); const request = this.service.zones.list({
project: this.$store.state.selectedProject.projectId,
});
return request.then( return request.then(
resp => { resp => {
...@@ -129,7 +131,7 @@ export default { ...@@ -129,7 +131,7 @@ export default {
> >
<dropdown-hidden-input <dropdown-hidden-input
:name="fieldName" :name="fieldName"
:value="$store.state.selectedProject" :value="$store.state.selectedZone"
/> />
<dropdown-button <dropdown-button
:class="{ 'gl-field-error-outline': hasErrors }" :class="{ 'gl-field-error-outline': hasErrors }"
......
...@@ -11,7 +11,10 @@ export default new Vuex.Store({ ...@@ -11,7 +11,10 @@ export default new Vuex.Store({
getters, getters,
mutations, mutations,
state: { state: {
selectedProject: '', selectedProject: {
projectId: '',
name: '',
},
selectedZone: '', selectedZone: '',
selectedMachineType: '', selectedMachineType: '',
}, },
......
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