diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /app/assets/javascripts/create_cluster | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/assets/javascripts/create_cluster')
7 files changed, 75 insertions, 81 deletions
diff --git a/app/assets/javascripts/create_cluster/eks_cluster/components/eks_cluster_configuration_form.vue b/app/assets/javascripts/create_cluster/eks_cluster/components/eks_cluster_configuration_form.vue index d403f370f9d..2858561e033 100644 --- a/app/assets/javascripts/create_cluster/eks_cluster/components/eks_cluster_configuration_form.vue +++ b/app/assets/javascripts/create_cluster/eks_cluster/components/eks_cluster_configuration_form.vue @@ -1,15 +1,12 @@ <script> import { createNamespacedHelpers, mapState, mapActions, mapGetters } from 'vuex'; -import { GlFormInput, GlFormCheckbox, GlIcon, GlLink, GlSprintf } from '@gitlab/ui'; +import { GlFormGroup, GlFormInput, GlFormCheckbox, GlIcon, GlLink, GlSprintf } from '@gitlab/ui'; import { s__ } from '~/locale'; import ClusterFormDropdown from '~/create_cluster/components/cluster_form_dropdown.vue'; import { KUBERNETES_VERSIONS } from '../constants'; import LoadingButton from '~/vue_shared/components/loading_button.vue'; const { mapState: mapRolesState, mapActions: mapRolesActions } = createNamespacedHelpers('roles'); -const { mapState: mapRegionsState, mapActions: mapRegionsActions } = createNamespacedHelpers( - 'regions', -); const { mapState: mapKeyPairsState, mapActions: mapKeyPairsActions } = createNamespacedHelpers( 'keyPairs', ); @@ -27,6 +24,7 @@ export default { components: { ClusterFormDropdown, GlFormCheckbox, + GlFormGroup, GlFormInput, GlIcon, GlLink, @@ -60,11 +58,10 @@ export default { ), roleDropdownHelpPath: 'https://docs.aws.amazon.com/eks/latest/userguide/service_IAM_role.html#create-service-role', - regionsDropdownHelpText: s__( - 'ClusterIntegration|Learn more about %{linkStart}Regions%{linkEnd}.', + regionInputLabel: s__('ClusterIntegration|Cluster Region'), + regionHelpText: s__( + 'ClusterIntegration|The region the new cluster will be created in. You must reauthenticate to change regions.', ), - regionsDropdownHelpPath: - 'https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/', keyPairDropdownHelpText: s__( 'ClusterIntegration|Select the key pair name that will be used to create EC2 nodes. To use a new key pair name, first create one on %{linkStart}Amazon Web Services%{linkEnd}.', ), @@ -117,11 +114,6 @@ export default { isLoadingRoles: 'isLoadingItems', loadingRolesError: 'loadingItemsError', }), - ...mapRegionsState({ - regions: 'items', - isLoadingRegions: 'isLoadingItems', - loadingRegionsError: 'loadingItemsError', - }), ...mapKeyPairsState({ keyPairs: 'items', isLoadingKeyPairs: 'isLoadingItems', @@ -195,8 +187,8 @@ export default { }, }, mounted() { - this.fetchRegions(); this.fetchRoles(); + this.setRegionAndFetchVpcsAndKeyPairs(); }, methods: { ...mapActions([ @@ -215,20 +207,18 @@ export default { 'setGitlabManagedCluster', 'setNamespacePerEnvironment', ]), - ...mapRegionsActions({ fetchRegions: 'fetchItems' }), ...mapVpcActions({ fetchVpcs: 'fetchItems' }), ...mapSubnetActions({ fetchSubnets: 'fetchItems' }), ...mapRolesActions({ fetchRoles: 'fetchItems' }), ...mapKeyPairsActions({ fetchKeyPairs: 'fetchItems' }), ...mapSecurityGroupsActions({ fetchSecurityGroups: 'fetchItems' }), - setRegionAndFetchVpcsAndKeyPairs(region) { - this.setRegion({ region }); + setRegionAndFetchVpcsAndKeyPairs() { this.setVpc({ vpc: null }); this.setKeyPair({ keyPair: null }); this.setSubnet({ subnet: [] }); this.setSecurityGroup({ securityGroup: null }); - this.fetchVpcs({ region }); - this.fetchKeyPairs({ region }); + this.fetchVpcs({ region: this.selectedRegion }); + this.fetchKeyPairs({ region: this.selectedRegion }); }, setVpcAndFetchSubnets(vpc) { this.setVpc({ vpc }); @@ -314,33 +304,12 @@ export default { </gl-sprintf> </p> </div> - <div class="form-group"> - <label class="label-bold" for="eks-role">{{ s__('ClusterIntegration|Region') }}</label> - <cluster-form-dropdown - field-id="eks-region" - field-name="eks-region" - :value="selectedRegion" - :items="regions" - :loading="isLoadingRegions" - :loading-text="s__('ClusterIntegration|Loading Regions')" - :placeholder="s__('ClusterIntergation|Select a region')" - :search-field-placeholder="s__('ClusterIntegration|Search regions')" - :empty-text="s__('ClusterIntegration|No region found')" - :has-errors="Boolean(loadingRegionsError)" - :error-message="s__('ClusterIntegration|Could not load regions from your AWS account')" - @input="setRegionAndFetchVpcsAndKeyPairs($event)" - /> - <p class="form-text text-muted"> - <gl-sprintf :message="$options.i18n.regionsDropdownHelpText"> - <template #link="{ content }"> - <gl-link :href="$options.i18n.regionsDropdownHelpPath" target="_blank"> - {{ content }} - <gl-icon name="external-link" class="gl-vertical-align-middle" /> - </gl-link> - </template> - </gl-sprintf> - </p> - </div> + <gl-form-group + :label="$options.i18n.regionInputLabel" + :description="$options.i18n.regionHelpText" + > + <gl-form-input id="eks-region" :value="selectedRegion" type="text" readonly /> + </gl-form-group> <div class="form-group"> <label class="label-bold" for="eks-key-pair">{{ s__('ClusterIntegration|Key pair name') diff --git a/app/assets/javascripts/create_cluster/eks_cluster/components/service_credentials_form.vue b/app/assets/javascripts/create_cluster/eks_cluster/components/service_credentials_form.vue index 5c13cbb2775..a3f76241bf2 100644 --- a/app/assets/javascripts/create_cluster/eks_cluster/components/service_credentials_form.vue +++ b/app/assets/javascripts/create_cluster/eks_cluster/components/service_credentials_form.vue @@ -1,15 +1,20 @@ <script> /* eslint-disable vue/no-v-html */ -import { GlFormInput, GlButton } from '@gitlab/ui'; +import { GlButton, GlFormGroup, GlFormInput, GlIcon, GlLink, GlSprintf } from '@gitlab/ui'; import { escape } from 'lodash'; import { mapState, mapActions } from 'vuex'; +import { DEFAULT_REGION } from '../constants'; import { sprintf, s__, __ } from '~/locale'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; export default { components: { - GlFormInput, GlButton, + GlFormGroup, + GlFormInput, + GlIcon, + GlLink, + GlSprintf, ClipboardButton, }, props: { @@ -26,9 +31,18 @@ export default { required: true, }, }, + i18n: { + regionInputLabel: s__('ClusterIntegration|Cluster Region'), + regionHelpPath: 'https://aws.amazon.com/about-aws/global-infrastructure/regions_az/', + regionHelpText: s__( + 'ClusterIntegration|Select the region you want to create the new cluster in. Make sure you have access to this region for your role to be able to authenticate. If no region is selected, we will use %{codeStart}DEFAULT_REGION%{codeEnd}. Learn more about %{linkStart}Regions%{linkEnd}.', + ), + regionHelpTextDefaultRegion: DEFAULT_REGION, + }, data() { return { roleArn: this.$store.state.roleArn, + selectedRegion: this.$store.state.selectedRegion, }; }, computed: { @@ -130,13 +144,33 @@ export default { <gl-form-input id="eks-provision-role-arn" v-model="roleArn" /> <p class="form-text text-muted" v-html="provisionRoleArnHelpText"></p> </div> + + <gl-form-group :label="$options.i18n.regionInputLabel"> + <gl-form-input id="eks-region" v-model="selectedRegion" type="text" /> + + <template #description> + <gl-sprintf :message="$options.i18n.regionHelpText"> + <template #code> + <code>{{ $options.i18n.regionHelpTextDefaultRegion }}</code> + </template> + + <template #link="{ content }"> + <gl-link :href="$options.i18n.regionHelpPath" target="_blank"> + {{ content }} + <gl-icon name="external-link" /> + </gl-link> + </template> + </gl-sprintf> + </template> + </gl-form-group> + <gl-button variant="success" category="primary" type="submit" :disabled="submitButtonDisabled" :loading="isCreatingRole" - @click.prevent="createRole({ roleArn, externalId })" + @click.prevent="createRole({ roleArn, selectedRegion, externalId })" > {{ submitButtonLabel }} </gl-button> diff --git a/app/assets/javascripts/create_cluster/eks_cluster/constants.js b/app/assets/javascripts/create_cluster/eks_cluster/constants.js index 471d6e1f0aa..0f0db2090c1 100644 --- a/app/assets/javascripts/create_cluster/eks_cluster/constants.js +++ b/app/assets/javascripts/create_cluster/eks_cluster/constants.js @@ -1,3 +1,5 @@ +export const DEFAULT_REGION = 'us-east-2'; + export const KUBERNETES_VERSIONS = [ { name: '1.14', value: '1.14' }, { name: '1.15', value: '1.15' }, diff --git a/app/assets/javascripts/create_cluster/eks_cluster/services/aws_services_facade.js b/app/assets/javascripts/create_cluster/eks_cluster/services/aws_services_facade.js index 601ff6f9adc..58568b5dedb 100644 --- a/app/assets/javascripts/create_cluster/eks_cluster/services/aws_services_facade.js +++ b/app/assets/javascripts/create_cluster/eks_cluster/services/aws_services_facade.js @@ -8,13 +8,8 @@ const lookupVpcName = ({ Tags: tags, VpcId: id }) => { return nameTag ? nameTag.Value : id; }; -export const DEFAULT_REGION = 'us-east-2'; - export const setAWSConfig = ({ awsCredentials }) => { - AWS.config = { - ...awsCredentials, - region: DEFAULT_REGION, - }; + AWS.config = awsCredentials; }; export const fetchRoles = () => { @@ -26,20 +21,6 @@ export const fetchRoles = () => { .then(({ Roles: roles }) => roles.map(({ RoleName: name, Arn: value }) => ({ name, value }))); }; -export const fetchRegions = () => { - const ec2 = new EC2(); - - return ec2 - .describeRegions() - .promise() - .then(({ Regions: regions }) => - regions.map(({ RegionName: name }) => ({ - name, - value: name, - })), - ); -}; - export const fetchKeyPairs = ({ region }) => { const ec2 = new EC2({ region }); diff --git a/app/assets/javascripts/create_cluster/eks_cluster/store/actions.js b/app/assets/javascripts/create_cluster/eks_cluster/store/actions.js index 48c85ff627f..f3950a3343a 100644 --- a/app/assets/javascripts/create_cluster/eks_cluster/store/actions.js +++ b/app/assets/javascripts/create_cluster/eks_cluster/store/actions.js @@ -1,4 +1,5 @@ import * as types from './mutation_types'; +import { DEFAULT_REGION } from '../constants'; import { setAWSConfig } from '../services/aws_services_facade'; import axios from '~/lib/utils/axios_utils'; import { deprecatedCreateFlash as createFlash } from '~/flash'; @@ -25,12 +26,22 @@ export const setKubernetesVersion = ({ commit }, payload) => { export const createRole = ({ dispatch, state: { createRolePath } }, payload) => { dispatch('requestCreateRole'); + const region = payload.selectedRegion || DEFAULT_REGION; + return axios .post(createRolePath, { role_arn: payload.roleArn, role_external_id: payload.externalId, + region, + }) + .then(({ data }) => { + const awsData = { + ...convertObjectPropsToCamelCase(data), + region, + }; + + dispatch('createRoleSuccess', awsData); }) - .then(({ data }) => dispatch('createRoleSuccess', convertObjectPropsToCamelCase(data))) .catch(error => dispatch('createRoleError', { error })); }; @@ -38,7 +49,8 @@ export const requestCreateRole = ({ commit }) => { commit(types.REQUEST_CREATE_ROLE); }; -export const createRoleSuccess = ({ commit }, awsCredentials) => { +export const createRoleSuccess = ({ dispatch, commit }, awsCredentials) => { + dispatch('setRegion', { region: awsCredentials.region }); setAWSConfig({ awsCredentials }); commit(types.CREATE_ROLE_SUCCESS); }; diff --git a/app/assets/javascripts/create_cluster/eks_cluster/store/index.js b/app/assets/javascripts/create_cluster/eks_cluster/store/index.js index 8dc55506dc2..262bbb3167a 100644 --- a/app/assets/javascripts/create_cluster/eks_cluster/store/index.js +++ b/app/assets/javascripts/create_cluster/eks_cluster/store/index.js @@ -8,7 +8,6 @@ import clusterDropdownStore from '~/create_cluster/store/cluster_dropdown'; import { fetchRoles, - fetchRegions, fetchKeyPairs, fetchVpcs, fetchSubnets, @@ -26,10 +25,6 @@ const createStore = ({ initialState }) => namespaced: true, ...clusterDropdownStore({ fetchFn: fetchRoles }), }, - regions: { - namespaced: true, - ...clusterDropdownStore({ fetchFn: fetchRegions }), - }, keyPairs: { namespaced: true, ...clusterDropdownStore({ fetchFn: fetchKeyPairs }), diff --git a/app/assets/javascripts/create_cluster/gke_cluster/components/gke_project_id_dropdown.vue b/app/assets/javascripts/create_cluster/gke_cluster/components/gke_project_id_dropdown.vue index 979628d683d..85d9f0d66ab 100644 --- a/app/assets/javascripts/create_cluster/gke_cluster/components/gke_project_id_dropdown.vue +++ b/app/assets/javascripts/create_cluster/gke_cluster/components/gke_project_id_dropdown.vue @@ -1,6 +1,6 @@ <script> import { mapState, mapGetters, mapActions } from 'vuex'; -import { GlSprintf, GlLink } from '@gitlab/ui'; +import { GlSprintf, GlLink, GlIcon } from '@gitlab/ui'; import { s__ } from '~/locale'; import gkeDropdownMixin from './gke_dropdown_mixin'; @@ -10,6 +10,7 @@ export default { components: { GlSprintf, GlLink, + GlIcon, }, mixins: [gkeDropdownMixin], props: { @@ -178,14 +179,14 @@ export default { 'https://console.cloud.google.com/freetrial?utm_campaign=2018_cpanel&utm_source=gitlab&utm_medium=referral' " target="_blank" - >{{ content }} <i class="fa fa-external-link" aria-hidden="true"></i - ></gl-link> + >{{ content }} <gl-icon name="external-link" aria-hidden="true" + /></gl-link> </template> <template #docsLink="{ content }"> <gl-link :href="docsUrl" target="_blank" - >{{ content }} <i class="fa fa-external-link" aria-hidden="true"></i - ></gl-link> + >{{ content }} <gl-icon name="external-link" aria-hidden="true" + /></gl-link> </template> <template #error> |