summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2017-11-07 10:14:22 +0000
committerGrzegorz Bizon <grzegorz@gitlab.com>2017-11-07 10:14:22 +0000
commitce7e60f6d77f4c7ad78ec97f3d5b8dcc9b12c03d (patch)
treec60fcca10bd75371ff424371c1f68c8feba8d516
parent39afe3bc15d27b98938c78a655fa2d7fdfbcaa0a (diff)
parent8d51a2f48a8c5319dd2f6bf53de58bfe0a13949d (diff)
downloadgitlab-ce-ce7e60f6d77f4c7ad78ec97f3d5b8dcc9b12c03d.tar.gz
Merge branch '35616-move-gke-form-1st-iteration' into 'master'
First iteration of Move Kubernetes from service to Cluster page See merge request gitlab-org/gitlab-ce!15061
-rw-r--r--app/controllers/projects/clusters_controller.rb13
-rw-r--r--app/views/projects/clusters/new.html.haml17
-rw-r--r--app/views/projects/clusters/new_gcp.html.haml10
-rw-r--r--config/routes/project.rb1
-rw-r--r--spec/controllers/projects/clusters_controller_spec.rb6
-rw-r--r--spec/features/projects/clusters_spec.rb6
6 files changed, 41 insertions, 12 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 de4cf40b492..ca2bcb2b5ae 100644
--- a/spec/controllers/projects/clusters_controller_spec.rb
+++ b/spec/controllers/projects/clusters_controller_spec.rb
@@ -72,7 +72,7 @@ describe Projects::ClustersController do
go
expect(assigns(:authorize_url)).to include(key)
- expect(session[session_key_for_redirect_uri]).to eq(project_clusters_url(project))
+ expect(session[session_key_for_redirect_uri]).to eq(providers_gcp_new_project_clusters_url(project))
end
end
@@ -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..368aad860e7 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_link('Create on GKE')
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