diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-24 04:43:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-24 04:43:31 +0300 |
commit | e20a1cde5d740fbc9f4d033786a8cd5ad7eb8b4d (patch) | |
tree | cf76b0527f1909eaf1ecac057a4ccc7591cce4f6 /app/controllers/projects | |
parent | 5fc725def41e6973e92bc32095774edd60fd154f (diff) |
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'app/controllers/projects')
4 files changed, 50 insertions, 42 deletions
diff --git a/app/controllers/projects/deploy_tokens_controller.rb b/app/controllers/projects/deploy_tokens_controller.rb index 4a70424ec01..830b1f4fe4a 100644 --- a/app/controllers/projects/deploy_tokens_controller.rb +++ b/app/controllers/projects/deploy_tokens_controller.rb @@ -7,6 +7,6 @@ class Projects::DeployTokensController < Projects::ApplicationController @token = @project.deploy_tokens.find(params[:id]) @token.revoke! - redirect_to project_settings_ci_cd_path(project, anchor: 'js-deploy-tokens') + redirect_to project_settings_repository_path(project, anchor: 'js-deploy-tokens') end end diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index cbab68b2827..8c37d70d4c9 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -26,6 +26,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo push_frontend_feature_flag(:code_navigation, @project) push_frontend_feature_flag(:widget_visibility_polling, @project, default_enabled: true) push_frontend_feature_flag(:merge_ref_head_comments, @project) + push_frontend_feature_flag(:diff_compare_with_head, @project) end before_action do diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb index c7cd9649dac..c4d291e8634 100644 --- a/app/controllers/projects/settings/ci_cd_controller.rb +++ b/app/controllers/projects/settings/ci_cd_controller.rb @@ -48,33 +48,6 @@ module Projects redirect_to namespace_project_settings_ci_cd_path end - def create_deploy_token - result = Projects::DeployTokens::CreateService.new(@project, current_user, deploy_token_params).execute - @new_deploy_token = result[:deploy_token] - - 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 - end - private def update_params @@ -93,10 +66,6 @@ module Projects end end - def deploy_token_params - params.require(:deploy_token).permit(:name, :expires_at, :read_repository, :read_registry, :write_registry, :username) - end - def run_autodevops_pipeline(service) return unless service.run_auto_devops_pipeline? @@ -116,7 +85,6 @@ module Projects def define_variables define_runners_variables define_ci_variables - define_deploy_token_variables define_triggers_variables define_badges_variables define_auto_devops_variables @@ -168,12 +136,6 @@ module Projects @auto_devops = @project.auto_devops || ProjectAutoDevops.new end - def define_deploy_token_variables - @deploy_tokens = @project.deploy_tokens.active - - @new_deploy_token = DeployToken.new - end - def define_deploy_keys @deploy_keys = DeployKeysPresenter.new(@project, current_user: current_user) end diff --git a/app/controllers/projects/settings/repository_controller.rb b/app/controllers/projects/settings/repository_controller.rb index a1f88c73649..68bab952217 100644 --- a/app/controllers/projects/settings/repository_controller.rb +++ b/app/controllers/projects/settings/repository_controller.rb @@ -4,7 +4,10 @@ module Projects module Settings class RepositoryController < Projects::ApplicationController before_action :authorize_admin_project! - before_action :remote_mirror, only: [:show] + before_action :define_variables, only: [:create_deploy_token] + before_action do + push_frontend_feature_flag(:ajax_new_deploy_token, @project) + end def show render_show @@ -24,15 +27,47 @@ module Projects redirect_to project_settings_repository_path(project) end + def create_deploy_token + result = Projects::DeployTokens::CreateService.new(@project, current_user, deploy_token_params).execute + @new_deploy_token = result[:deploy_token] + + 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 + end + private def render_show - define_protected_refs - remote_mirror + define_variables render 'show' end + def define_variables + define_deploy_token_variables + define_protected_refs + remote_mirror + end + # rubocop: disable CodeReuse/ActiveRecord def define_protected_refs @protected_branches = @project.protected_branches.order(:name).page(params[:page]) @@ -51,6 +86,10 @@ module Projects @remote_mirror = project.remote_mirrors.first_or_initialize end + def deploy_token_params + params.require(:deploy_token).permit(:name, :expires_at, :read_repository, :read_registry, :write_registry, :username) + end + def access_levels_options { create_access_levels: levels_for_dropdown, @@ -74,6 +113,12 @@ module Projects { open_branches: ProtectableDropdown.new(@project, :branches).hash } end + def define_deploy_token_variables + @deploy_tokens = @project.deploy_tokens.active + + @new_deploy_token ||= DeployToken.new + end + def load_gon_index gon.push(protectable_tags_for_dropdown) gon.push(protectable_branches_for_dropdown) |