Commit b45714db authored by Dennis Tang's avatar Dennis Tang

cleanup

parent e33c4458
...@@ -3,11 +3,17 @@ import _ from 'underscore'; ...@@ -3,11 +3,17 @@ import _ from 'underscore';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { mapState, mapGetters, mapActions } from 'vuex'; import { mapState, mapGetters, mapActions } from 'vuex';
import gcpDropdownMixin from './gcp_dropdown_mixin'; import gkeDropdownMixin from './gke_dropdown_mixin';
export default { export default {
name: 'GkeMachineTypeDropdown', name: 'GkeMachineTypeDropdown',
mixins: [gcpDropdownMixin], mixins: [gkeDropdownMixin],
data() {
return {
searchPlaceholderText: s__('ClusterIntegration|Search machine types'),
noSearchResultsText: s__('ClusterIntegration|No machine types matched your search'),
};
},
computed: { computed: {
...mapState(['selectedProject', 'selectedZone', 'selectedMachineType']), ...mapState(['selectedProject', 'selectedZone', 'selectedMachineType']),
...mapState({ items: 'machineTypes' }), ...mapState({ items: 'machineTypes' }),
...@@ -35,12 +41,6 @@ export default { ...@@ -35,12 +41,6 @@ export default {
? s__('ClusterIntegration|Select zone to choose machine type') ? s__('ClusterIntegration|Select zone to choose machine type')
: s__('ClusterIntegration|Select machine type'); : s__('ClusterIntegration|Select machine type');
}, },
searchPlaceholderText() {
return s__('ClusterIntegration|Search machine types');
},
noSearchResultsText() {
return s__('ClusterIntegration|No machine types matched your search');
},
}, },
watch: { watch: {
selectedZone() { selectedZone() {
......
...@@ -3,11 +3,11 @@ import _ from 'underscore'; ...@@ -3,11 +3,11 @@ import _ from 'underscore';
import { s__, sprintf } from '~/locale'; import { s__, sprintf } from '~/locale';
import { mapState, mapGetters, mapActions } from 'vuex'; import { mapState, mapGetters, mapActions } from 'vuex';
import gcpDropdownMixin from './gcp_dropdown_mixin'; import gkeDropdownMixin from './gke_dropdown_mixin';
export default { export default {
name: 'GkeProjectIdDropdown', name: 'GkeProjectIdDropdown',
mixins: [gcpDropdownMixin], mixins: [gkeDropdownMixin],
props: { props: {
docsUrl: { docsUrl: {
type: String, type: String,
...@@ -17,6 +17,8 @@ export default { ...@@ -17,6 +17,8 @@ export default {
data() { data() {
return { return {
isLoading: true, isLoading: true,
searchPlaceholderText: s__('ClusterIntegration|Search projects'),
noSearchResultsText: s__('ClusterIntegration|No projects matched your search'),
}; };
}, },
computed: { computed: {
...@@ -29,9 +31,6 @@ export default { ...@@ -29,9 +31,6 @@ export default {
isDisabled() { isDisabled() {
return this.items.length < 2; return this.items.length < 2;
}, },
noSearchResultsText() {
return s__('ClusterIntegration|No projects matched your search');
},
toggleText() { toggleText() {
if (this.isLoading) { if (this.isLoading) {
return s__('ClusterIntegration|Fetching projects'); return s__('ClusterIntegration|Fetching projects');
...@@ -45,9 +44,6 @@ export default { ...@@ -45,9 +44,6 @@ export default {
? s__('ClusterIntegration|No projects found') ? s__('ClusterIntegration|No projects found')
: s__('ClusterIntegration|Select project'); : s__('ClusterIntegration|Select project');
}, },
searchPlaceholderText() {
return s__('ClusterIntegration|Search projects');
},
helpText() { helpText() {
let message; let message;
if (this.hasErrors) { if (this.hasErrors) {
...@@ -73,7 +69,13 @@ export default { ...@@ -73,7 +69,13 @@ export default {
}, },
created() { created() {
this.getProjects() this.getProjects()
.then(() => { .then(this.fetchSuccessHandler)
.catch(this.fetchFailureHandler);
},
methods: {
...mapActions(['getProjects']),
...mapActions({ setItem: 'setProject' }),
fetchSuccessHandler() {
if (this.defaultValue) { if (this.defaultValue) {
const projectToSelect = _.find(this.items, item => item.projectId === this.defaultValue); const projectToSelect = _.find(this.items, item => item.projectId === this.defaultValue);
...@@ -86,12 +88,7 @@ export default { ...@@ -86,12 +88,7 @@ export default {
this.isLoading = false; this.isLoading = false;
this.hasErrors = false; this.hasErrors = false;
})
.catch(this.fetchFailureHandler);
}, },
methods: {
...mapActions(['getProjects']),
...mapActions({ setItem: 'setProject' }),
}, },
}; };
</script> </script>
......
...@@ -2,11 +2,17 @@ ...@@ -2,11 +2,17 @@
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { mapState, mapGetters, mapActions } from 'vuex'; import { mapState, mapGetters, mapActions } from 'vuex';
import gcpDropdownMixin from './gcp_dropdown_mixin'; import gkeDropdownMixin from './gke_dropdown_mixin';
export default { export default {
name: 'GkeZoneDropdown', name: 'GkeZoneDropdown',
mixins: [gcpDropdownMixin], mixins: [gkeDropdownMixin],
data() {
return {
searchPlaceholderText: s__('ClusterIntegration|Search zones'),
noSearchResultsText: s__('ClusterIntegration|No zones matched your search'),
};
},
computed: { computed: {
...mapState(['selectedProject', 'selectedZone']), ...mapState(['selectedProject', 'selectedZone']),
...mapState({ items: 'zones' }), ...mapState({ items: 'zones' }),
...@@ -27,12 +33,6 @@ export default { ...@@ -27,12 +33,6 @@ export default {
? s__('ClusterIntegration|Select project to choose zone') ? s__('ClusterIntegration|Select project to choose zone')
: s__('ClusterIntegration|Select zone'); : s__('ClusterIntegration|Select zone');
}, },
searchPlaceholderText() {
return s__('ClusterIntegration|Search zones');
},
noSearchResultsText() {
return s__('ClusterIntegration|No zones matched your search');
},
}, },
watch: { watch: {
selectedProject() { selectedProject() {
......
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