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
ed0a62df
Commit
ed0a62df
authored
Mar 09, 2021
by
Emily Ring
Committed by
Brandon Labuschagne
Mar 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add pagination to agent token table
Update clusters/agents vues and GraphQl to include pagination
parent
0d347294
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
157 additions
and
29 deletions
+157
-29
ee/app/assets/javascripts/clusters/agents/components/show.vue
...pp/assets/javascripts/clusters/agents/components/show.vue
+52
-3
ee/app/assets/javascripts/clusters/agents/constants.js
ee/app/assets/javascripts/clusters/agents/constants.js
+1
-0
ee/app/assets/javascripts/clusters/agents/graphql/queries/get_cluster_agent.query.graphql
...rs/agents/graphql/queries/get_cluster_agent.query.graphql
+14
-2
ee/changelogs/unreleased/298748-token-pagination.yml
ee/changelogs/unreleased/298748-token-pagination.yml
+5
-0
ee/spec/frontend/clusters/agents/components/show_spec.js
ee/spec/frontend/clusters/agents/components/show_spec.js
+85
-24
No files found.
ee/app/assets/javascripts/clusters/agents/components/show.vue
View file @
ed0a62df
<
script
>
<
script
>
import
{
GlAlert
,
GlBadge
,
GlLoadingIcon
,
GlSprintf
,
GlTab
,
GlTabs
}
from
'
@gitlab/ui
'
;
import
{
GlAlert
,
GlBadge
,
GlKeysetPagination
,
GlLoadingIcon
,
GlSprintf
,
GlTab
,
GlTabs
,
}
from
'
@gitlab/ui
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
s__
}
from
'
~/locale
'
;
import
TimeAgoTooltip
from
'
~/vue_shared/components/time_ago_tooltip.vue
'
;
import
TimeAgoTooltip
from
'
~/vue_shared/components/time_ago_tooltip.vue
'
;
import
{
MAX_LIST_COUNT
}
from
'
../constants
'
;
import
getClusterAgentQuery
from
'
../graphql/queries/get_cluster_agent.query.graphql
'
;
import
getClusterAgentQuery
from
'
../graphql/queries/get_cluster_agent.query.graphql
'
;
import
TokenTable
from
'
./token_table.vue
'
;
import
TokenTable
from
'
./token_table.vue
'
;
...
@@ -19,6 +28,7 @@ export default {
...
@@ -19,6 +28,7 @@ export default {
return
{
return
{
agentName
:
this
.
agentName
,
agentName
:
this
.
agentName
,
projectPath
:
this
.
projectPath
,
projectPath
:
this
.
projectPath
,
...
this
.
cursor
,
};
};
},
},
update
:
(
data
)
=>
data
?.
project
?.
clusterAgent
,
update
:
(
data
)
=>
data
?.
project
?.
clusterAgent
,
...
@@ -30,6 +40,7 @@ export default {
...
@@ -30,6 +40,7 @@ export default {
components
:
{
components
:
{
GlAlert
,
GlAlert
,
GlBadge
,
GlBadge
,
GlKeysetPagination
,
GlLoadingIcon
,
GlLoadingIcon
,
GlSprintf
,
GlSprintf
,
GlTab
,
GlTab
,
...
@@ -47,6 +58,14 @@ export default {
...
@@ -47,6 +58,14 @@ export default {
type
:
String
,
type
:
String
,
},
},
},
},
data
()
{
return
{
cursor
:
{
first
:
MAX_LIST_COUNT
,
last
:
null
,
},
};
},
computed
:
{
computed
:
{
createdAt
()
{
createdAt
()
{
return
this
.
clusterAgent
?.
createdAt
;
return
this
.
clusterAgent
?.
createdAt
;
...
@@ -57,13 +76,35 @@ export default {
...
@@ -57,13 +76,35 @@ export default {
isLoading
()
{
isLoading
()
{
return
this
.
$apollo
.
queries
.
clusterAgent
.
loading
;
return
this
.
$apollo
.
queries
.
clusterAgent
.
loading
;
},
},
showPagination
()
{
return
this
.
tokenPageInfo
.
hasPreviousPage
||
this
.
tokenPageInfo
.
hasNextPage
;
},
tokenCount
()
{
tokenCount
()
{
return
this
.
clusterAgent
?.
tokens
?.
count
;
return
this
.
clusterAgent
?.
tokens
?.
count
;
},
},
tokenPageInfo
()
{
return
this
.
clusterAgent
?.
tokens
?.
pageInfo
||
{};
},
tokens
()
{
tokens
()
{
return
this
.
clusterAgent
?.
tokens
?.
nodes
||
[];
return
this
.
clusterAgent
?.
tokens
?.
nodes
||
[];
},
},
},
},
methods
:
{
nextPage
()
{
this
.
cursor
=
{
first
:
MAX_LIST_COUNT
,
last
:
null
,
afterToken
:
this
.
tokenPageInfo
.
endCursor
,
};
},
prevPage
()
{
this
.
cursor
=
{
first
:
null
,
last
:
MAX_LIST_COUNT
,
beforeToken
:
this
.
tokenPageInfo
.
startCursor
,
};
},
},
};
};
</
script
>
</
script
>
...
@@ -71,7 +112,7 @@ export default {
...
@@ -71,7 +112,7 @@ export default {
<section>
<section>
<h2>
{{
agentName
}}
</h2>
<h2>
{{
agentName
}}
</h2>
<gl-loading-icon
v-if=
"isLoading"
size=
"lg"
class=
"gl-m-3"
/>
<gl-loading-icon
v-if=
"isLoading
&& clusterAgent == null
"
size=
"lg"
class=
"gl-m-3"
/>
<div
v-else-if=
"clusterAgent"
>
<div
v-else-if=
"clusterAgent"
>
<p
data-testid=
"cluster-agent-create-info"
>
<p
data-testid=
"cluster-agent-create-info"
>
...
@@ -98,7 +139,15 @@ export default {
...
@@ -98,7 +139,15 @@ export default {
</span>
</span>
</
template
>
</
template
>
<gl-loading-icon
v-if=
"isLoading"
size=
"md"
class=
"gl-m-3"
/>
<div
v-else
>
<TokenTable
:tokens=
"tokens"
/>
<TokenTable
:tokens=
"tokens"
/>
<div
v-if=
"showPagination"
class=
"gl-display-flex gl-justify-content-center gl-mt-5"
>
<gl-keyset-pagination
v-bind=
"tokenPageInfo"
@
prev=
"prevPage"
@
next=
"nextPage"
/>
</div>
</div>
</gl-tab>
</gl-tab>
</gl-tabs>
</gl-tabs>
</div>
</div>
...
...
ee/app/assets/javascripts/clusters/agents/constants.js
0 → 100644
View file @
ed0a62df
export
const
MAX_LIST_COUNT
=
25
;
ee/app/assets/javascripts/clusters/agents/graphql/queries/get_cluster_agent.query.graphql
View file @
ed0a62df
#import "~/graphql_shared/fragments/pageInfo.fragment.graphql"
#import "../fragments/cluster_agent_token.fragment.graphql"
#import "../fragments/cluster_agent_token.fragment.graphql"
query
getClusterAgent
(
$projectPath
:
ID
!,
$agentName
:
String
!)
{
query
getClusterAgent
(
$projectPath
:
ID
!
$agentName
:
String
!
$first
:
Int
$last
:
Int
$afterToken
:
String
$beforeToken
:
String
)
{
project
(
fullPath
:
$projectPath
)
{
project
(
fullPath
:
$projectPath
)
{
clusterAgent
(
name
:
$agentName
)
{
clusterAgent
(
name
:
$agentName
)
{
id
id
...
@@ -10,12 +18,16 @@ query getClusterAgent($projectPath: ID!, $agentName: String!) {
...
@@ -10,12 +18,16 @@ query getClusterAgent($projectPath: ID!, $agentName: String!) {
name
name
}
}
tokens
{
tokens
(
first
:
$first
,
last
:
$last
,
before
:
$beforeToken
,
after
:
$afterToken
)
{
count
count
nodes
{
nodes
{
...
Token
...
Token
}
}
pageInfo
{
...
PageInfo
}
}
}
}
}
}
}
...
...
ee/changelogs/unreleased/298748-token-pagination.yml
0 → 100644
View file @
ed0a62df
---
title
:
Add pagination to agent token table
merge_request
:
55788
author
:
type
:
changed
ee/spec/frontend/clusters/agents/components/show_spec.js
View file @
ed0a62df
import
{
GlAlert
,
GlLoadingIcon
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
GlAlert
,
Gl
KeysetPagination
,
Gl
LoadingIcon
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
createLocalVue
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
createLocalVue
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
ClusterAgentShow
from
'
ee/clusters/agents/components/show.vue
'
;
import
ClusterAgentShow
from
'
ee/clusters/agents/components/show.vue
'
;
...
@@ -31,6 +31,7 @@ describe('ClusterAgentShow', () => {
...
@@ -31,6 +31,7 @@ describe('ClusterAgentShow', () => {
tokens
:
{
tokens
:
{
count
:
1
,
count
:
1
,
nodes
:
[],
nodes
:
[],
pageInfo
:
null
,
},
},
};
};
...
@@ -47,17 +48,29 @@ describe('ClusterAgentShow', () => {
...
@@ -47,17 +48,29 @@ describe('ClusterAgentShow', () => {
});
});
};
};
const
findCreatedText
=
()
=>
wrapper
.
find
(
'
[data-testid="cluster-agent-create-info"]
'
).
text
();
const
createWrapperWithoutApollo
=
({
clusterAgent
,
loading
=
false
})
=>
{
const
findTokenCount
=
()
=>
wrapper
.
find
(
'
[data-testid="cluster-agent-token-count"]
'
).
text
()
;
const
$apollo
=
{
queries
:
{
clusterAgent
:
{
loading
}
}
}
;
beforeEach
(()
=>
{
wrapper
=
shallowMount
(
ClusterAgentShow
,
{
return
createWrapper
({
clusterAgent
:
defaultClusterAgent
});
propsData
,
mocks
:
{
$apollo
,
clusterAgent
},
});
});
};
const
findCreatedText
=
()
=>
wrapper
.
find
(
'
[data-testid="cluster-agent-create-info"]
'
).
text
();
const
findLoadingIcon
=
()
=>
wrapper
.
find
(
GlLoadingIcon
);
const
findPaginationButtons
=
()
=>
wrapper
.
find
(
GlKeysetPagination
);
const
findTokenCount
=
()
=>
wrapper
.
find
(
'
[data-testid="cluster-agent-token-count"]
'
).
text
();
afterEach
(()
=>
{
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
describe
(
'
default behaviour
'
,
()
=>
{
beforeEach
(()
=>
{
return
createWrapper
({
clusterAgent
:
defaultClusterAgent
});
});
it
(
'
displays the agent name
'
,
()
=>
{
it
(
'
displays the agent name
'
,
()
=>
{
expect
(
wrapper
.
text
()).
toContain
(
propsData
.
agentName
);
expect
(
wrapper
.
text
()).
toContain
(
propsData
.
agentName
);
});
});
...
@@ -66,6 +79,21 @@ describe('ClusterAgentShow', () => {
...
@@ -66,6 +79,21 @@ describe('ClusterAgentShow', () => {
expect
(
findCreatedText
()).
toMatchInterpolatedText
(
'
Created by user-1 2 days ago
'
);
expect
(
findCreatedText
()).
toMatchInterpolatedText
(
'
Created by user-1 2 days ago
'
);
});
});
it
(
'
displays token count
'
,
()
=>
{
expect
(
findTokenCount
()).
toMatchInterpolatedText
(
`
${
ClusterAgentShow
.
i18n
.
tokens
}
${
defaultClusterAgent
.
tokens
.
count
}
`
,
);
});
it
(
'
renders token table
'
,
()
=>
{
expect
(
wrapper
.
find
(
TokenTable
).
exists
()).
toBe
(
true
);
});
it
(
'
should not render pagination buttons when there are no additional pages
'
,
()
=>
{
expect
(
findPaginationButtons
().
exists
()).
toBe
(
false
);
});
});
describe
(
'
when create user is unknown
'
,
()
=>
{
describe
(
'
when create user is unknown
'
,
()
=>
{
const
missingUser
=
{
const
missingUser
=
{
...
defaultClusterAgent
,
...
defaultClusterAgent
,
...
@@ -81,12 +109,6 @@ describe('ClusterAgentShow', () => {
...
@@ -81,12 +109,6 @@ describe('ClusterAgentShow', () => {
});
});
});
});
it
(
'
displays token count
'
,
()
=>
{
expect
(
findTokenCount
()).
toMatchInterpolatedText
(
`
${
ClusterAgentShow
.
i18n
.
tokens
}
${
defaultClusterAgent
.
tokens
.
count
}
`
,
);
});
describe
(
'
when token count is missing
'
,
()
=>
{
describe
(
'
when token count is missing
'
,
()
=>
{
const
missingTokens
=
{
const
missingTokens
=
{
...
defaultClusterAgent
,
...
defaultClusterAgent
,
...
@@ -102,11 +124,37 @@ describe('ClusterAgentShow', () => {
...
@@ -102,11 +124,37 @@ describe('ClusterAgentShow', () => {
});
});
});
});
it
(
'
renders token table
'
,
()
=>
{
describe
(
'
when the token list has additional pages
'
,
()
=>
{
expect
(
wrapper
.
find
(
TokenTable
).
exists
()).
toBe
(
true
);
const
pageInfo
=
{
hasNextPage
:
true
,
hasPreviousPage
:
false
,
startCursor
:
'
prev
'
,
endCursor
:
'
next
'
,
};
const
tokenPagination
=
{
...
defaultClusterAgent
,
tokens
:
{
...
defaultClusterAgent
.
tokens
,
pageInfo
,
},
};
beforeEach
(()
=>
{
return
createWrapper
({
clusterAgent
:
tokenPagination
});
});
it
(
'
should render pagination buttons
'
,
()
=>
{
expect
(
findPaginationButtons
().
exists
()).
toBe
(
true
);
});
it
(
'
should pass pageInfo to the pagination component
'
,
()
=>
{
expect
(
findPaginationButtons
().
props
()).
toMatchObject
(
pageInfo
);
});
});
});
describe
(
'
when the agent query is loading
'
,
()
=>
{
describe
(
'
when the agent query is loading
'
,
()
=>
{
describe
(
'
when the clusterAgent is missing
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
return
createWrapper
({
return
createWrapper
({
clusterAgent
:
null
,
clusterAgent
:
null
,
...
@@ -114,8 +162,21 @@ describe('ClusterAgentShow', () => {
...
@@ -114,8 +162,21 @@ describe('ClusterAgentShow', () => {
});
});
});
});
it
(
'
displays a loading icon
'
,
()
=>
{
it
(
'
displays a loading icon and hides the token tab
'
,
()
=>
{
expect
(
wrapper
.
find
(
GlLoadingIcon
).
exists
()).
toBe
(
true
);
expect
(
findLoadingIcon
().
exists
()).
toBe
(
true
);
expect
(
wrapper
.
text
()).
not
.
toContain
(
ClusterAgentShow
.
i18n
.
tokens
);
});
});
describe
(
'
when the clusterAgent is present
'
,
()
=>
{
beforeEach
(()
=>
{
createWrapperWithoutApollo
({
clusterAgent
:
defaultClusterAgent
,
loading
:
true
});
});
it
(
'
displays a loading icon and token tab
'
,
()
=>
{
expect
(
findLoadingIcon
().
exists
()).
toBe
(
true
);
expect
(
wrapper
.
text
()).
toContain
(
ClusterAgentShow
.
i18n
.
tokens
);
});
});
});
});
});
...
...
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