Commit 7717c009 authored by Enrique Alcántara's avatar Enrique Alcántara Committed by Jan Provaznik

Allow to switch between cloud providers

In the cluster creation UI, always display the
cloud provider links to allow the user to switch
between cloud providers.
parent 16af66eb
...@@ -306,9 +306,9 @@ export default { ...@@ -306,9 +306,9 @@ export default {
</script> </script>
<template> <template>
<form name="eks-cluster-configuration-form"> <form name="eks-cluster-configuration-form">
<h2> <h4>
{{ s__('ClusterIntegration|Enter the details for your Amazon EKS Kubernetes cluster') }} {{ s__('ClusterIntegration|Enter the details for your Amazon EKS Kubernetes cluster') }}
</h2> </h4>
<div class="mb-3" v-html="kubernetesIntegrationHelpText"></div> <div class="mb-3" v-html="kubernetesIntegrationHelpText"></div>
<div class="form-group"> <div class="form-group">
<label class="label-bold" for="eks-cluster-name">{{ <label class="label-bold" for="eks-cluster-name">{{
......
...@@ -83,7 +83,7 @@ export default { ...@@ -83,7 +83,7 @@ export default {
</script> </script>
<template> <template>
<form name="service-credentials-form"> <form name="service-credentials-form">
<h2>{{ s__('ClusterIntegration|Authenticate with Amazon Web Services') }}</h2> <h4>{{ s__('ClusterIntegration|Authenticate with Amazon Web Services') }}</h4>
<p> <p>
{{ {{
s__( s__(
......
...@@ -17,17 +17,6 @@ module ClustersHelper ...@@ -17,17 +17,6 @@ module ClustersHelper
end end
end end
def new_cluster_partial(provider: nil)
case provider
when 'aws'
'clusters/clusters/aws/new'
when 'gcp'
'clusters/clusters/gcp/new'
else
'clusters/clusters/cloud_providers/cloud_provider_selector'
end
end
def render_gcp_signup_offer def render_gcp_signup_offer
return if Gitlab::CurrentSettings.current_application_settings.hide_third_party_offers? return if Gitlab::CurrentSettings.current_application_settings.hide_third_party_offers?
return unless show_gcp_signup_offer? return unless show_gcp_signup_offer?
......
- provider = local_assigns.fetch(:provider) - provider = local_assigns.fetch(:provider)
- is_current_provider = provider == params[:provider]
- logo_path = local_assigns.fetch(:logo_path) - logo_path = local_assigns.fetch(:logo_path)
- label = local_assigns.fetch(:label) - label = local_assigns.fetch(:label)
- last = local_assigns.fetch(:last, false) - last = local_assigns.fetch(:last, false)
- classes = ['btn btn-light btn-outline flex-fill d-inline-flex flex-column justify-content-center align-items-center', ('mr-3' unless last)] - classes = ["btn btn-light btn-outline flex-fill d-inline-flex flex-column justify-content-center align-items-center w-50 js-create-#{provider}-cluster-button"]
- conditional_classes = [('mr-3' unless last), ('active' if is_current_provider)]
= link_to clusterable.new_path(provider: provider), class: classes do = link_to clusterable.new_path(provider: provider), class: classes + conditional_classes do
.svg-content.p-2= image_tag logo_path, alt: label, class: 'gl-w-64 gl-h-64' .svg-content.p-2= image_tag logo_path, alt: label, class: 'gl-w-64 gl-h-64'
%span %span
= label = label
- gke_label = s_('ClusterIntegration|Google GKE') - gke_label = s_('ClusterIntegration|Google GKE')
- eks_label = s_('ClusterIntegration|Amazon EKS') - eks_label = s_('ClusterIntegration|Amazon EKS')
- create_cluster_label = s_('ClusterIntegration|Create cluster on') - create_cluster_label = s_('ClusterIntegration|Create cluster on')
.d-flex.flex-column .d-flex.flex-column.p-3
%h5.mb-3 %h4.mb-3
= create_cluster_label = create_cluster_label
.d-flex .d-flex
= render partial: 'clusters/clusters/cloud_providers/cloud_provider_button', = render partial: 'clusters/clusters/cloud_providers/cloud_provider_button',
......
- breadcrumb_title _('Kubernetes') - breadcrumb_title _('Kubernetes')
- page_title _('Kubernetes Cluster') - page_title _('Kubernetes Cluster')
- active_tab = local_assigns.fetch(:active_tab, 'create') - active_tab = local_assigns.fetch(:active_tab, 'create')
- provider = params[:provider]
= javascript_include_tag 'https://apis.google.com/js/api.js' = javascript_include_tag 'https://apis.google.com/js/api.js'
= render_gcp_signup_offer = render_gcp_signup_offer
...@@ -19,8 +20,12 @@ ...@@ -19,8 +20,12 @@
%span Add existing cluster %span Add existing cluster
.tab-content.gitlab-tab-content .tab-content.gitlab-tab-content
.tab-pane{ id: 'create-cluster-pane', class: active_when(active_tab == 'create'), role: 'tabpanel' } .tab-pane.p-0{ id: 'create-cluster-pane', class: active_when(active_tab == 'create'), role: 'tabpanel' }
= render new_cluster_partial(provider: params[:provider]) = render 'clusters/clusters/cloud_providers/cloud_provider_selector'
- if ['aws', 'gcp'].include?(provider)
.p-3.border-top
= render "clusters/clusters/#{provider}/new"
.tab-pane{ id: 'add-cluster-pane', class: active_when(active_tab == 'add'), role: 'tabpanel' } .tab-pane{ id: 'add-cluster-pane', class: active_when(active_tab == 'add'), role: 'tabpanel' }
= render 'clusters/clusters/user/header' = render 'clusters/clusters/user/header'
......
---
title: Allow to switch between cloud providers in cluster creation screen
merge_request: 23362
author:
type: changed
...@@ -30,6 +30,10 @@ describe 'AWS EKS Cluster', :js do ...@@ -30,6 +30,10 @@ describe 'AWS EKS Cluster', :js do
it 'user sees a form to create an EKS cluster' do it 'user sees a form to create an EKS cluster' do
expect(page).to have_content('Create new cluster on EKS') expect(page).to have_content('Create new cluster on EKS')
end end
it 'highlights Amazon EKS logo' do
expect(page).to have_css('.js-create-aws-cluster-button.active')
end
end end
end end
end end
...@@ -38,6 +38,10 @@ describe 'Gcp Cluster', :js, :do_not_mock_admin_mode do ...@@ -38,6 +38,10 @@ describe 'Gcp Cluster', :js, :do_not_mock_admin_mode do
click_link 'Google GKE' click_link 'Google GKE'
end end
it 'highlights Google GKE logo' do
expect(page).to have_css('.js-create-gcp-cluster-button.active')
end
context 'when user filled form with valid parameters' do context 'when user filled form with valid parameters' do
subject { submit_form } subject { submit_form }
......
...@@ -58,32 +58,4 @@ describe ClustersHelper do ...@@ -58,32 +58,4 @@ describe ClustersHelper do
it { is_expected.to eq('Create new cluster') } it { is_expected.to eq('Create new cluster') }
end end
end end
describe '#render_new_provider_form' do
subject { helper.new_cluster_partial(provider: provider) }
context 'GCP provider' do
let(:provider) { 'gcp' }
it { is_expected.to eq('clusters/clusters/gcp/new') }
end
context 'AWS provider' do
let(:provider) { 'aws' }
it { is_expected.to eq('clusters/clusters/aws/new') }
end
context 'other provider' do
let(:provider) { 'other' }
it { is_expected.to eq('clusters/clusters/cloud_providers/cloud_provider_selector') }
end
context 'no provider' do
let(:provider) { nil }
it { is_expected.to eq('clusters/clusters/cloud_providers/cloud_provider_selector') }
end
end
end end
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