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
9e682947
Commit
9e682947
authored
Oct 19, 2020
by
Emily Ring
Committed by
Rémy Coutable
Oct 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Order Cluster Agents by name
parent
17e9f197
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
3 deletions
+22
-3
app/models/clusters/agent.rb
app/models/clusters/agent.rb
+1
-0
ee/app/assets/javascripts/clusters_list/components/agents.vue
...pp/assets/javascripts/clusters_list/components/agents.vue
+1
-2
ee/app/finders/clusters/agents_finder.rb
ee/app/finders/clusters/agents_finder.rb
+1
-1
ee/changelogs/unreleased/257864-order-agent-list.yml
ee/changelogs/unreleased/257864-order-agent-list.yml
+5
-0
spec/models/clusters/agent_spec.rb
spec/models/clusters/agent_spec.rb
+14
-0
No files found.
app/models/clusters/agent.rb
View file @
9e682947
...
@@ -8,6 +8,7 @@ module Clusters
...
@@ -8,6 +8,7 @@ module Clusters
has_many
:agent_tokens
,
class_name:
'Clusters::AgentToken'
has_many
:agent_tokens
,
class_name:
'Clusters::AgentToken'
scope
:ordered_by_name
,
->
{
order
(
:name
)
}
scope
:with_name
,
->
(
name
)
{
where
(
name:
name
)
}
scope
:with_name
,
->
(
name
)
{
where
(
name:
name
)
}
validates
:name
,
validates
:name
,
...
...
ee/app/assets/javascripts/clusters_list/components/agents.vue
View file @
9e682947
<
script
>
<
script
>
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
sortBy
}
from
'
lodash
'
;
import
AgentEmptyState
from
'
./agent_empty_state.vue
'
;
import
AgentEmptyState
from
'
./agent_empty_state.vue
'
;
import
AgentTable
from
'
./agent_table.vue
'
;
import
AgentTable
from
'
./agent_table.vue
'
;
import
getAgentsQuery
from
'
../graphql/queries/get_agents.query.graphql
'
;
import
getAgentsQuery
from
'
../graphql/queries/get_agents.query.graphql
'
;
...
@@ -26,7 +25,7 @@ export default {
...
@@ -26,7 +25,7 @@ export default {
});
});
}
}
return
sortBy
(
agentList
,
'
name
'
)
;
return
agentList
;
},
},
},
},
},
},
...
...
ee/app/finders/clusters/agents_finder.rb
View file @
9e682947
...
@@ -14,7 +14,7 @@ module Clusters
...
@@ -14,7 +14,7 @@ module Clusters
agents
=
project
.
cluster_agents
agents
=
project
.
cluster_agents
agents
=
agents
.
with_name
(
params
[
:name
])
if
params
[
:name
].
present?
agents
=
agents
.
with_name
(
params
[
:name
])
if
params
[
:name
].
present?
agents
agents
.
ordered_by_name
end
end
private
private
...
...
ee/changelogs/unreleased/257864-order-agent-list.yml
0 → 100644
View file @
9e682947
---
title
:
Order cluster agents query by name
merge_request
:
45165
author
:
type
:
changed
spec/models/clusters/agent_spec.rb
View file @
9e682947
...
@@ -13,6 +13,20 @@ RSpec.describe Clusters::Agent do
...
@@ -13,6 +13,20 @@ RSpec.describe Clusters::Agent do
it
{
is_expected
.
to
validate_uniqueness_of
(
:name
).
scoped_to
(
:project_id
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:name
).
scoped_to
(
:project_id
)
}
describe
'scopes'
do
describe
'scopes'
do
describe
'.ordered_by_name'
do
let
(
:names
)
{
%w(agent-d agent-b agent-a agent-c)
}
subject
{
described_class
.
ordered_by_name
}
before
do
names
.
each
do
|
name
|
create
(
:cluster_agent
,
name:
name
)
end
end
it
{
expect
(
subject
.
map
(
&
:name
)).
to
eq
(
names
.
sort
)
}
end
describe
'.with_name'
do
describe
'.with_name'
do
let!
(
:matching_name
)
{
create
(
:cluster_agent
,
name:
'matching-name'
)
}
let!
(
:matching_name
)
{
create
(
:cluster_agent
,
name:
'matching-name'
)
}
let!
(
:other_name
)
{
create
(
:cluster_agent
,
name:
'other-name'
)
}
let!
(
:other_name
)
{
create
(
:cluster_agent
,
name:
'other-name'
)
}
...
...
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