diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-11-04 03:34:13 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-11-04 03:34:13 +0900 |
commit | 3278b0a5ffca9ccbe0c043b1f9ef79d0ce4af813 (patch) | |
tree | 1494208cf93df507acb65804bb7e4f66be2f990c | |
parent | 8fb7e87806e8ae94ee40e56400625886cbcf411e (diff) | |
parent | db98ce38b5bdb38fae6b62298432841a1f4670f0 (diff) | |
download | gitlab-ce-3278b0a5ffca9ccbe0c043b1f9ef79d0ce4af813.tar.gz |
Merge branch '35616-move-gke-form-1st-iteration' into move-kubernetes-from-service-to-clusters-page-10-2-ver
-rw-r--r-- | app/controllers/projects/clusters_controller.rb | 13 | ||||
-rw-r--r-- | app/views/projects/clusters/new.html.haml | 17 | ||||
-rw-r--r-- | app/views/projects/clusters/new_gcp.html.haml | 10 | ||||
-rw-r--r-- | config/routes/project.rb | 1 | ||||
-rw-r--r-- | spec/controllers/projects/clusters_controller_spec.rb | 4 | ||||
-rw-r--r-- | spec/features/projects/clusters_spec.rb | 6 |
6 files changed, 40 insertions, 11 deletions
diff --git a/app/controllers/projects/clusters_controller.rb b/app/controllers/projects/clusters_controller.rb index c1692ea2569..9a56c9de858 100644 --- a/app/controllers/projects/clusters_controller.rb +++ b/app/controllers/projects/clusters_controller.rb @@ -1,8 +1,8 @@ class Projects::ClustersController < Projects::ApplicationController - before_action :cluster, except: [:login, :index, :new, :create] + before_action :cluster, except: [:login, :index, :new, :new_gcp, :create] before_action :authorize_read_cluster! - before_action :authorize_create_cluster!, only: [:new, :create] - before_action :authorize_google_api, only: [:new, :create] + before_action :authorize_create_cluster!, only: [:new, :new_gcp, :create] + before_action :authorize_google_api, only: [:new_gcp, :create] before_action :authorize_update_cluster!, only: [:update] before_action :authorize_admin_cluster!, only: [:destroy] @@ -16,7 +16,7 @@ class Projects::ClustersController < Projects::ApplicationController def login begin - state = generate_session_key_redirect(namespace_project_clusters_url.to_s) + state = generate_session_key_redirect(providers_gcp_new_namespace_project_clusters_url.to_s) @authorize_url = GoogleApi::CloudPlatform::Client.new( nil, callback_google_api_auth_url, @@ -27,6 +27,9 @@ class Projects::ClustersController < Projects::ApplicationController end def new + end + + def new_gcp @cluster = Clusters::Cluster.new.tap do |cluster| cluster.build_provider_gcp end @@ -40,7 +43,7 @@ class Projects::ClustersController < Projects::ApplicationController if @cluster.persisted? redirect_to project_cluster_path(project, @cluster) else - render :new + render :new_gcp end end diff --git a/app/views/projects/clusters/new.html.haml b/app/views/projects/clusters/new.html.haml index c538d41ffad..6b321f60212 100644 --- a/app/views/projects/clusters/new.html.haml +++ b/app/views/projects/clusters/new.html.haml @@ -1,9 +1,20 @@ - breadcrumb_title "Cluster" -- page_title _("New Cluster") +- page_title _("Cluster") .row.prepend-top-default .col-sm-4 = render 'sidebar' .col-sm-8 - = render 'header' -= render 'form' + - if @project.kubernetes_service&.active? + %h4.prepend-top-0= s_('ClusterIntegration|Cluster management') + + %p= s_('ClusterIntegration|A cluster has been set up on this project through the Kubernetes integration page') + = link_to s_('ClusterIntegration|Manage Kubernetes integration'), edit_project_service_path(@project, :kubernetes), class: 'btn append-bottom-20' + + - else + %h4.prepend-top-0= s_('ClusterIntegration|Choose how to set up cluster integration') + + %p= s_('ClusterIntegration|Create a new cluster on Google Container Engine right from GitLab') + = link_to s_('ClusterIntegration|Create on GKE'), providers_gcp_new_namespace_project_clusters_path(@project.namespace, @project), class: 'btn append-bottom-20' + %p= s_('ClusterIntegration|Enter the details for an existing Kubernetes cluster') + = link_to s_('ClusterIntegration|Add an existing cluster'), edit_project_service_path(@project, :kubernetes), class: 'btn append-bottom-20' diff --git a/app/views/projects/clusters/new_gcp.html.haml b/app/views/projects/clusters/new_gcp.html.haml new file mode 100644 index 00000000000..48e6b6ae8e8 --- /dev/null +++ b/app/views/projects/clusters/new_gcp.html.haml @@ -0,0 +1,10 @@ +- breadcrumb_title "Cluster" +- page_title _("New Cluster") + +.row.prepend-top-default + .col-sm-4 + = render 'sidebar' + .col-sm-8 + = render 'header' + += render 'form' diff --git a/config/routes/project.rb b/config/routes/project.rb index 746c0c46677..c52dd542c90 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -186,6 +186,7 @@ constraints(ProjectUrlConstrainer.new) do resources :clusters, except: [:edit] do collection do get :login + get '/providers/gcp/new', action: :new_gcp end member do diff --git a/spec/controllers/projects/clusters_controller_spec.rb b/spec/controllers/projects/clusters_controller_spec.rb index bfa5b5a91dc..b6c7186b9c8 100644 --- a/spec/controllers/projects/clusters_controller_spec.rb +++ b/spec/controllers/projects/clusters_controller_spec.rb @@ -113,7 +113,7 @@ describe Projects::ClustersController do end end - describe 'GET new' do + describe 'GET new_gcp' do let(:project) { create(:project) } describe 'functionality' do @@ -161,7 +161,7 @@ describe Projects::ClustersController do end def go - get :new, namespace_id: project.namespace, project_id: project + get :new_gcp, namespace_id: project.namespace, project_id: project end end diff --git a/spec/features/projects/clusters_spec.rb b/spec/features/projects/clusters_spec.rb index 27c1f5062f5..83049b788e2 100644 --- a/spec/features/projects/clusters_spec.rb +++ b/spec/features/projects/clusters_spec.rb @@ -22,6 +22,8 @@ feature 'Clusters', :js do context 'when user does not have a cluster and visits cluster index page' do before do visit project_clusters_path(project) + + click_link 'Create on GKE' end it 'user sees a new page' do @@ -98,7 +100,7 @@ feature 'Clusters', :js do it 'user sees creation form with the succeccful message' do expect(page).to have_content('Cluster integration was successfully removed.') - expect(page).to have_button('Create cluster') + expect(page).to have_content('Choose how to set up cluster integration') end end end @@ -107,6 +109,8 @@ feature 'Clusters', :js do context 'when user has not signed in Google' do before do visit project_clusters_path(project) + + click_link 'Create on GKE' end it 'user sees a login page' do |