Commit 3920782e authored by Emily Ring's avatar Emily Ring Committed by Vitaly Slobodin

Link cluster agent index to show page

Update GraphQl to include cluster path.
Add link in vue so users can navigate to cluster show page.
Update associated tests.
parent ba76e8da
...@@ -45,6 +45,12 @@ export default { ...@@ -45,6 +45,12 @@ export default {
</div> </div>
<gl-table :items="agents" :fields="fields" stacked="md" data-testid="cluster-agent-list-table"> <gl-table :items="agents" :fields="fields" stacked="md" data-testid="cluster-agent-list-table">
<template #cell(name)="{ item }">
<gl-link :href="item.webPath">
{{ item.name }}
</gl-link>
</template>
<template #cell(configuration)="{ item }"> <template #cell(configuration)="{ item }">
<!-- eslint-disable @gitlab/vue-require-i18n-strings --> <!-- eslint-disable @gitlab/vue-require-i18n-strings -->
<gl-link v-if="item.configFolder" :href="item.configFolder.webPath"> <gl-link v-if="item.configFolder" :href="item.configFolder.webPath">
......
...@@ -15,6 +15,7 @@ query getAgents( ...@@ -15,6 +15,7 @@ query getAgents(
nodes { nodes {
id id
name name
webPath
} }
pageInfo { pageInfo {
......
---
title: Link cluster index page to cluster show page
merge_request: 55536
author:
type: changed
...@@ -9,9 +9,11 @@ const propsData = { ...@@ -9,9 +9,11 @@ const propsData = {
configFolder: { configFolder: {
webPath: '/agent/full/path', webPath: '/agent/full/path',
}, },
webPath: '/agent-1',
}, },
{ {
name: 'agent-2', name: 'agent-2',
webPath: '/agent-2',
}, },
], ],
}; };
...@@ -36,16 +38,17 @@ describe('AgentTable', () => { ...@@ -36,16 +38,17 @@ describe('AgentTable', () => {
describe('agent table', () => { describe('agent table', () => {
it.each` it.each`
agentName | lineNumber agentName | link | lineNumber
${'agent-1'} | ${0} ${'agent-1'} | ${'/agent-1'} | ${0}
${'agent-2'} | ${1} ${'agent-2'} | ${'/agent-2'} | ${1}
`('displays agent name', ({ agentName, lineNumber }) => { `('displays agent link', ({ agentName, link, lineNumber }) => {
const agents = wrapper.findAll( const agents = wrapper.findAll(
'[data-testid="cluster-agent-list-table"] tbody tr > td:first-child', '[data-testid="cluster-agent-list-table"] tbody tr > td:first-child',
); );
const agent = agents.at(lineNumber); const agent = agents.at(lineNumber).find(GlLink);
expect(agent.text()).toBe(agentName); expect(agent.text()).toBe(agentName);
expect(agent.attributes('href')).toBe(link);
}); });
it.each` it.each`
......
...@@ -58,10 +58,12 @@ describe('Agents', () => { ...@@ -58,10 +58,12 @@ describe('Agents', () => {
{ {
id: '1', id: '1',
name: 'agent-1', name: 'agent-1',
webPath: '/agent-1',
}, },
{ {
id: '2', id: '2',
name: 'agent-2', name: 'agent-2',
webPath: '/agent-2',
}, },
]; ];
...@@ -84,7 +86,7 @@ describe('Agents', () => { ...@@ -84,7 +86,7 @@ describe('Agents', () => {
it('should pass agent and folder info to table component', () => { it('should pass agent and folder info to table component', () => {
expect(findAgentTable().props('agents')).toEqual([ expect(findAgentTable().props('agents')).toEqual([
{ id: '1', name: 'agent-1', configFolder: undefined }, { id: '1', name: 'agent-1', webPath: '/agent-1', configFolder: undefined },
{ {
id: '2', id: '2',
name: 'agent-2', name: 'agent-2',
...@@ -93,6 +95,7 @@ describe('Agents', () => { ...@@ -93,6 +95,7 @@ describe('Agents', () => {
path: '.gitlab/agents/agent-2', path: '.gitlab/agents/agent-2',
webPath: '/project/path/.gitlab/agents/agent-2', webPath: '/project/path/.gitlab/agents/agent-2',
}, },
webPath: '/agent-2',
}, },
]); ]);
}); });
......
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