Commit 0731a7af authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Show only enabled CI projects

Since CI is enabled by pushing .gitlab-ci.yml file there is no need to
add CI project via dashboard
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent aba9668a
@CiPager =
init: (@url, @limit = 0, preload, @disable = false) ->
if preload
@offset = 0
@getItems()
else
@offset = @limit
@initLoadMore()
getItems: ->
$(".loading").show()
$.ajax
type: "GET"
url: @url
data: "limit=" + @limit + "&offset=" + @offset
complete: =>
$(".loading").hide()
success: (data) =>
CiPager.append(data.count, data.html)
dataType: "json"
append: (count, html) ->
if count > 1
$(".content-list").append html
if count == @limit
@offset += count
else
@disable = true
initLoadMore: ->
$(document).unbind('scroll')
$(document).endlessScroll
bottomPixels: 400
fireDelay: 1000
fireOnce: true
ceaseFire: ->
CiPager.disable
callback: (i) =>
unless $(".loading").is(':visible')
$(".loading").show()
CiPager.getItems()
module Ci module Ci
class ProjectsController < Ci::ApplicationController class ProjectsController < Ci::ApplicationController
PROJECTS_BATCH = 100
before_action :authenticate_user!, except: [:build, :badge, :index, :show] before_action :authenticate_user!, except: [:build, :badge, :index, :show]
before_action :authenticate_public_page!, only: :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 :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_access_project!, except: [:build, :badge, :index, :show, :new, :disabled]
before_action :authorize_manage_project!, only: [:edit, :integration, :update, :destroy, :toggle_shared_runners, :dumped_yaml] before_action :authorize_manage_project!, only: [:edit, :integration, :update, :destroy, :toggle_shared_runners, :dumped_yaml]
before_action :authenticate_token!, only: [:build] before_action :authenticate_token!, only: [:build]
before_action :no_cache, only: [:badge] before_action :no_cache, only: [:badge]
...@@ -18,14 +16,9 @@ module Ci ...@@ -18,14 +16,9 @@ module Ci
end end
def index 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 if current_user
@projects = ProjectListBuilder.new.execute(current_user, params[:search]) @projects = ProjectListBuilder.new.execute(current_user, params[:search])
@projects = @projects.page(params[:page]).per(40)
@projects = @projects.page(@page).per(@limit)
@total_count = @projects.size @total_count = @projects.size
end end
...@@ -48,22 +41,6 @@ module Ci ...@@ -48,22 +41,6 @@ module Ci
def integration def integration
end 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)
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 def edit
end end
......
...@@ -24,14 +24,3 @@ ...@@ -24,14 +24,3 @@
Private Private
%td %td
= ci_project.commits.count = ci_project.commits.count
- else
%tr.light
%td
= project.name_with_namespace
%td
%small Not added to CI
%td
%td
= form_tag ci_projects_path do
= hidden_field_tag :project, project.to_json(methods: [:name_with_namespace, :path_with_namespace, :ssh_url_to_repo])
= submit_tag 'Add project to CI', class: 'btn btn-default btn-sm'
.search .search
= form_tag "#", method: :get, class: 'ci-search-form' do |f| = form_tag ci_root_path, method: :get, class: 'ci-search-form' do |f|
.input-group .input-group
= search_field_tag "search", params[:search], placeholder: "Search", class: "search-input form-control" = search_field_tag "search", params[:search], placeholder: "Search", class: "search-input form-control"
.input-group-addon .input-group-addon
%i.fa.fa-search %i.fa.fa-search
:coffeescript
$('.ci-search-form').submit ->
CiPager.init "#{ci_projects_path}" + "?search=" + query, #{Ci::ProjectsController::PROJECTS_BATCH}, false
false
- if current_user - if current_user
- if @offset > 0 .gray-content-block.top-block
= render @projects = render "search"
- else .projects
.gray-content-block.top-block .gray-content-block.clearfix.light.second-block
= render "search" .pull-left.fetch-status
.projects - if params[:search].present?
.gray-content-block.clearfix.light.second-block by keyword: "#{params[:search]}",
.pull-left.fetch-status #{@total_count} projects
- if params[:search].present?
by keyword: "#{params[:search]}",
#{@total_count} projects
.wide-table-holder .wide-table-holder
%table.table.projects-table.content-list %table.table.projects-table.content-list
%thead %thead
%tr %tr
%th Project Name %th Project Name
%th Last commit %th Last commit
%th Access %th Access
%th Commits %th Commits
= render @projects
%p.text-center.hide.loading
%i.fa.fa-refresh.fa-spin
:coffeescript
CiPager.init "#{ci_projects_path}", #{Ci::ProjectsController::PROJECTS_BATCH}, false
= render @projects
= paginate @projects, theme: 'gitlab'
- else - else
= render 'public' = render 'public'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment