Commit c997c4cc authored by Dennis Tang's avatar Dennis Tang

use watchers instead of eventHub

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