summaryrefslogtreecommitdiff
path: root/app/controllers/ci/projects_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/ci/projects_controller.rb')
-rw-r--r--app/controllers/ci/projects_controller.rb91
1 files changed, 6 insertions, 85 deletions
diff --git a/app/controllers/ci/projects_controller.rb b/app/controllers/ci/projects_controller.rb
index b1f1c087b9e..e8788955eba 100644
--- a/app/controllers/ci/projects_controller.rb
+++ b/app/controllers/ci/projects_controller.rb
@@ -1,12 +1,10 @@
module Ci
class ProjectsController < Ci::ApplicationController
- PROJECTS_BATCH = 100
-
- before_action :authenticate_user!, except: [:build, :badge, :index, :show]
+ before_action :authenticate_user!, except: [:build, :badge, :show]
before_action :authenticate_public_page!, only: :show
- before_action :project, only: [:build, :integration, :show, :badge, :edit, :update, :destroy, :toggle_shared_runners, :dumped_yaml]
- before_action :authorize_access_project!, except: [:build, :badge, :index, :show, :new, :create, :disabled]
- before_action :authorize_manage_project!, only: [:edit, :integration, :update, :destroy, :toggle_shared_runners, :dumped_yaml]
+ before_action :project, only: [:build, :show, :badge, :toggle_shared_runners, :dumped_yaml]
+ before_action :authorize_access_project!, except: [:build, :badge, :show, :new, :disabled]
+ before_action :authorize_manage_project!, only: [:toggle_shared_runners, :dumped_yaml]
before_action :authenticate_token!, only: [:build]
before_action :no_cache, only: [:badge]
skip_before_action :check_enable_flag!, only: [:disabled]
@@ -17,26 +15,6 @@ module Ci
def disabled
end
- def index
- @limit, @offset = (params[:limit] || PROJECTS_BATCH).to_i, (params[:offset] || 0).to_i
- @page = @offset == 0 ? 1 : (@offset / @limit + 1)
-
- if current_user
- @projects = ProjectListBuilder.new.execute(current_user, params[:search])
-
- @projects = @projects.page(@page).per(@limit)
-
- @total_count = @projects.size
- end
-
- respond_to do |format|
- format.json do
- pager_json("ci/projects/index", @total_count)
- end
- format.html
- end
- end
-
def show
@ref = params[:ref]
@@ -45,57 +23,6 @@ module Ci
@commits = @commits.page(params[:page]).per(20)
end
- def integration
- end
-
- def create
- project_data = OpenStruct.new(JSON.parse(params["project"]))
-
- unless can?(current_user, :admin_project, ::Project.find(project_data.id))
- return redirect_to ci_root_path, alert: 'You have to have at least master role to enable CI for this project'
- end
-
- @project = Ci::CreateProjectService.new.execute(current_user, project_data, ci_project_url(":project_id"))
-
- if @project.persisted?
- redirect_to ci_project_path(@project, show_guide: true), notice: 'Project was successfully created.'
- else
- redirect_to :back, alert: 'Cannot save project'
- end
- end
-
- def edit
- end
-
- def update
- if project.update_attributes(project_params)
- Ci::EventService.new.change_project_settings(current_user, project)
-
- redirect_to :back, notice: 'Project was successfully updated.'
- else
- render action: "edit"
- end
- end
-
- def destroy
- project.gl_project.gitlab_ci_service.update_attributes(active: false)
- project.destroy
-
- Ci::EventService.new.remove_project(current_user, project)
-
- redirect_to ci_projects_url
- end
-
- def build
- @commit = Ci::CreateCommitService.new.execute(@project, params.dup)
-
- if @commit && @commit.valid?
- head 201
- else
- head 400
- end
- end
-
# Project status badge
# Image with build status for sha or ref
def badge
@@ -106,7 +33,8 @@ module Ci
def toggle_shared_runners
project.toggle!(:shared_runners_enabled)
- redirect_to :back
+
+ redirect_to namespace_project_runners_path(project.gl_project.namespace, project.gl_project)
end
def dumped_yaml
@@ -124,12 +52,5 @@ module Ci
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
end
-
- def project_params
- params.require(:project).permit(:path, :timeout, :timeout_in_minutes, :default_ref, :always_build,
- :polling_interval, :public, :ssh_url_to_repo, :allow_git_fetch, :email_recipients,
- :email_add_pusher, :email_only_broken_builds, :coverage_regex, :shared_runners_enabled, :token,
- { variables_attributes: [:id, :key, :value, :_destroy] })
- end
end
end