diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-24 01:43:31 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-24 01:43:31 +0000 |
commit | e20a1cde5d740fbc9f4d033786a8cd5ad7eb8b4d (patch) | |
tree | cf76b0527f1909eaf1ecac057a4ccc7591cce4f6 /app/controllers/groups | |
parent | 5fc725def41e6973e92bc32095774edd60fd154f (diff) | |
download | gitlab-ce-e20a1cde5d740fbc9f4d033786a8cd5ad7eb8b4d.tar.gz |
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'app/controllers/groups')
-rw-r--r-- | app/controllers/groups/deploy_tokens_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/groups/settings/ci_cd_controller.rb | 41 | ||||
-rw-r--r-- | app/controllers/groups/settings/repository_controller.rb | 53 |
3 files changed, 55 insertions, 41 deletions
diff --git a/app/controllers/groups/deploy_tokens_controller.rb b/app/controllers/groups/deploy_tokens_controller.rb index a765922fc54..6bb075fd115 100644 --- a/app/controllers/groups/deploy_tokens_controller.rb +++ b/app/controllers/groups/deploy_tokens_controller.rb @@ -7,6 +7,6 @@ class Groups::DeployTokensController < Groups::ApplicationController @token = @group.deploy_tokens.find(params[:id]) @token.revoke! - redirect_to group_settings_ci_cd_path(@group, anchor: 'js-deploy-tokens') + redirect_to group_settings_repository_path(@group, anchor: 'js-deploy-tokens') end end diff --git a/app/controllers/groups/settings/ci_cd_controller.rb b/app/controllers/groups/settings/ci_cd_controller.rb index bfe7987176a..18f336eae78 100644 --- a/app/controllers/groups/settings/ci_cd_controller.rb +++ b/app/controllers/groups/settings/ci_cd_controller.rb @@ -8,9 +8,8 @@ module Groups before_action :authorize_update_max_artifacts_size!, only: [:update] before_action do push_frontend_feature_flag(:new_variables_ui, @group, default_enabled: true) - push_frontend_feature_flag(:ajax_new_deploy_token, @group) end - before_action :define_variables, only: [:show, :create_deploy_token] + before_action :define_variables, only: [:show] def show end @@ -42,38 +41,10 @@ module Groups redirect_to group_settings_ci_cd_path end - def create_deploy_token - result = Groups::DeployTokens::CreateService.new(@group, 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 group 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 define_variables define_ci_variables - define_deploy_token_variables end def define_ci_variables @@ -83,12 +54,6 @@ module Groups .map { |variable| variable.present(current_user: current_user) } end - def define_deploy_token_variables - @deploy_tokens = @group.deploy_tokens.active - - @new_deploy_token = DeployToken.new - end - def authorize_admin_group! return render_404 unless can?(current_user, :admin_group, group) end @@ -112,10 +77,6 @@ module Groups def update_group_params params.require(:group).permit(:max_artifacts_size) end - - def deploy_token_params - params.require(:deploy_token).permit(:name, :expires_at, :read_repository, :read_registry, :write_registry, :username) - end end end end diff --git a/app/controllers/groups/settings/repository_controller.rb b/app/controllers/groups/settings/repository_controller.rb new file mode 100644 index 00000000000..6e8c5628d24 --- /dev/null +++ b/app/controllers/groups/settings/repository_controller.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +module Groups + module Settings + class RepositoryController < Groups::ApplicationController + skip_cross_project_access_check :show + before_action :authorize_admin_group! + before_action :define_deploy_token_variables + before_action do + push_frontend_feature_flag(:ajax_new_deploy_token, @group) + end + + def create_deploy_token + result = Groups::DeployTokens::CreateService.new(@group, 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 group 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 define_deploy_token_variables + @deploy_tokens = @group.deploy_tokens.active + + @new_deploy_token = DeployToken.new + end + + def deploy_token_params + params.require(:deploy_token).permit(:name, :expires_at, :read_repository, :read_registry, :write_registry, :username) + end + end + end +end |