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
16d12491
Commit
16d12491
authored
Jun 08, 2018
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add status filter to admin runners page
parent
bbc305b1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
16 deletions
+112
-16
app/controllers/admin/runners_controller.rb
app/controllers/admin/runners_controller.rb
+1
-0
app/views/admin/runners/_statuses.html.haml
app/views/admin/runners/_statuses.html.haml
+13
-0
app/views/admin/runners/index.html.haml
app/views/admin/runners/index.html.haml
+11
-7
spec/features/admin/admin_runners_spec.rb
spec/features/admin/admin_runners_spec.rb
+87
-9
No files found.
app/controllers/admin/runners_controller.rb
View file @
16d12491
...
...
@@ -5,6 +5,7 @@ class Admin::RunnersController < Admin::ApplicationController
sort
=
params
[
:sort
]
==
'contacted_asc'
?
{
contacted_at: :asc
}
:
{
id: :desc
}
@runners
=
Ci
::
Runner
.
order
(
sort
)
@runners
=
@runners
.
search
(
params
[
:search
])
if
params
[
:search
].
present?
@runners
=
@runners
.
public_send
(
params
[
:status
])
if
params
[
:status
].
present?
&&
Ci
::
Runner
::
AVAILABLE_STATUSES
.
include?
(
params
[
:status
])
@runners
=
@runners
.
page
(
params
[
:page
]).
per
(
30
)
@active_runners_cnt
=
Ci
::
Runner
.
online
.
count
end
...
...
app/views/admin/runners/_statuses.html.haml
0 → 100644
View file @
16d12491
-
active_status
=
params
[
:status
].
presence
-
toggle_text
=
'Status'
-
if
active_status
=
hidden_field_tag
:status
,
params
[
:status
]
-
toggle_text
=
params
[
:status
].
titleize
=
dropdown_tag
(
toggle_text
,
options:
{
wrapper_class:
'dropdown-menu-selectable'
,
title:
'Statuses'
})
do
%ul
%li
=
link_to
'Any Status'
,
admin_runners_path
(
safe_params
.
slice
(
:search
)),
class:
(
'is-active'
unless
active_status
)
%li
.divider
-
Ci
::
Runner
::
AVAILABLE_STATUSES
.
each
do
|
status
|
%li
=
link_to
status
.
titleize
,
admin_runners_path
(
safe_params
.
slice
(
:search
).
merge
(
status:
status
)),
class:
(
'is-active'
if
active_status
==
status
)
app/views/admin/runners/index.html.haml
View file @
16d12491
...
...
@@ -42,14 +42,18 @@
locals:
{
registration_token:
Gitlab
::
CurrentSettings
.
runners_registration_token
}
.append-bottom-20.clearfix
.float-left
=
form_tag
admin_runners_path
,
id:
'runners-search'
,
class:
'form-inline'
,
method: :get
do
.form-group
=
search_field_tag
:search
,
params
[
:search
],
class:
'form-control input-short'
,
placeholder:
'Runner description or token'
,
spellcheck:
false
=
submit_tag
'Search'
,
class:
'btn'
=
form_tag
admin_runners_path
,
id:
'runners-search'
,
method: :get
do
.float-left
.form-inline
.form-group
=
search_field_tag
:search
,
params
[
:search
],
class:
'form-control input-short'
,
placeholder:
'Runner description or token'
,
spellcheck:
false
=
submit_tag
'Search'
,
class:
'btn'
.float-left.prepend-left-10
=
render
'statuses'
.float-right.light
Runners currently online:
#{
@active_runners_cnt
}
.float-right.light
Runners currently online:
#{
@active_runners_cnt
}
%br
...
...
spec/features/admin/admin_runners_spec.rb
View file @
16d12491
...
...
@@ -12,13 +12,11 @@ describe "Admin Runners" do
let
(
:pipeline
)
{
create
(
:ci_pipeline
)
}
context
"when there are runners"
do
before
do
it
'has all necessary texts'
do
runner
=
FactoryBot
.
create
(
:ci_runner
,
contacted_at:
Time
.
now
)
FactoryBot
.
create
(
:ci_build
,
pipeline:
pipeline
,
runner_id:
runner
.
id
)
visit
admin_runners_path
end
it
'has all necessary texts'
do
expect
(
page
).
to
have_text
"Setup a shared Runner manually"
expect
(
page
).
to
have_text
"Runners currently online: 1"
end
...
...
@@ -27,25 +25,105 @@ describe "Admin Runners" do
before
do
FactoryBot
.
create
:ci_runner
,
description:
'runner-foo'
FactoryBot
.
create
:ci_runner
,
description:
'runner-bar'
visit
admin_runners_path
end
it
'shows correct runner when description matches'
do
search_form
=
find
(
'#runners-search'
)
search_form
.
fill_in
'search'
,
with:
'runner-foo'
search_form
.
click_button
'Search'
within
'#runners-search'
do
fill_in
'search'
,
with:
'runner-foo'
click_button
'Search'
end
expect
(
page
).
to
have_content
(
"runner-foo"
)
expect
(
page
).
not_to
have_content
(
"runner-bar"
)
end
it
'shows no runner when description does not match'
do
search_form
=
find
(
'#runners-search'
)
search_form
.
fill_in
'search'
,
with:
'runner-baz'
search_form
.
click_button
'Search'
within
'#runners-search'
do
fill_in
'search'
,
with:
'runner-baz'
click_button
'Search'
end
expect
(
page
).
to
have_text
'No runners found'
end
end
describe
'filter by status'
,
:js
do
it
'shows correct runner when status matches'
do
FactoryBot
.
create
:ci_runner
,
description:
'runner-active'
,
active:
true
FactoryBot
.
create
:ci_runner
,
description:
'runner-paused'
,
active:
false
visit
admin_runners_path
expect
(
page
).
to
have_content
'runner-active'
expect
(
page
).
to
have_content
'runner-paused'
click_button
'Status'
click_link
'Active'
expect
(
page
).
to
have_content
'runner-active'
expect
(
page
).
not_to
have_content
'runner-paused'
end
it
'shows no runner when status does not match'
do
FactoryBot
.
create
:ci_runner
,
:online
,
description:
'runner-active'
,
active:
true
FactoryBot
.
create
:ci_runner
,
:online
,
description:
'runner-paused'
,
active:
false
visit
admin_runners_path
click_button
'Status'
click_link
'Offline'
expect
(
page
).
not_to
have_content
'runner-active'
expect
(
page
).
not_to
have_content
'runner-paused'
expect
(
page
).
to
have_text
'No runners found'
end
end
describe
'filter by status and enter search term'
,
:js
do
before
do
FactoryBot
.
create
:ci_runner
,
description:
'runner-a-1'
,
active:
true
FactoryBot
.
create
:ci_runner
,
description:
'runner-a-2'
,
active:
false
FactoryBot
.
create
:ci_runner
,
description:
'runner-b-1'
,
active:
true
visit
admin_runners_path
end
it
'shows correct runner when status is selected first and then search term is entered'
do
click_button
'Status'
click_link
'Active'
expect
(
page
).
to
have_content
'runner-a-1'
expect
(
page
).
to
have_content
'runner-b-1'
expect
(
page
).
not_to
have_content
'runner-a-2'
within
'#runners-search'
do
fill_in
'search'
,
with:
'runner-a'
click_button
'Search'
end
expect
(
page
).
to
have_content
'runner-a-1'
expect
(
page
).
not_to
have_content
'runner-b-1'
expect
(
page
).
not_to
have_content
'runner-a-2'
end
it
'shows correct runner when search term is entered first and then status is selected'
do
within
'#runners-search'
do
fill_in
'search'
,
with:
'runner-a'
click_button
'Search'
end
expect
(
page
).
to
have_content
'runner-a-1'
expect
(
page
).
to
have_content
'runner-a-2'
expect
(
page
).
not_to
have_content
'runner-b-1'
click_button
'Status'
click_link
'Active'
expect
(
page
).
to
have_content
'runner-a-1'
expect
(
page
).
not_to
have_content
'runner-b-1'
expect
(
page
).
not_to
have_content
'runner-a-2'
end
end
end
context
"when there are no runners"
do
...
...
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