diff options
Diffstat (limited to 'app/controllers/projects/settings')
-rw-r--r-- | app/controllers/projects/settings/ci_cd_controller.rb | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb index aac6ecb07e4..5feb3e019c2 100644 --- a/app/controllers/projects/settings/ci_cd_controller.rb +++ b/app/controllers/projects/settings/ci_cd_controller.rb @@ -7,6 +7,7 @@ module Projects before_action :define_variables before_action do push_frontend_feature_flag(:new_variables_ui, @project) + push_frontend_feature_flag(:ajax_new_deploy_token, @project) end def show @@ -47,13 +48,30 @@ module Projects end def create_deploy_token - @new_deploy_token = Projects::DeployTokens::CreateService.new(@project, current_user, deploy_token_params).execute + result = Projects::DeployTokens::CreateService.new(@project, current_user, deploy_token_params).execute + @new_deploy_token = result[:deploy_token] - if @new_deploy_token.persisted? - flash.now[:notice] = s_('DeployTokens|Your new project deploy token has been created.') + if result[:status] == :success + respond_to do |format| + format.json do + # IMPORTANT: It's a security risk to expose the token value more than just once here! + json = API::Entities::DeployTokenWithToken.represent(@new_deploy_token).as_json + render json: json, status: result[:http_status] + end + format.html do + flash.now[:notice] = s_('DeployTokens|Your new project deploy token has been created.') + render :show + end + end + else + respond_to do |format| + format.json { render json: { message: result[:message] }, status: result[:http_status] } + format.html do + flash.now[:alert] = result[:message] + render :show + end + end end - - render 'show' end private |