From 80f9aff34b07fd8dc490a06cd6281b5af4310438 Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Tue, 13 Mar 2018 11:57:16 -0600 Subject: Make ci/lint page context aware: - Create ci/lints controller inside project/ - Move js pages to be inside projects/ - Copy view ci/lint view to be inside project folder - Remove ci/lint view and js files Closes #43603 --- app/controllers/ci/lints_controller.rb | 15 ------------ app/controllers/projects/ci/lints_controller.rb | 31 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 app/controllers/projects/ci/lints_controller.rb (limited to 'app/controllers') diff --git a/app/controllers/ci/lints_controller.rb b/app/controllers/ci/lints_controller.rb index e9bd1689a1e..738a6a5173e 100644 --- a/app/controllers/ci/lints_controller.rb +++ b/app/controllers/ci/lints_controller.rb @@ -4,20 +4,5 @@ module Ci def show end - - def create - @content = params[:content] - @error = Gitlab::Ci::YamlProcessor.validation_message(@content) - @status = @error.blank? - - if @error.blank? - @config_processor = Gitlab::Ci::YamlProcessor.new(@content) - @stages = @config_processor.stages - @builds = @config_processor.builds - @jobs = @config_processor.jobs - end - - render :show - end end end diff --git a/app/controllers/projects/ci/lints_controller.rb b/app/controllers/projects/ci/lints_controller.rb new file mode 100644 index 00000000000..47328504cd5 --- /dev/null +++ b/app/controllers/projects/ci/lints_controller.rb @@ -0,0 +1,31 @@ +class Projects::Ci::LintsController < Projects::ApplicationController + before_action :ensure_user_access + + def show + end + + def create + @content = params[:content] + @error = Gitlab::Ci::YamlProcessor.validation_message(@content, yaml_processor_options) + @status = @error.blank? + + if @error.blank? + @config_processor = Gitlab::Ci::YamlProcessor.new(@content, yaml_processor_options) + @stages = @config_processor.stages + @builds = @config_processor.builds + @jobs = @config_processor.jobs + end + + render :show + end + + private + + def yaml_processor_options + { project: @project, sha: project.repository.commit.sha } + end + + def ensure_user_access + return access_denied! unless can?(current_user, :create_pipeline, @project) + end +end -- cgit v1.2.1 From 02bc89983a4b4b81a2f6279c39622b8a14430e3d Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Tue, 13 Mar 2018 14:57:42 -0600 Subject: Build ci/lint page - Includes new image from gitlab-svgs - Updates dependency for svgs --- app/controllers/projects/settings/ci_cd_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb index 259809f3429..96125b549b7 100644 --- a/app/controllers/projects/settings/ci_cd_controller.rb +++ b/app/controllers/projects/settings/ci_cd_controller.rb @@ -29,12 +29,12 @@ module Projects @project_runners = @project.runners.ordered @assignable_runners = current_user.ci_authorized_runners .assignable_for(project).ordered.page(params[:page]).per(20) - @shared_runners = Ci::Runner.shared.active + @shared_runners = ::Ci::Runner.shared.active @shared_runners_count = @shared_runners.count(:all) end def define_secret_variables - @variable = Ci::Variable.new(project: project) + @variable = ::Ci::Variable.new(project: project) .present(current_user: current_user) @variables = project.variables.order_key_asc .map { |variable| variable.present(current_user: current_user) } @@ -42,7 +42,7 @@ module Projects def define_triggers_variables @triggers = @project.triggers - @trigger = Ci::Trigger.new + @trigger = ::Ci::Trigger.new end def define_badges_variables -- cgit v1.2.1 From 56c95fb6a157be67c11172e16c5417bbcf168eb0 Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Wed, 21 Mar 2018 15:24:49 -0600 Subject: Changes ci/lints controller to use authorize before action Also includes a comment on Ci::Config regarding that's going to be override by EE --- app/controllers/projects/ci/lints_controller.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/ci/lints_controller.rb b/app/controllers/projects/ci/lints_controller.rb index 47328504cd5..a2185572a20 100644 --- a/app/controllers/projects/ci/lints_controller.rb +++ b/app/controllers/projects/ci/lints_controller.rb @@ -1,5 +1,5 @@ class Projects::Ci::LintsController < Projects::ApplicationController - before_action :ensure_user_access + before_action :authorize_create_pipeline! def show end @@ -24,8 +24,4 @@ class Projects::Ci::LintsController < Projects::ApplicationController def yaml_processor_options { project: @project, sha: project.repository.commit.sha } end - - def ensure_user_access - return access_denied! unless can?(current_user, :create_pipeline, @project) - end end -- cgit v1.2.1