Commit 40f65208 authored by Mark Florian's avatar Mark Florian

Merge branch '327854-change-static-doc-links' into 'master'

Change static docs links

See merge request gitlab-org/gitlab!65535
parents e5a427c5 dfe2b25e
...@@ -20,7 +20,11 @@ module ClustersHelper ...@@ -20,7 +20,11 @@ module ClustersHelper
{ {
default_branch_name: clusterable_project.default_branch, default_branch_name: clusterable_project.default_branch,
empty_state_image: image_path('illustrations/clusters_empty.svg'), empty_state_image: image_path('illustrations/clusters_empty.svg'),
project_path: clusterable_project.full_path project_path: clusterable_project.full_path,
agent_docs_url: help_page_path('user/clusters/agent/index'),
install_docs_url: help_page_path('administration/clusters/kas'),
get_started_docs_url: help_page_path('user/clusters/agent/index', anchor: 'define-a-configuration-repository'),
integration_docs_url: help_page_path('user/clusters/agent/index', anchor: 'get-started-with-gitops-and-the-gitlab-agent')
} }
end end
......
...@@ -9,15 +9,15 @@ export default { ...@@ -9,15 +9,15 @@ export default {
GlSprintf, GlSprintf,
GlAlert, GlAlert,
}, },
inject: [
'emptyStateImage',
'projectPath',
'agentDocsUrl',
'installDocsUrl',
'getStartedDocsUrl',
'integrationDocsUrl',
],
props: { props: {
image: {
type: String,
required: true,
},
projectPath: {
type: String,
required: true,
},
hasConfigurations: { hasConfigurations: {
type: Boolean, type: Boolean,
required: true, required: true,
...@@ -33,7 +33,7 @@ export default { ...@@ -33,7 +33,7 @@ export default {
<template> <template>
<gl-empty-state <gl-empty-state
:svg-path="image" :svg-path="emptyStateImage"
:title="s__('ClusterAgents|Integrate Kubernetes with a GitLab Agent')" :title="s__('ClusterAgents|Integrate Kubernetes with a GitLab Agent')"
class="empty-state--agent" class="empty-state--agent"
> >
...@@ -47,7 +47,7 @@ export default { ...@@ -47,7 +47,7 @@ export default {
" "
> >
<template #link="{ content }"> <template #link="{ content }">
<gl-link href="https://docs.gitlab.com/ee/user/clusters/agent/" target="_blank"> <gl-link :href="agentDocsUrl" target="_blank" data-testid="agent-docs-link">
{{ content }} {{ content }}
</gl-link> </gl-link>
</template> </template>
...@@ -63,10 +63,7 @@ export default { ...@@ -63,10 +63,7 @@ export default {
" "
> >
<template #link="{ content }"> <template #link="{ content }">
<gl-link <gl-link :href="installDocsUrl" target="_blank" data-testid="install-docs-link">
href="https://docs.gitlab.com/ee/user/clusters/agent/#install-the-agent-server"
target="_blank"
>
{{ content }} {{ content }}
</gl-link> </gl-link>
</template> </template>
...@@ -89,7 +86,7 @@ export default { ...@@ -89,7 +86,7 @@ export default {
<gl-button <gl-button
category="primary" category="primary"
variant="info" variant="info"
href="https://docs.gitlab.com/ee/user/clusters/agent/#define-a-configuration-repository" :href="getStartedDocsUrl"
target="_blank" target="_blank"
class="gl-ml-0!" class="gl-ml-0!"
> >
...@@ -108,7 +105,7 @@ export default { ...@@ -108,7 +105,7 @@ export default {
data-testid="integration-primary-button" data-testid="integration-primary-button"
category="primary" category="primary"
variant="success" variant="success"
href="https://docs.gitlab.com/ee/user/clusters/agent/#get-started-with-gitops-and-the-gitlab-agent" :href="integrationDocsUrl"
target="_blank" target="_blank"
> >
{{ s__('ClusterAgents|Integrate with the GitLab Agent') }} {{ s__('ClusterAgents|Integrate with the GitLab Agent') }}
......
...@@ -7,6 +7,7 @@ export default { ...@@ -7,6 +7,7 @@ export default {
GlLink, GlLink,
GlTable, GlTable,
}, },
inject: ['integrationDocsUrl'],
props: { props: {
agents: { agents: {
required: true, required: true,
...@@ -33,10 +34,7 @@ export default { ...@@ -33,10 +34,7 @@ export default {
<template> <template>
<div> <div>
<div class="gl-display-block gl-text-right gl-my-3"> <div class="gl-display-block gl-text-right gl-my-3">
<gl-link <gl-link :href="integrationDocsUrl" target="_blank">
href="https://docs.gitlab.com/ee/user/clusters/agent/#get-started-with-gitops-and-the-gitlab-agent"
target="_blank"
>
{{ s__('ClusterAgents|Learn more about installing the GitLab Agent') }} {{ s__('ClusterAgents|Learn more about installing the GitLab Agent') }}
</gl-link> </gl-link>
</div> </div>
......
...@@ -29,20 +29,13 @@ export default { ...@@ -29,20 +29,13 @@ export default {
GlKeysetPagination, GlKeysetPagination,
GlLoadingIcon, GlLoadingIcon,
}, },
inject: ['projectPath'],
props: { props: {
emptyStateImage: {
required: true,
type: String,
},
defaultBranchName: { defaultBranchName: {
default: '.noBranch', default: '.noBranch',
required: false, required: false,
type: String, type: String,
}, },
projectPath: {
required: true,
type: String,
},
}, },
data() { data() {
return { return {
...@@ -124,12 +117,7 @@ export default { ...@@ -124,12 +117,7 @@ export default {
</div> </div>
</div> </div>
<AgentEmptyState <AgentEmptyState v-else :has-configurations="hasConfigurations" />
v-else
:image="emptyStateImage"
:project-path="projectPath"
:has-configurations="hasConfigurations"
/>
</section> </section>
<gl-alert v-else variant="danger" :dismissible="false"> <gl-alert v-else variant="danger" :dismissible="false">
......
...@@ -10,17 +10,31 @@ export default (Vue, VueApollo) => { ...@@ -10,17 +10,31 @@ export default (Vue, VueApollo) => {
const defaultClient = createDefaultClient(); const defaultClient = createDefaultClient();
const { emptyStateImage, defaultBranchName, projectPath } = el.dataset; const {
emptyStateImage,
defaultBranchName,
projectPath,
agentDocsUrl,
installDocsUrl,
getStartedDocsUrl,
integrationDocsUrl,
} = el.dataset;
return new Vue({ return new Vue({
el, el,
apolloProvider: new VueApollo({ defaultClient }), apolloProvider: new VueApollo({ defaultClient }),
provide: {
emptyStateImage,
projectPath,
agentDocsUrl,
installDocsUrl,
getStartedDocsUrl,
integrationDocsUrl,
},
render(createElement) { render(createElement) {
return createElement(Agents, { return createElement(Agents, {
props: { props: {
emptyStateImage,
defaultBranchName, defaultBranchName,
projectPath,
}, },
}); });
}, },
......
...@@ -2,22 +2,38 @@ import { GlAlert, GlEmptyState, GlSprintf } from '@gitlab/ui'; ...@@ -2,22 +2,38 @@ import { GlAlert, GlEmptyState, GlSprintf } from '@gitlab/ui';
import AgentEmptyState from 'ee/clusters_list/components/agent_empty_state.vue'; import AgentEmptyState from 'ee/clusters_list/components/agent_empty_state.vue';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
const emptyStateImage = '/path/to/image';
const projectPath = 'path/to/project';
const agentDocsUrl = 'path/to/agentDocs';
const installDocsUrl = 'path/to/installDocs';
const getStartedDocsUrl = 'path/to/getStartedDocs';
const integrationDocsUrl = 'path/to/integrationDocs';
describe('AgentEmptyStateComponent', () => { describe('AgentEmptyStateComponent', () => {
let wrapper; let wrapper;
const propsData = { const propsData = {
image: '/image/path',
projectPath: 'path/to/project',
hasConfigurations: false, hasConfigurations: false,
}; };
const provideData = {
emptyStateImage,
projectPath,
agentDocsUrl,
installDocsUrl,
getStartedDocsUrl,
integrationDocsUrl,
};
const findConfigurationsAlert = () => wrapper.findComponent(GlAlert); const findConfigurationsAlert = () => wrapper.findComponent(GlAlert);
const findAgentDocsLink = () => wrapper.findByTestId('agent-docs-link');
const findInstallDocsLink = () => wrapper.findByTestId('install-docs-link');
const findIntegrationButton = () => wrapper.findByTestId('integration-primary-button'); const findIntegrationButton = () => wrapper.findByTestId('integration-primary-button');
const findEmptyState = () => wrapper.findComponent(GlEmptyState); const findEmptyState = () => wrapper.findComponent(GlEmptyState);
beforeEach(() => { beforeEach(() => {
wrapper = shallowMountExtended(AgentEmptyState, { wrapper = shallowMountExtended(AgentEmptyState, {
propsData, propsData,
provide: provideData,
stubs: { GlEmptyState, GlSprintf }, stubs: { GlEmptyState, GlSprintf },
}); });
}); });
...@@ -29,6 +45,11 @@ describe('AgentEmptyStateComponent', () => { ...@@ -29,6 +45,11 @@ describe('AgentEmptyStateComponent', () => {
} }
}); });
it('renders correct href attributes for the links', () => {
expect(findAgentDocsLink().attributes('href')).toBe(agentDocsUrl);
expect(findInstallDocsLink().attributes('href')).toBe(installDocsUrl);
});
describe('when there are no agent configurations in repository', () => { describe('when there are no agent configurations in repository', () => {
it('should render notification message box', () => { it('should render notification message box', () => {
expect(findConfigurationsAlert().exists()).toBe(true); expect(findConfigurationsAlert().exists()).toBe(true);
...@@ -44,6 +65,7 @@ describe('AgentEmptyStateComponent', () => { ...@@ -44,6 +65,7 @@ describe('AgentEmptyStateComponent', () => {
propsData.hasConfigurations = true; propsData.hasConfigurations = true;
wrapper = shallowMountExtended(AgentEmptyState, { wrapper = shallowMountExtended(AgentEmptyState, {
propsData, propsData,
provide: provideData,
}); });
}); });
it('should render content without notification message box', () => { it('should render content without notification message box', () => {
...@@ -51,5 +73,9 @@ describe('AgentEmptyStateComponent', () => { ...@@ -51,5 +73,9 @@ describe('AgentEmptyStateComponent', () => {
expect(findConfigurationsAlert().exists()).toBe(false); expect(findConfigurationsAlert().exists()).toBe(false);
expect(findIntegrationButton().attributes('disabled')).toBeUndefined(); expect(findIntegrationButton().attributes('disabled')).toBeUndefined();
}); });
it('should render correct href for the integration button', () => {
expect(findIntegrationButton().attributes('href')).toBe(integrationDocsUrl);
});
}); });
}); });
...@@ -17,12 +17,13 @@ const propsData = { ...@@ -17,12 +17,13 @@ const propsData = {
}, },
], ],
}; };
const provideData = { integrationDocsUrl: 'path/to/integrationDocs' };
describe('AgentTable', () => { describe('AgentTable', () => {
let wrapper; let wrapper;
beforeEach(() => { beforeEach(() => {
wrapper = mount(AgentTable, { propsData }); wrapper = mount(AgentTable, { propsData, provide: provideData });
}); });
afterEach(() => { afterEach(() => {
...@@ -32,8 +33,9 @@ describe('AgentTable', () => { ...@@ -32,8 +33,9 @@ describe('AgentTable', () => {
} }
}); });
it('displays header link', () => { it('displays header link with the correct href', () => {
expect(wrapper.find(GlLink).text()).toBe('Learn more about installing the GitLab Agent'); expect(wrapper.find(GlLink).text()).toBe('Learn more about installing the GitLab Agent');
expect(wrapper.find(GlLink).attributes('href')).toBe('path/to/integrationDocs');
}); });
describe('agent table', () => { describe('agent table', () => {
......
...@@ -14,12 +14,14 @@ describe('Agents', () => { ...@@ -14,12 +14,14 @@ describe('Agents', () => {
let wrapper; let wrapper;
const propsData = { const propsData = {
emptyStateImage: '/path/to/image',
defaultBranchName: 'default', defaultBranchName: 'default',
};
const provideData = {
projectPath: 'path/to/project', projectPath: 'path/to/project',
}; };
const createWrapper = ({ agents = [], pageInfo = null, trees = [] }) => { const createWrapper = ({ agents = [], pageInfo = null, trees = [] }) => {
const provide = provideData;
const apolloQueryResponse = { const apolloQueryResponse = {
data: { data: {
project: { project: {
...@@ -30,13 +32,14 @@ describe('Agents', () => { ...@@ -30,13 +32,14 @@ describe('Agents', () => {
}; };
const apolloProvider = createMockApollo([ const apolloProvider = createMockApollo([
[getAgentsQuery, jest.fn().mockResolvedValue(apolloQueryResponse)], [getAgentsQuery, jest.fn().mockResolvedValue(apolloQueryResponse, provide)],
]); ]);
wrapper = shallowMount(Agents, { wrapper = shallowMount(Agents, {
localVue, localVue,
apolloProvider, apolloProvider,
propsData, propsData,
provide: provideData,
}); });
return wrapper.vm.$nextTick(); return wrapper.vm.$nextTick();
...@@ -138,10 +141,6 @@ describe('Agents', () => { ...@@ -138,10 +141,6 @@ describe('Agents', () => {
expect(findAgentTable().exists()).toBe(false); expect(findAgentTable().exists()).toBe(false);
expect(findEmptyState().exists()).toBe(true); expect(findEmptyState().exists()).toBe(true);
}); });
it('should pass the correct project path to empty state component', () => {
expect(findEmptyState().props('projectPath')).toEqual('path/to/project');
});
}); });
describe('when the agent configurations are present', () => { describe('when the agent configurations are present', () => {
...@@ -184,7 +183,7 @@ describe('Agents', () => { ...@@ -184,7 +183,7 @@ describe('Agents', () => {
}; };
beforeEach(() => { beforeEach(() => {
wrapper = shallowMount(Agents, { mocks, propsData }); wrapper = shallowMount(Agents, { mocks, propsData, provide: provideData });
return wrapper.vm.$nextTick(); return wrapper.vm.$nextTick();
}); });
......
...@@ -75,6 +75,13 @@ RSpec.describe ClustersHelper do ...@@ -75,6 +75,13 @@ RSpec.describe ClustersHelper do
it 'displays project path' do it 'displays project path' do
expect(subject[:project_path]).to eq(project.full_path) expect(subject[:project_path]).to eq(project.full_path)
end end
it 'generates docs urls' do
expect(subject[:agent_docs_url]).to eq(help_page_path('user/clusters/agent/index'))
expect(subject[:install_docs_url]).to eq(help_page_path('administration/clusters/kas'))
expect(subject[:get_started_docs_url]).to eq(help_page_path('user/clusters/agent/index', anchor: 'define-a-configuration-repository'))
expect(subject[:integration_docs_url]).to eq(help_page_path('user/clusters/agent/index', anchor: 'get-started-with-gitops-and-the-gitlab-agent'))
end
end end
describe '#js_clusters_list_data' do describe '#js_clusters_list_data' do
......
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