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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
34bdb747
Commit
34bdb747
authored
Jul 12, 2018
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add sort dropdown to admin runners page
parent
89b30999
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
75 additions
and
10 deletions
+75
-10
app/controllers/admin/runners_controller.rb
app/controllers/admin/runners_controller.rb
+3
-1
app/finders/admin/runners_finder.rb
app/finders/admin/runners_finder.rb
+9
-1
app/helpers/sorting_helper.rb
app/helpers/sorting_helper.rb
+10
-1
app/views/admin/runners/_sort_dropdown.html.haml
app/views/admin/runners/_sort_dropdown.html.haml
+11
-0
app/views/admin/runners/index.html.haml
app/views/admin/runners/index.html.haml
+3
-1
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/features/admin/admin_runners_spec.rb
spec/features/admin/admin_runners_spec.rb
+30
-0
spec/finders/admin/runners_finder_spec.rb
spec/finders/admin/runners_finder_spec.rb
+6
-6
No files found.
app/controllers/admin/runners_controller.rb
View file @
34bdb747
...
...
@@ -2,8 +2,10 @@ class Admin::RunnersController < Admin::ApplicationController
before_action
:runner
,
except: :index
def
index
@runners
=
Admin
::
RunnersFinder
.
new
(
params:
params
).
execute
finder
=
Admin
::
RunnersFinder
.
new
(
params:
params
)
@runners
=
finder
.
execute
@active_runners_cnt
=
Ci
::
Runner
.
online
.
count
@sort
=
finder
.
sort_key
end
def
show
...
...
app/finders/admin/runners_finder.rb
View file @
34bdb747
...
...
@@ -14,6 +14,14 @@ class Admin::RunnersFinder < UnionFinder
@runners
end
def
sort_key
if
@params
[
:sort
]
==
'contacted_asc'
'contacted_asc'
else
'created_date'
end
end
private
def
search!
...
...
@@ -33,7 +41,7 @@ class Admin::RunnersFinder < UnionFinder
end
def
sort!
sort
=
@params
[
:sort
]
==
'contacted_asc'
?
{
contacted_at: :asc
}
:
{
id
: :desc
}
sort
=
sort_key
==
'contacted_asc'
?
{
contacted_at: :asc
}
:
{
created_at
: :desc
}
@runners
=
@runners
.
order
(
sort
)
end
...
...
app/helpers/sorting_helper.rb
View file @
34bdb747
...
...
@@ -22,7 +22,8 @@ module SortingHelper
sort_value_recently_updated
=>
sort_title_recently_updated
,
sort_value_popularity
=>
sort_title_popularity
,
sort_value_priority
=>
sort_title_priority
,
sort_value_upvotes
=>
sort_title_upvotes
sort_value_upvotes
=>
sort_title_upvotes
,
sort_value_contacted_date
=>
sort_title_contacted_date
}
end
...
...
@@ -228,6 +229,10 @@ module SortingHelper
s_
(
'SortOptions|Most popular'
)
end
def
sort_title_contacted_date
s_
(
'SortOptions|Last Contact'
)
end
# Values.
def
sort_value_access_level_asc
'access_level_asc'
...
...
@@ -348,4 +353,8 @@ module SortingHelper
def
sort_value_upvotes
'upvotes_desc'
end
def
sort_value_contacted_date
'contacted_asc'
end
end
app/views/admin/runners/_sort_dropdown.html.haml
0 → 100644
View file @
34bdb747
-
sorted_by
=
sort_options_hash
[
@sort
]
.dropdown.inline.prepend-left-10
%button
.dropdown-toggle
{
type:
'button'
,
data:
{
toggle:
'dropdown'
,
display:
'static'
}
}
=
sorted_by
=
icon
(
'chevron-down'
)
%ul
.dropdown-menu.dropdown-menu-right.dropdown-menu-selectable.dropdown-menu-sort
%li
=
sortable_item
(
sort_title_created_date
,
page_filter_path
(
sort:
sort_value_created_date
,
label:
true
),
sorted_by
)
=
sortable_item
(
sort_title_contacted_date
,
page_filter_path
(
sort:
sort_value_contacted_date
,
label:
true
),
sorted_by
)
app/views/admin/runners/index.html.haml
View file @
34bdb747
...
...
@@ -82,6 +82,8 @@
=
status
.
titleize
=
button_tag
class:
%w[clear-search hidden]
do
=
icon
(
'times'
)
.filter-dropdown-container
=
render
'sort_dropdown'
.clearfix
.float-right.light
.prepend-top-10
...
...
@@ -103,7 +105,7 @@
%th
Projects
%th
Jobs
%th
Tags
%th
=
link_to
'Last contact'
,
admin_runners_path
(
safe_params
.
slice
(
:search
).
merge
(
sort:
'contacted_asc'
))
%th
Last contact
%th
-
@runners
.
each
do
|
runner
|
...
...
locale/gitlab.pot
View file @
34bdb747
...
...
@@ -5175,6 +5175,9 @@ msgstr ""
msgid "SortOptions|Largest repository"
msgstr ""
msgid "SortOptions|Last Contact"
msgstr ""
msgid "SortOptions|Last created"
msgstr ""
...
...
spec/features/admin/admin_runners_spec.rb
View file @
34bdb747
...
...
@@ -3,6 +3,7 @@ require 'spec_helper'
describe
"Admin Runners"
,
:js
do
include
StubENV
include
FilteredSearchHelpers
include
SortingHelper
before
do
stub_env
(
'IN_MEMORY_APPLICATION_SETTINGS'
,
'false'
)
...
...
@@ -91,6 +92,35 @@ describe "Admin Runners", :js do
expect
(
page
).
not_to
have_content
'runner-b-1'
expect
(
page
).
not_to
have_content
'runner-a-2'
end
it
'sorts by last contact date'
do
FactoryBot
.
create
:ci_runner
,
description:
'runner-1'
,
created_at:
'2018-07-12 15:37'
,
contacted_at:
'2018-07-12 15:37'
FactoryBot
.
create
:ci_runner
,
description:
'runner-2'
,
created_at:
'2018-07-12 16:37'
,
contacted_at:
'2018-07-12 16:37'
visit
admin_runners_path
within
'.runners-content tbody'
do
within
(
'tr:nth-child(1)'
)
do
expect
(
page
).
to
have_content
'runner-2'
end
within
(
'tr:nth-child(2)'
)
do
expect
(
page
).
to
have_content
'runner-1'
end
end
sorting_by
'Last Contact'
within
'.runners-content tbody'
do
within
(
'tr:nth-child(1)'
)
do
expect
(
page
).
to
have_content
'runner-1'
end
within
(
'tr:nth-child(2)'
)
do
expect
(
page
).
to
have_content
'runner-2'
end
end
end
end
context
"when there are no runners"
do
...
...
spec/finders/admin/runners_finder_spec.rb
View file @
34bdb747
...
...
@@ -29,10 +29,10 @@ describe Admin::RunnersFinder do
context
'sort'
do
context
'without sort param'
do
it
'sorts by
id
'
do
runner1
=
create
:ci_runner
runner2
=
create
:ci_runner
runner3
=
create
:ci_runner
it
'sorts by
created_at
'
do
runner1
=
create
:ci_runner
,
created_at:
'2018-07-12 07:00'
runner2
=
create
:ci_runner
,
created_at:
'2018-07-12 08:00'
runner3
=
create
:ci_runner
,
created_at:
'2018-07-12 09:00'
expect
(
described_class
.
new
(
params:
{}).
execute
).
to
eq
[
runner3
,
runner2
,
runner1
]
end
...
...
@@ -52,8 +52,8 @@ describe Admin::RunnersFinder do
context
'paginate'
do
it
'returns the runners for the specified page'
do
stub_const
(
'Admin::RunnersFinder::NUMBER_OF_RUNNERS_PER_PAGE'
,
1
)
runner1
=
create
:ci_runner
runner2
=
create
:ci_runner
runner1
=
create
:ci_runner
,
created_at:
'2018-07-12 07:00'
runner2
=
create
:ci_runner
,
created_at:
'2018-07-12 08:00'
expect
(
described_class
.
new
(
params:
{
page:
1
}).
execute
).
to
eq
[
runner2
]
expect
(
described_class
.
new
(
params:
{
page:
2
}).
execute
).
to
eq
[
runner1
]
...
...
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