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
Boxiang Sun
gitlab-ce
Commits
a1094e23
Commit
a1094e23
authored
Jun 11, 2018
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add type filter to admin runners page
parent
dc1e0f6b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
104 additions
and
17 deletions
+104
-17
app/assets/javascripts/filtered_search/admin_runners_filtered_search_token_keys.js
...ltered_search/admin_runners_filtered_search_token_keys.js
+7
-0
app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js
...ripts/filtered_search/filtered_search_dropdown_manager.js
+5
-0
app/finders/admin/runners_finder.rb
app/finders/admin/runners_finder.rb
+14
-4
app/views/admin/runners/index.html.haml
app/views/admin/runners/index.html.haml
+9
-0
spec/features/admin/admin_runners_spec.rb
spec/features/admin/admin_runners_spec.rb
+61
-13
spec/finders/admin/runners_finder_spec.rb
spec/finders/admin/runners_finder_spec.rb
+8
-0
No files found.
app/assets/javascripts/filtered_search/admin_runners_filtered_search_token_keys.js
View file @
a1094e23
...
...
@@ -7,6 +7,13 @@ const tokenKeys = [{
symbol
:
''
,
icon
:
'
signal
'
,
tag
:
'
status
'
,
},
{
key
:
'
type
'
,
type
:
'
string
'
,
param
:
'
type
'
,
symbol
:
''
,
icon
:
'
cube
'
,
tag
:
'
type
'
,
}];
const
AdminRunnersFilteredSearchTokenKeys
=
new
FilteredSearchTokenKeys
(
tokenKeys
);
...
...
app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js
View file @
a1094e23
...
...
@@ -96,6 +96,11 @@ export default class FilteredSearchDropdownManager {
gl
:
NullDropdown
,
element
:
this
.
container
.
querySelector
(
'
#js-dropdown-admin-runner-status
'
),
},
type
:
{
reference
:
null
,
gl
:
NullDropdown
,
element
:
this
.
container
.
querySelector
(
'
#js-dropdown-admin-runner-type
'
),
},
};
supportedTokens
.
forEach
((
type
)
=>
{
...
...
app/finders/admin/runners_finder.rb
View file @
a1094e23
...
...
@@ -10,6 +10,7 @@ class Admin::RunnersFinder < UnionFinder
def
execute
search!
filter_by_status!
filter_by_runner_type!
sort!
paginate!
...
...
@@ -36,10 +37,11 @@ class Admin::RunnersFinder < UnionFinder
end
def
filter_by_status!
status
=
@params
[
:status_status
]
if
status
.
present?
&&
Ci
::
Runner
::
AVAILABLE_STATUSES
.
include?
(
status
)
@runners
=
@runners
.
public_send
(
status
)
# rubocop:disable GitlabSecurity/PublicSend
end
filter_by!
(
:status_status
,
Ci
::
Runner
::
AVAILABLE_STATUSES
)
end
def
filter_by_runner_type!
filter_by!
(
:type_type
,
Ci
::
Runner
::
AVAILABLE_TYPES
)
end
def
sort!
...
...
@@ -49,4 +51,12 @@ class Admin::RunnersFinder < UnionFinder
def
paginate!
@runners
=
@runners
.
page
(
@params
[
:page
]).
per
(
NUMBER_OF_RUNNERS_PER_PAGE
)
end
def
filter_by!
(
scope_name
,
available_scopes
)
scope
=
@params
[
scope_name
]
if
scope
.
present?
&&
available_scopes
.
include?
(
scope
)
@runners
=
@runners
.
public_send
(
scope
)
# rubocop:disable GitlabSecurity/PublicSend
end
end
end
app/views/admin/runners/index.html.haml
View file @
a1094e23
...
...
@@ -82,12 +82,21 @@
{{hint}}
%span
.js-filter-tag.dropdown-light-content
{{tag}}
#js-dropdown-admin-runner-status
.filtered-search-input-dropdown-menu.dropdown-menu
%ul
{
data:
{
dropdown:
true
}
}
-
Ci
::
Runner
::
AVAILABLE_STATUSES
.
each
do
|
status
|
%li
.filter-dropdown-item
{
data:
{
value:
status
}
}
=
button_tag
class:
%w[btn btn-link]
do
=
status
.
titleize
#js-dropdown-admin-runner-type
.filtered-search-input-dropdown-menu.dropdown-menu
%ul
{
data:
{
dropdown:
true
}
}
-
Ci
::
Runner
::
AVAILABLE_TYPES
.
each
do
|
runner_type
|
%li
.filter-dropdown-item
{
data:
{
value:
runner_type
}
}
=
button_tag
class:
%w[btn btn-link]
do
=
runner_type
.
titleize
=
button_tag
class:
%w[clear-search hidden]
do
=
icon
(
'times'
)
.filter-dropdown-container
...
...
spec/features/admin/admin_runners_spec.rb
View file @
a1094e23
...
...
@@ -73,24 +73,72 @@ describe "Admin Runners" do
expect
(
page
).
to
have_text
'No runners found'
end
it
'shows correct runner when status is selected and search term is entered'
do
create
(
:ci_runner
,
description:
'runner-a-1'
,
active:
true
)
create
(
:ci_runner
,
description:
'runner-a-2'
,
active:
false
)
create
(
:ci_runner
,
description:
'runner-b-1'
,
active:
true
)
visit
admin_runners_path
input_filtered_search_keys
(
'status: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'
input_filtered_search_keys
(
'status:active runner-a'
)
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
it
'shows correct runner when status is selected and search term is entered
'
,
:js
do
create
(
:ci_runner
,
description:
'runner-a-1'
,
active:
true
)
create
(
:ci_runner
,
description:
'runner-a-2'
,
active:
false
)
create
(
:ci_runner
,
description:
'runner-b-1'
,
active:
true
)
describe
'filter by type
'
,
:js
do
it
'shows correct runner when type matches'
do
create
:ci_runner
,
:project
,
description:
'runner-project'
create
:ci_runner
,
:group
,
description:
'runner-group'
visit
admin_runners_path
visit
admin_runners_path
expect
(
page
).
to
have_content
'runner-project'
expect
(
page
).
to
have_content
'runner-group'
input_filtered_search_keys
(
'status: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'
input_filtered_search_keys
(
'type:project_type'
)
expect
(
page
).
to
have_content
'runner-project'
expect
(
page
).
not_to
have_content
'runner-group'
end
it
'shows no runner when type does not match'
do
create
:ci_runner
,
:project
,
description:
'runner-project'
create
:ci_runner
,
:group
,
description:
'runner-group'
input_filtered_search_keys
(
'status:active runner-a'
)
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'
visit
admin_runners_path
input_filtered_search_keys
(
'type:instance_type'
)
expect
(
page
).
not_to
have_content
'runner-project'
expect
(
page
).
not_to
have_content
'runner-group'
expect
(
page
).
to
have_text
'No runners found'
end
it
'shows correct runner when type is selected and search term is entered'
do
create
:ci_runner
,
:project
,
description:
'runner-a-1'
create
:ci_runner
,
:instance
,
description:
'runner-a-2'
create
:ci_runner
,
:project
,
description:
'runner-b-1'
visit
admin_runners_path
input_filtered_search_keys
(
'type:project_type'
)
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'
input_filtered_search_keys
(
'type:project_type runner-a'
)
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
it
'sorts by last contact date'
,
:js
do
...
...
spec/finders/admin/runners_finder_spec.rb
View file @
a1094e23
...
...
@@ -29,6 +29,14 @@ describe Admin::RunnersFinder do
end
end
context
'filter by runner type'
do
it
'calls the corresponding scope on Ci::Runner'
do
expect
(
Ci
::
Runner
).
to
receive
(
:project_type
).
and_call_original
described_class
.
new
(
params:
{
type_type:
'project_type'
}).
execute
end
end
context
'sort'
do
context
'without sort param'
do
it
'sorts by created_at'
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