From 5754908fee556062ab2e42a418bf192a0bf56402 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Fri, 27 Oct 2017 16:48:02 +0100 Subject: [PATCH 1/6] Adds buttons to the first page. Moves first page into a new one --- app/controllers/projects/clusters_controller.rb | 7 ++++++- app/views/projects/clusters/new.html.haml | 11 +++++++++-- .../projects/clusters/new_kubernetes_form.html.haml | 9 +++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 app/views/projects/clusters/new_kubernetes_form.html.haml diff --git a/app/controllers/projects/clusters_controller.rb b/app/controllers/projects/clusters_controller.rb index 03019b0becc..95e2f6a1257 100644 --- a/app/controllers/projects/clusters_controller.rb +++ b/app/controllers/projects/clusters_controller.rb @@ -26,10 +26,15 @@ class Projects::ClustersController < Projects::ApplicationController end end - def new + # TODO fix this + def new_kubernetes_form @cluster = project.build_cluster end + def new + # First page! + end + def create @cluster = Ci::CreateClusterService .new(project, current_user, create_params) diff --git a/app/views/projects/clusters/new.html.haml b/app/views/projects/clusters/new.html.haml index c538d41ffad..3963e4741f3 100644 --- a/app/views/projects/clusters/new.html.haml +++ b/app/views/projects/clusters/new.html.haml @@ -5,5 +5,12 @@ .col-sm-4 = render 'sidebar' .col-sm-8 - = render 'header' -= render 'form' + %h4= s_('ClusterIntegration|Choose how to set up cluster integration') + + %p= s_('ClusterIntegration| Create a new cluster on Google Engine right from GitLab') + -# TODO FIX PATH + = link_to s_('ClusterIntegration|Create on GKE'), providers_gcp_login_project_clusters_path(@project), class: 'btn append-bottom-20' + -# TODO FIX PATH + %p= s_('ClusterIntegration| Enter the details for an existing Kubernetes cluster') + = link_to s_('ClusterIntegration|Add an existing cluster'), project_settings_integrations_path(@project), class: 'btn append-bottom-20' + diff --git a/app/views/projects/clusters/new_kubernetes_form.html.haml b/app/views/projects/clusters/new_kubernetes_form.html.haml new file mode 100644 index 00000000000..c538d41ffad --- /dev/null +++ b/app/views/projects/clusters/new_kubernetes_form.html.haml @@ -0,0 +1,9 @@ +- breadcrumb_title "Cluster" +- page_title _("New Cluster") + +.row.prepend-top-default + .col-sm-4 + = render 'sidebar' + .col-sm-8 + = render 'header' += render 'form' From 882cf2e409ce2ea798fce7f3082083fcdf143baf Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Wed, 1 Nov 2017 12:11:47 +0100 Subject: [PATCH 2/6] Fix paths to the first page --- app/controllers/projects/clusters_controller.rb | 16 +++++++--------- app/views/projects/clusters/new.html.haml | 7 ++----- ...bernetes_form.html.haml => new_gcp.html.haml} | 1 + config/routes/project.rb | 1 + 4 files changed, 11 insertions(+), 14 deletions(-) rename app/views/projects/clusters/{new_kubernetes_form.html.haml => new_gcp.html.haml} (97%) diff --git a/app/controllers/projects/clusters_controller.rb b/app/controllers/projects/clusters_controller.rb index 95e2f6a1257..23613b98e8c 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, @@ -26,13 +26,11 @@ class Projects::ClustersController < Projects::ApplicationController end end - # TODO fix this - def new_kubernetes_form - @cluster = project.build_cluster + def new end - def new - # First page! + def new_gcp + @cluster = project.build_cluster end def create diff --git a/app/views/projects/clusters/new.html.haml b/app/views/projects/clusters/new.html.haml index 3963e4741f3..b11202a4985 100644 --- a/app/views/projects/clusters/new.html.haml +++ b/app/views/projects/clusters/new.html.haml @@ -8,9 +8,6 @@ %h4= s_('ClusterIntegration|Choose how to set up cluster integration') %p= s_('ClusterIntegration| Create a new cluster on Google Engine right from GitLab') - -# TODO FIX PATH - = link_to s_('ClusterIntegration|Create on GKE'), providers_gcp_login_project_clusters_path(@project), class: 'btn append-bottom-20' - -# TODO FIX PATH + = 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'), project_settings_integrations_path(@project), class: 'btn append-bottom-20' - + = 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_kubernetes_form.html.haml b/app/views/projects/clusters/new_gcp.html.haml similarity index 97% rename from app/views/projects/clusters/new_kubernetes_form.html.haml rename to app/views/projects/clusters/new_gcp.html.haml index c538d41ffad..ad4b250db35 100644 --- a/app/views/projects/clusters/new_kubernetes_form.html.haml +++ b/app/views/projects/clusters/new_gcp.html.haml @@ -6,4 +6,5 @@ = render 'sidebar' .col-sm-8 = render 'header' + = render 'form' diff --git a/config/routes/project.rb b/config/routes/project.rb index d05fe11f233..764f794f369 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', to: :new_gcp end member do From 5efea3a298258e91bdc8b768be512f317e05ed5e Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 1 Nov 2017 23:13:22 +0900 Subject: [PATCH 3/6] Fix pipeline. Fix routing when validation failed. --- app/controllers/projects/clusters_controller.rb | 2 +- app/views/projects/clusters/new_gcp.html.haml | 2 +- config/routes/project.rb | 2 +- spec/controllers/projects/clusters_controller_spec.rb | 6 +++--- spec/features/projects/clusters_spec.rb | 6 +++++- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/controllers/projects/clusters_controller.rb b/app/controllers/projects/clusters_controller.rb index 23613b98e8c..0fd5635523f 100644 --- a/app/controllers/projects/clusters_controller.rb +++ b/app/controllers/projects/clusters_controller.rb @@ -41,7 +41,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_gcp.html.haml b/app/views/projects/clusters/new_gcp.html.haml index ad4b250db35..48e6b6ae8e8 100644 --- a/app/views/projects/clusters/new_gcp.html.haml +++ b/app/views/projects/clusters/new_gcp.html.haml @@ -6,5 +6,5 @@ = render 'sidebar' .col-sm-8 = render 'header' - + = render 'form' diff --git a/config/routes/project.rb b/config/routes/project.rb index 764f794f369..4b703ecb193 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -186,7 +186,7 @@ constraints(ProjectUrlConstrainer.new) do resources :clusters, except: [:edit] do collection do get :login - get '/providers/gcp/new', to: :new_gcp + 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 bd924a1c7be..ec948e49ad0 100644 --- a/spec/controllers/projects/clusters_controller_spec.rb +++ b/spec/controllers/projects/clusters_controller_spec.rb @@ -73,11 +73,11 @@ describe Projects::ClustersController do end end - describe 'GET new' do + describe 'GET new_gcp' do render_views subject do - get :new, namespace_id: project.namespace, + get :new_gcp, namespace_id: project.namespace, project_id: project end @@ -150,7 +150,7 @@ describe Projects::ClustersController do it 'shows an error message' do expect { subject }.not_to change { Gcp::Cluster.count } - expect(response).to render_template(:new) + expect(response).to render_template(:new_gcp) end end end diff --git a/spec/features/projects/clusters_spec.rb b/spec/features/projects/clusters_spec.rb index 810f2c39b43..b3f723b8104 100644 --- a/spec/features/projects/clusters_spec.rb +++ b/spec/features/projects/clusters_spec.rb @@ -18,6 +18,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 @@ -93,7 +95,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 @@ -102,6 +104,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 From 91229f0b5c8137a60a7a0b1242a1aa1baff78efa Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Thu, 2 Nov 2017 00:41:24 +0900 Subject: [PATCH 4/6] Fix static anlysys --- spec/controllers/projects/clusters_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/controllers/projects/clusters_controller_spec.rb b/spec/controllers/projects/clusters_controller_spec.rb index ec948e49ad0..5da4be2d319 100644 --- a/spec/controllers/projects/clusters_controller_spec.rb +++ b/spec/controllers/projects/clusters_controller_spec.rb @@ -78,7 +78,7 @@ describe Projects::ClustersController do subject do get :new_gcp, namespace_id: project.namespace, - project_id: project + project_id: project end context 'when logged' do From 54e27754b87ede2920fb56ffd7fbbe603076c16e Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Fri, 3 Nov 2017 10:52:29 +0000 Subject: [PATCH 5/6] Adds check for existing cluster --- app/views/projects/clusters/new.html.haml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/views/projects/clusters/new.html.haml b/app/views/projects/clusters/new.html.haml index b11202a4985..c850eeb3a7d 100644 --- a/app/views/projects/clusters/new.html.haml +++ b/app/views/projects/clusters/new.html.haml @@ -5,9 +5,16 @@ .col-sm-4 = render 'sidebar' .col-sm-8 - %h4= s_('ClusterIntegration|Choose how to set up cluster integration') + - if @project.kubernetes_service&.active? + %h4.prepend-top-0= s_('ClusterIntegration|Cluster management') - %p= s_('ClusterIntegration| Create a new cluster on Google 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' + %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' From db98ce38b5bdb38fae6b62298432841a1f4670f0 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Fri, 3 Nov 2017 12:57:10 +0000 Subject: [PATCH 6/6] Fix page title --- app/views/projects/clusters/new.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/clusters/new.html.haml b/app/views/projects/clusters/new.html.haml index c850eeb3a7d..6b321f60212 100644 --- a/app/views/projects/clusters/new.html.haml +++ b/app/views/projects/clusters/new.html.haml @@ -1,5 +1,5 @@ - breadcrumb_title "Cluster" -- page_title _("New Cluster") +- page_title _("Cluster") .row.prepend-top-default .col-sm-4