Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b7e49d80
Commit
b7e49d80
authored
Sep 17, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: ci projects order
parent
2e9a7032
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
93 additions
and
95 deletions
+93
-95
app/controllers/ci/projects_controller.rb
app/controllers/ci/projects_controller.rb
+9
-15
app/views/ci/projects/_gl_projects.html.haml
app/views/ci/projects/_gl_projects.html.haml
+0
-15
app/views/ci/projects/_project.html.haml
app/views/ci/projects/_project.html.haml
+36
-22
app/views/ci/projects/_search.html.haml
app/views/ci/projects/_search.html.haml
+1
-7
app/views/ci/projects/gitlab.html.haml
app/views/ci/projects/gitlab.html.haml
+0
-27
app/views/ci/projects/index.html.haml
app/views/ci/projects/index.html.haml
+25
-8
lib/ci/project_list_builder.rb
lib/ci/project_list_builder.rb
+21
-0
spec/controllers/ci/projects_controller_spec.rb
spec/controllers/ci/projects_controller_spec.rb
+1
-1
No files found.
app/controllers/ci/projects_controller.rb
View file @
b7e49d80
...
@@ -5,38 +5,32 @@ module Ci
...
@@ -5,38 +5,32 @@ module Ci
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
,
:
gitlab
,
:
badge
,
:index
,
:show
,
:new
,
:create
]
before_action
:authorize_access_project!
,
except:
[
:build
,
:badge
,
:index
,
:show
,
:new
,
:create
]
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
]
protect_from_forgery
except: :build
protect_from_forgery
except: :build
layout
'ci/project'
,
except:
[
:index
,
:gitlab
]
layout
'ci/project'
,
except:
:index
def
index
def
index
@projects
=
Ci
::
Project
.
ordered_by_last_commit_date
.
public_only
.
page
(
params
[
:page
])
unless
current_user
end
def
gitlab
@limit
,
@offset
=
(
params
[
:limit
]
||
PROJECTS_BATCH
).
to_i
,
(
params
[
:offset
]
||
0
).
to_i
@limit
,
@offset
=
(
params
[
:limit
]
||
PROJECTS_BATCH
).
to_i
,
(
params
[
:offset
]
||
0
).
to_i
@page
=
@offset
==
0
?
1
:
(
@offset
/
@limit
+
1
)
@page
=
@offset
==
0
?
1
:
(
@offset
/
@limit
+
1
)
@gl_projects
=
current_user
.
authorized_projects
if
current_user
@gl_projects
=
@gl_projects
.
where
(
"name LIKE ?"
,
"%
#{
params
[
:search
]
}
%"
)
if
params
[
:search
]
@projects
=
ProjectListBuilder
.
new
.
execute
(
current_user
,
params
[
:search
])
@gl_projects
=
@gl_projects
.
page
(
@page
).
per
(
@limit
)
@projects
=
Ci
::
Project
.
where
(
gitlab_id:
@gl_projects
.
map
(
&
:id
)).
ordered_by_last_commit_date
@projects
=
@projects
.
page
(
@page
).
per
(
@limit
)
@total_count
=
@gl_projects
.
size
@gl_projects
=
@gl_projects
.
where
.
not
(
id:
@projects
.
map
(
&
:gitlab_id
))
@total_count
=
@projects
.
size
end
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
json
do
format
.
json
do
pager_json
(
"ci/projects/
gitlab
"
,
@total_count
)
pager_json
(
"ci/projects/
index
"
,
@total_count
)
end
end
format
.
html
end
end
rescue
@error
=
'Failed to fetch GitLab projects'
end
end
def
show
def
show
...
...
app/views/ci/projects/_gl_projects.html.haml
deleted
100644 → 0
View file @
2e9a7032
-
@gl_projects
.
sort_by
(
&
:name_with_namespace
).
each
do
|
project
|
%tr
.light
%td
=
project
.
name_with_namespace
%td
%small
Not added to CI
%td
%td
-
if
Ci
::
Project
.
already_added?
(
project
)
%strong
.cgreen
Added
-
else
=
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'
app/views/ci/projects/_project.html.haml
View file @
b7e49d80
-
last_commit
=
project
.
last_commit
-
if
project
.
gitlab_ci_project
%tr
.alert
{
class:
commit_status_alert_class
(
last_commit
)
}
-
ci_project
=
project
.
gitlab_ci_project
%td
-
last_commit
=
ci_project
.
last_commit
=
link_to
[
:ci
,
project
]
do
%tr
.alert
{
class:
commit_status_alert_class
(
last_commit
)
}
=
project
.
name
%td
%td
=
link_to
[
:ci
,
ci_project
]
do
-
if
last_commit
=
ci_project
.
name
#{
last_commit
.
status
}
(
#{
commit_link
(
last_commit
)
}
)
%td
-
if
project
.
last_commit_date
-
if
last_commit
=
time_ago_in_words
project
.
last_commit_date
#{
last_commit
.
status
}
(
#{
commit_link
(
last_commit
)
}
)
ago
-
if
ci_project
.
last_commit_date
-
else
=
time_ago_in_words
ci_project
.
last_commit_date
No builds yet
ago
%td
-
else
-
if
project
.
public
No builds yet
%i
.fa.fa-globe
%td
Public
-
if
ci_project
.
public
-
else
%i
.fa.fa-globe
%i
.fa.fa-lock
Public
Private
-
else
%td
%i
.fa.fa-lock
=
project
.
commits
.
count
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'
\ No newline at end of file
app/views/ci/projects/_search.html.haml
View file @
b7e49d80
...
@@ -5,13 +5,7 @@
...
@@ -5,13 +5,7 @@
.input-group-addon
.input-group-addon
%i
.fa.fa-search
%i
.fa.fa-search
:coffeescript
:coffeescript
$('.ci-search-form').submit ->
$('.ci-search-form').submit ->
NProgress.start()
CiPager.init "
#{
ci_projects_path
}
" + "?search=" + query,
#{
Ci
::
ProjectsController
::
PROJECTS_BATCH
}
, false
query = $('.ci-search-form .search-input').val()
$.get '
#{
gitlab_ci_projects_path
}
', { search: query }, (data) ->
$(".projects").html data.html
NProgress.done()
CiPager.init "
#{
gitlab_ci_projects_path
}
" + "?search=" + query,
#{
Ci
::
ProjectsController
::
PROJECTS_BATCH
}
, false
false
false
app/views/ci/projects/gitlab.html.haml
deleted
100644 → 0
View file @
2e9a7032
-
if
@offset
==
0
.gray-content-block.clearfix.light.second-block
.pull-left.fetch-status
-
if
params
[
:search
].
present?
by keyword: "
#{
params
[
:search
]
}
",
#{
@total_count
}
projects,
#{
@projects
.
size
}
of them added to CI
.wide-table-holder
%table
.table.projects-table.content-list
%thead
%tr
%th
Project Name
%th
Last commit
%th
Access
%th
Commits
=
render
@projects
=
render
"gl_projects"
%p
.text-center.hide.loading
%i
.fa.fa-refresh.fa-spin
-
else
=
render
@projects
=
render
"gl_projects"
app/views/ci/projects/index.html.haml
View file @
b7e49d80
-
if
current_user
-
if
current_user
.gray-content-block.top-block
-
if
@offset
>
0
=
render
"search"
=
render
@projects
.projects
-
else
%p
.fetch-status.light
.gray-content-block.top-block
%i
.fa.fa-refresh.fa-spin
=
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
:coffeescript
$.get '
#{
gitlab_ci_projects_path
}
', (data) ->
CiPager.init "
#{
ci_projects_path
}
",
#{
Ci
::
ProjectsController
::
PROJECTS_BATCH
}
, false
$(".projects").html data.html
CiPager.init "
#{
gitlab_ci_projects_path
}
",
#{
Ci
::
ProjectsController
::
PROJECTS_BATCH
}
, false
-
else
-
else
=
render
'public'
=
render
'public'
lib/ci/project_list_builder.rb
0 → 100644
View file @
b7e49d80
module
Ci
class
ProjectListBuilder
def
execute
(
current_user
,
search
=
nil
)
projects
=
current_user
.
authorized_projects
projects
=
projects
.
search
(
search
)
if
search
projects
.
joins
(
"LEFT JOIN ci_projects ON projects.id = ci_projects.gitlab_id
LEFT JOIN
#{
last_commit_subquery
}
AS last_commit ON
#{
Ci
::
Project
.
table_name
}
.id = last_commit.project_id"
).
reorder
(
"ci_projects.id is NULL ASC,
CASE WHEN last_commit.committed_at IS NULL THEN 1 ELSE 0 END,
last_commit.committed_at DESC"
)
end
private
def
last_commit_subquery
"(SELECT project_id, MAX(committed_at) committed_at FROM
#{
Ci
::
Commit
.
table_name
}
GROUP BY project_id)"
end
end
end
spec/controllers/ci/projects_controller_spec.rb
View file @
b7e49d80
...
@@ -84,7 +84,7 @@ describe Ci::ProjectsController do
...
@@ -84,7 +84,7 @@ describe Ci::ProjectsController do
end
end
it
"searches projects"
do
it
"searches projects"
do
xhr
:get
,
:
gitlab
,
{
search:
"str"
,
format:
"js
"
}.
with_indifferent_access
xhr
:get
,
:
index
,
{
search:
"str"
,
format:
"json
"
}.
with_indifferent_access
expect
(
response
).
to
be_success
expect
(
response
).
to
be_success
expect
(
response
.
code
).
to
eq
(
'200'
)
expect
(
response
.
code
).
to
eq
(
'200'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment