summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-01-10 14:34:56 +0100
committerKamil Trzciński <ayufan@ayufan.eu>2018-01-10 14:34:56 +0100
commit325a57a7970df26bbf2c290ae936c0b446bded13 (patch)
treeebea46677f2d425cb7c6534a459273659853f527
parentbe623ef3c1a867d23e9625fe372c17fcad3c47ce (diff)
downloadgitlab-ce-fix-billing-flash-notice.tar.gz
Fix billing enabled flash noticefix-billing-flash-notice
-rw-r--r--app/controllers/projects/clusters/gcp_controller.rb29
1 files changed, 20 insertions, 9 deletions
diff --git a/app/controllers/projects/clusters/gcp_controller.rb b/app/controllers/projects/clusters/gcp_controller.rb
index 25608df0b9c..659bf8d8f82 100644
--- a/app/controllers/projects/clusters/gcp_controller.rb
+++ b/app/controllers/projects/clusters/gcp_controller.rb
@@ -3,6 +3,7 @@ class Projects::Clusters::GcpController < Projects::ApplicationController
before_action :authorize_google_api, except: [:login]
before_action :authorize_google_project_billing, only: [:new]
before_action :authorize_create_cluster!, only: [:new, :create]
+ before_action :verify_billing, only: [:create]
def login
begin
@@ -23,24 +24,34 @@ class Projects::Clusters::GcpController < Projects::ApplicationController
end
def create
+ @cluster = ::Clusters::CreateService
+ .new(project, current_user, create_params)
+ .execute(token_in_session)
+
+ if @cluster.persisted?
+ redirect_to project_cluster_path(project, @cluster)
+ else
+ render :new
+ end
+ end
+
+ private
+
+ def verify_billing
case google_project_billing_status
when 'true'
- @cluster = ::Clusters::CreateService
- .new(project, current_user, create_params)
- .execute(token_in_session)
-
- return redirect_to project_cluster_path(project, @cluster) if @cluster.persisted?
+ return
when 'false'
- flash[:error] = _('Please enable billing for one of your projects to be able to create a cluster.')
+ flash[:alert] = _('Please enable billing for one of your projects to be able to create a cluster.')
else
- flash[:error] = _('We could not verify that one of your projects on GCP has billing enabled. Please try again.')
+ flash[:alert] = _('We could not verify that one of your projects on GCP has billing enabled. Please try again.')
end
+ @cluster = ::Clusters::Cluster.new(create_params)
+
render :new
end
- private
-
def create_params
params.require(:cluster).permit(
:enabled,