BigW Consortium Gitlab

Commit c997c4cc by Dennis Tang

use watchers instead of eventHub

parent e73da567
......@@ -7,7 +7,6 @@ import DropdownSearchInput from '~/vue_shared/components/dropdown/dropdown_searc
import DropdownHiddenInput from '~/vue_shared/components/dropdown/dropdown_hidden_input.vue';
import DropdownButton from '~/vue_shared/components/dropdown/dropdown_button.vue';
import eventHub from '../eventhub';
import store from '../stores';
export default {
......@@ -79,9 +78,13 @@ export default {
return s__('ClusterIntegration|No machine types matched your search');
},
},
created() {
eventHub.$on('zoneSelected', this.fetchMachineTypes);
eventHub.$on('machineTypeSelected', this.enableSubmit);
watch: {
selectedZone() {
this.fetchMachineTypes();
},
selectedMachineType() {
this.enableSubmit();
},
},
methods: {
...mapActions(['setMachineType', 'getMachineTypes']),
......
......@@ -7,7 +7,6 @@ import DropdownSearchInput from '~/vue_shared/components/dropdown/dropdown_searc
import DropdownHiddenInput from '~/vue_shared/components/dropdown/dropdown_hidden_input.vue';
import DropdownButton from '~/vue_shared/components/dropdown/dropdown_button.vue';
import eventHub from '../eventhub';
import store from '../stores';
export default {
......@@ -70,8 +69,10 @@ export default {
return s__('ClusterIntegration|No zones matched your search');
},
},
created() {
eventHub.$on('projectSelected', this.fetchZones);
watch: {
selectedProject() {
this.fetchZones();
},
},
methods: {
...mapActions(['setZone', 'getZones']),
......
......@@ -3,24 +3,17 @@ import Flash from '~/flash';
import { s__, sprintf } from '~/locale';
import * as types from './mutation_types';
import eventHub from '../eventhub';
export const setProject = ({ commit }, selectedProject) => {
commit(types.SET_PROJECT, selectedProject);
eventHub.$emit('projectSelected');
};
export const setZone = ({ commit }, selectedZone) => {
commit(types.SET_ZONE, selectedZone);
eventHub.$emit('zoneSelected');
};
export const setMachineType = ({ commit }, selectedMachineType) => {
commit(types.SET_MACHINE_TYPE, selectedMachineType);
eventHub.$emit('machineTypeSelected');
};
export const getProjects = ({ commit }) =>
......
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