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: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
aba9668ace
commit
0731a7af31
5 changed files with 21 additions and 109 deletions
|
@ -1,42 +0,0 @@
|
|||
@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()
|
|
@ -1,11 +1,9 @@
|
|||
module Ci
|
||||
class ProjectsController < Ci::ApplicationController
|
||||
PROJECTS_BATCH = 100
|
||||
|
||||
before_action :authenticate_user!, except: [:build, :badge, :index, :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_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 :authenticate_token!, only: [:build]
|
||||
before_action :no_cache, only: [:badge]
|
||||
|
@ -18,14 +16,9 @@ module Ci
|
|||
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)
|
||||
|
||||
@projects = @projects.page(params[:page]).per(40)
|
||||
@total_count = @projects.size
|
||||
end
|
||||
|
||||
|
@ -48,22 +41,6 @@ module Ci
|
|||
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)
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -24,14 +24,3 @@
|
|||
Private
|
||||
%td
|
||||
= 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'
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
.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
|
||||
= search_field_tag "search", params[:search], placeholder: "Search", class: "search-input form-control"
|
||||
.input-group-addon
|
||||
%i.fa.fa-search
|
||||
|
||||
:coffeescript
|
||||
$('.ci-search-form').submit ->
|
||||
CiPager.init "#{ci_projects_path}" + "?search=" + query, #{Ci::ProjectsController::PROJECTS_BATCH}, false
|
||||
false
|
||||
|
|
|
@ -1,30 +1,23 @@
|
|||
- if current_user
|
||||
- if @offset > 0
|
||||
= render @projects
|
||||
- else
|
||||
.gray-content-block.top-block
|
||||
= render "search"
|
||||
.projects
|
||||
.gray-content-block.clearfix.light.second-block
|
||||
.pull-left.fetch-status
|
||||
- if params[:search].present?
|
||||
by keyword: "#{params[:search]}",
|
||||
#{@total_count} projects
|
||||
.gray-content-block.top-block
|
||||
= render "search"
|
||||
.projects
|
||||
.gray-content-block.clearfix.light.second-block
|
||||
.pull-left.fetch-status
|
||||
- if params[:search].present?
|
||||
by keyword: "#{params[:search]}",
|
||||
#{@total_count} projects
|
||||
|
||||
.wide-table-holder
|
||||
%table.table.projects-table.content-list
|
||||
%thead
|
||||
%tr
|
||||
%th Project Name
|
||||
%th Last commit
|
||||
%th Access
|
||||
%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
|
||||
.wide-table-holder
|
||||
%table.table.projects-table.content-list
|
||||
%thead
|
||||
%tr
|
||||
%th Project Name
|
||||
%th Last commit
|
||||
%th Access
|
||||
%th Commits
|
||||
|
||||
= render @projects
|
||||
= paginate @projects, theme: 'gitlab'
|
||||
- else
|
||||
= render 'public'
|
||||
|
|
Loading…
Reference in a new issue