diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-01 15:08:00 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-01 15:08:00 +0300 |
commit | 1a0d6dbdc2ac3047f4953a359ef27ba6e26074ae (patch) | |
tree | ddb78a8a0d1350dc767f049a21e0f7d37edaa82c /app/controllers/projects/settings | |
parent | b11f7057d067885619ee3e513751f180b2e8ad85 (diff) |
Add latest changes from gitlab-org/gitlab@master
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 |