Commit 37e33999 authored by Savas Vedova's avatar Savas Vedova

Merge branch '349804-only-docs-links-in-new-tabs' into 'master'

Open doc links in new tab/window only

See merge request gitlab-org/gitlab!77849
parents 0f45394d a71a21fe
......@@ -31,6 +31,9 @@ export default {
this.action === 'userAdded' && isExperimentVariant('invite_for_help_continuous_onboarding')
);
},
openInNewTab() {
return ACTION_LABELS[this.action]?.openInNewTab === true;
},
},
methods: {
openModal() {
......@@ -61,8 +64,9 @@ export default {
</gl-link>
<gl-link
v-else
target="_blank"
:target="openInNewTab ? '_blank' : '_self'"
:href="value.url"
data-testid="uncompleted-learn-gitlab-link"
data-track-action="click_link"
:data-track-label="$options.i18n.ACTION_LABELS[action].title"
data-track-property="Growth::Conversion::Experiment::LearnGitLab"
......
......@@ -62,6 +62,7 @@ export const ACTION_LABELS = {
description: s__('LearnGitLab|Scan your code to uncover vulnerabilities before deploying.'),
section: 'deploy',
position: 1,
openInNewTab: true,
},
issueCreated: {
title: s__('LearnGitLab|Create an issue'),
......
......@@ -135,13 +135,13 @@ exports[`Learn GitLab renders correctly 1`] = `
>
<a
class="gl-link"
data-testid="uncompleted-learn-gitlab-link"
data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Set up CI/CD"
data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/"
rel="noopener noreferrer"
target="_blank"
target="_self"
>
Set up CI/CD
......@@ -155,13 +155,13 @@ exports[`Learn GitLab renders correctly 1`] = `
>
<a
class="gl-link"
data-testid="uncompleted-learn-gitlab-link"
data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Start a free Ultimate trial"
data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/"
rel="noopener noreferrer"
target="_blank"
target="_self"
>
Start a free Ultimate trial
......@@ -175,13 +175,13 @@ exports[`Learn GitLab renders correctly 1`] = `
>
<a
class="gl-link"
data-testid="uncompleted-learn-gitlab-link"
data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Add code owners"
data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/"
rel="noopener noreferrer"
target="_blank"
target="_self"
>
Add code owners
......@@ -202,13 +202,13 @@ exports[`Learn GitLab renders correctly 1`] = `
>
<a
class="gl-link"
data-testid="uncompleted-learn-gitlab-link"
data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Add merge request approval"
data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/"
rel="noopener noreferrer"
target="_blank"
target="_self"
>
Add merge request approval
......@@ -265,13 +265,13 @@ exports[`Learn GitLab renders correctly 1`] = `
>
<a
class="gl-link"
data-testid="uncompleted-learn-gitlab-link"
data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Create an issue"
data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/"
rel="noopener noreferrer"
target="_blank"
target="_self"
>
Create an issue
......@@ -285,13 +285,13 @@ exports[`Learn GitLab renders correctly 1`] = `
>
<a
class="gl-link"
data-testid="uncompleted-learn-gitlab-link"
data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Submit a merge request"
data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/"
rel="noopener noreferrer"
target="_blank"
target="_self"
>
Submit a merge request
......@@ -341,11 +341,12 @@ exports[`Learn GitLab renders correctly 1`] = `
>
<a
class="gl-link"
data-testid="uncompleted-learn-gitlab-link"
data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Run a Security scan using CI/CD"
data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/"
href="https://docs.gitlab.com/ee/foobar/"
rel="noopener noreferrer"
target="_blank"
>
......
......@@ -12,6 +12,10 @@ const defaultProps = {
completed: false,
};
const docLinkProps = {
url: 'https://docs.gitlab.com/ee/user/application_security/security_dashboard/',
};
describe('Learn GitLab Section Link', () => {
let wrapper;
......@@ -53,6 +57,14 @@ describe('Learn GitLab Section Link', () => {
expect(wrapper.find('[data-testid="trial-only"]').exists()).toBe(true);
});
it('renders doc links with blank target', () => {
createWrapper('securityScanEnabled', docLinkProps);
const linkElement = wrapper.find('[data-testid="uncompleted-learn-gitlab-link"]');
expect(linkElement.exists()).toBe(true);
expect(linkElement.attributes('target')).toEqual('_blank');
});
describe('rendering a link to open the invite_members modal instead of a regular link', () => {
it.each`
action | experimentVariant | showModal
......
......@@ -35,7 +35,7 @@ export const testActions = {
svg: 'http://example.com/images/illustration.svg',
},
securityScanEnabled: {
url: 'http://example.com/',
url: 'https://docs.gitlab.com/ee/foobar/',
completed: false,
svg: 'http://example.com/images/illustration.svg',
},
......
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