Commit 0c3a71ca authored by Vitaly Slobodin's avatar Vitaly Slobodin

Merge branch 'show-active-agent-tokens' into 'master'

Exclude revoked tokens from agent tokens list

See merge request gitlab-org/gitlab!78420
parents cd5c5865 3b97b95b
...@@ -10,7 +10,7 @@ import { ...@@ -10,7 +10,7 @@ import {
} from '@gitlab/ui'; } 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 { MAX_LIST_COUNT, TOKEN_STATUS_ACTIVE } 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';
import ActivityEvents from './activity_events_list.vue'; import ActivityEvents from './activity_events_list.vue';
...@@ -30,6 +30,7 @@ export default { ...@@ -30,6 +30,7 @@ export default {
return { return {
agentName: this.agentName, agentName: this.agentName,
projectPath: this.projectPath, projectPath: this.projectPath,
tokenStatus: TOKEN_STATUS_ACTIVE,
...this.cursor, ...this.cursor,
}; };
}, },
......
...@@ -36,3 +36,4 @@ export const EVENT_DETAILS = { ...@@ -36,3 +36,4 @@ export const EVENT_DETAILS = {
}; };
export const DEFAULT_ICON = 'token'; export const DEFAULT_ICON = 'token';
export const TOKEN_STATUS_ACTIVE = 'ACTIVE';
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
query getClusterAgent( query getClusterAgent(
$projectPath: ID! $projectPath: ID!
$agentName: String! $agentName: String!
$tokenStatus: AgentTokenStatus!
$first: Int $first: Int
$last: Int $last: Int
$afterToken: String $afterToken: String
...@@ -20,7 +21,13 @@ query getClusterAgent( ...@@ -20,7 +21,13 @@ query getClusterAgent(
name name
} }
tokens(first: $first, last: $last, before: $beforeToken, after: $afterToken) { tokens(
status: $tokenStatus
first: $first
last: $last
before: $beforeToken
after: $afterToken
) {
count count
nodes { nodes {
......
...@@ -11,12 +11,14 @@ import { useFakeDate } from 'helpers/fake_date'; ...@@ -11,12 +11,14 @@ import { useFakeDate } from 'helpers/fake_date';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import { MAX_LIST_COUNT, TOKEN_STATUS_ACTIVE } from '~/clusters/agents/constants';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(VueApollo); localVue.use(VueApollo);
describe('ClusterAgentShow', () => { describe('ClusterAgentShow', () => {
let wrapper; let wrapper;
let agentQueryResponse;
useFakeDate([2021, 2, 15]); useFakeDate([2021, 2, 15]);
const provide = { const provide = {
...@@ -40,7 +42,7 @@ describe('ClusterAgentShow', () => { ...@@ -40,7 +42,7 @@ describe('ClusterAgentShow', () => {
}; };
const createWrapper = ({ clusterAgent, queryResponse = null }) => { const createWrapper = ({ clusterAgent, queryResponse = null }) => {
const agentQueryResponse = agentQueryResponse =
queryResponse || queryResponse ||
jest.fn().mockResolvedValue({ data: { project: { id: 'project-1', clusterAgent } } }); jest.fn().mockResolvedValue({ data: { project: { id: 'project-1', clusterAgent } } });
const apolloProvider = createMockApollo([[getAgentQuery, agentQueryResponse]]); const apolloProvider = createMockApollo([[getAgentQuery, agentQueryResponse]]);
...@@ -84,6 +86,18 @@ describe('ClusterAgentShow', () => { ...@@ -84,6 +86,18 @@ describe('ClusterAgentShow', () => {
return createWrapper({ clusterAgent: defaultClusterAgent }); return createWrapper({ clusterAgent: defaultClusterAgent });
}); });
it('sends expected params', () => {
const variables = {
agentName: provide.agentName,
projectPath: provide.projectPath,
tokenStatus: TOKEN_STATUS_ACTIVE,
first: MAX_LIST_COUNT,
last: null,
};
expect(agentQueryResponse).toHaveBeenCalledWith(variables);
});
it('displays the agent name', () => { it('displays the agent name', () => {
expect(wrapper.text()).toContain(provide.agentName); expect(wrapper.text()).toContain(provide.agentName);
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment