summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/create_cluster/gke_cluster/components/gke_subnetwork_dropdown.vue
blob: dab4adc378911b7b65db9207c6a6c26b3318b0a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<script>
import { createNamespacedHelpers, mapState, mapGetters, mapActions } from 'vuex';

import ClusterFormDropdown from '~/create_cluster/components/cluster_form_dropdown.vue';

const { mapState: mapDropdownState } = createNamespacedHelpers('subnetworks');

export default {
  components: {
    ClusterFormDropdown,
  },
  props: {
    fieldName: {
      type: String,
      required: true,
    },
  },
  computed: {
    ...mapState(['selectedSubnetwork']),
    ...mapDropdownState(['items', 'isLoadingItems', 'loadingItemsError']),
    ...mapGetters(['hasNetwork']),
  },
  methods: {
    ...mapActions(['setSubnetwork']),
  },
};
</script>
<template>
  <cluster-form-dropdown
    :field-name="fieldName"
    :value="selectedSubnetwork"
    :items="items"
    :disabled="!hasNetwork"
    :loading="isLoadingItems"
    :has-errors="Boolean(loadingItemsError)"
    :loading-text="s__('ClusterIntegration|Loading subnetworks')"
    :placeholder="s__('ClusterIntegration|Select a subnetwork')"
    :search-field-placeholder="s__('ClusterIntegration|Search subnetworks')"
    :empty-text="s__('ClusterIntegration|No subnetworks found')"
    :error-message="s__('ClusterIntegration|Could not load subnetworks')"
    :disabled-text="s__('ClusterIntegration|Select a network to choose a subnetwork')"
    @input="setSubnetwork"
  />
</template>