Commit 34c68bfa authored by Doug Stull's avatar Doug Stull Committed by Paul Slaughter

Move constants to constants file for suggest pipeline

- better development pattern.
parent 6f8c0377
...@@ -2,24 +2,30 @@ ...@@ -2,24 +2,30 @@
import { GlLink, GlSprintf, GlButton } from '@gitlab/ui'; import { GlLink, GlSprintf, GlButton } from '@gitlab/ui';
import MrWidgetIcon from './mr_widget_icon.vue'; import MrWidgetIcon from './mr_widget_icon.vue';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import { s__ } from '~/locale';
import DismissibleContainer from '~/vue_shared/components/dismissible_container.vue'; import DismissibleContainer from '~/vue_shared/components/dismissible_container.vue';
import {
SP_TRACK_LABEL,
SP_LINK_TRACK_EVENT,
SP_SHOW_TRACK_EVENT,
SP_LINK_TRACK_VALUE,
SP_SHOW_TRACK_VALUE,
SP_HELP_CONTENT,
SP_HELP_URL,
SP_ICON_NAME,
} from '../constants';
const trackingMixin = Tracking.mixin(); const trackingMixin = Tracking.mixin();
const TRACK_LABEL = 'no_pipeline_noticed';
export default { export default {
name: 'MRWidgetSuggestPipeline', name: 'MRWidgetSuggestPipeline',
iconName: 'status_notfound', SP_ICON_NAME,
trackLabel: TRACK_LABEL, SP_TRACK_LABEL,
linkTrackValue: 30, SP_LINK_TRACK_EVENT,
linkTrackEvent: 'click_link', SP_SHOW_TRACK_EVENT,
showTrackValue: 10, SP_LINK_TRACK_VALUE,
showTrackEvent: 'click_button', SP_SHOW_TRACK_VALUE,
helpContent: s__( SP_HELP_CONTENT,
`mrWidget|Use %{linkStart}CI pipelines to test your code%{linkEnd} by simply adding a GitLab CI configuration file to your project. It only takes a minute to make your code more secure and robust.`, SP_HELP_URL,
),
helpURL: 'https://about.gitlab.com/blog/2019/07/12/guide-to-ci-cd-pipelines/',
components: { components: {
GlLink, GlLink,
GlSprintf, GlSprintf,
...@@ -53,7 +59,7 @@ export default { ...@@ -53,7 +59,7 @@ export default {
computed: { computed: {
tracking() { tracking() {
return { return {
label: TRACK_LABEL, label: SP_TRACK_LABEL,
property: this.humanAccess, property: this.humanAccess,
}; };
}, },
...@@ -71,7 +77,7 @@ export default { ...@@ -71,7 +77,7 @@ export default {
@dismiss="$emit('dismiss')" @dismiss="$emit('dismiss')"
> >
<template #title> <template #title>
<mr-widget-icon :name="$options.iconName" /> <mr-widget-icon :name="$options.SP_ICON_NAME" />
<div> <div>
<gl-sprintf <gl-sprintf
:message=" :message="
...@@ -91,9 +97,9 @@ export default { ...@@ -91,9 +97,9 @@ export default {
class="gl-ml-1" class="gl-ml-1"
data-testid="add-pipeline-link" data-testid="add-pipeline-link"
:data-track-property="humanAccess" :data-track-property="humanAccess"
:data-track-value="$options.linkTrackValue" :data-track-value="$options.SP_LINK_TRACK_VALUE"
:data-track-event="$options.linkTrackEvent" :data-track-event="$options.SP_LINK_TRACK_EVENT"
:data-track-label="$options.trackLabel" :data-track-label="$options.SP_TRACK_LABEL"
> >
{{ content }} {{ content }}
</gl-link> </gl-link>
...@@ -111,11 +117,11 @@ export default { ...@@ -111,11 +117,11 @@ export default {
{{ s__('mrWidget|Are you adding technical debt or code vulnerabilities?') }} {{ s__('mrWidget|Are you adding technical debt or code vulnerabilities?') }}
</strong> </strong>
<p class="gl-mt-2"> <p class="gl-mt-2">
<gl-sprintf :message="$options.helpContent"> <gl-sprintf :message="$options.SP_HELP_CONTENT">
<template #link="{ content }"> <template #link="{ content }">
<gl-link <gl-link
data-testid="help" data-testid="help"
:href="$options.helpURL" :href="$options.SP_HELP_URL"
target="_blank" target="_blank"
class="font-size-inherit" class="font-size-inherit"
>{{ content }} >{{ content }}
...@@ -130,9 +136,9 @@ export default { ...@@ -130,9 +136,9 @@ export default {
variant="info" variant="info"
:href="pipelinePath" :href="pipelinePath"
:data-track-property="humanAccess" :data-track-property="humanAccess"
:data-track-value="$options.showTrackValue" :data-track-value="$options.SP_SHOW_TRACK_VALUE"
:data-track-event="$options.showTrackEvent" :data-track-event="$options.SP_SHOW_TRACK_EVENT"
:data-track-label="$options.trackLabel" :data-track-label="$options.SP_TRACK_LABEL"
> >
{{ __('Show me how to add a pipeline') }} {{ __('Show me how to add a pipeline') }}
</gl-button> </gl-button>
......
import { s__ } from '~/locale';
export const SUCCESS = 'success'; export const SUCCESS = 'success';
export const WARNING = 'warning'; export const WARNING = 'warning';
export const DANGER = 'danger'; export const DANGER = 'danger';
...@@ -10,3 +12,15 @@ export const MTWPS_MERGE_STRATEGY = 'add_to_merge_train_when_pipeline_succeeds'; ...@@ -10,3 +12,15 @@ export const MTWPS_MERGE_STRATEGY = 'add_to_merge_train_when_pipeline_succeeds';
export const MT_MERGE_STRATEGY = 'merge_train'; export const MT_MERGE_STRATEGY = 'merge_train';
export const AUTO_MERGE_STRATEGIES = [MWPS_MERGE_STRATEGY, MTWPS_MERGE_STRATEGY, MT_MERGE_STRATEGY]; export const AUTO_MERGE_STRATEGIES = [MWPS_MERGE_STRATEGY, MTWPS_MERGE_STRATEGY, MT_MERGE_STRATEGY];
// SP - "Suggest Pipelines"
export const SP_TRACK_LABEL = 'no_pipeline_noticed';
export const SP_LINK_TRACK_EVENT = 'click_link';
export const SP_SHOW_TRACK_EVENT = 'click_button';
export const SP_LINK_TRACK_VALUE = 30;
export const SP_SHOW_TRACK_VALUE = 10;
export const SP_HELP_CONTENT = s__(
`mrWidget|Use %{linkStart}CI pipelines to test your code%{linkEnd} by simply adding a GitLab CI configuration file to your project. It only takes a minute to make your code more secure and robust.`,
);
export const SP_HELP_URL = 'https://about.gitlab.com/blog/2019/07/12/guide-to-ci-cd-pipelines/';
export const SP_ICON_NAME = 'status_notfound';
...@@ -7,6 +7,14 @@ import { mockTracking, triggerEvent, unmockTracking } from 'helpers/tracking_hel ...@@ -7,6 +7,14 @@ import { mockTracking, triggerEvent, unmockTracking } from 'helpers/tracking_hel
import { suggestProps, iconName } from './pipeline_tour_mock_data'; import { suggestProps, iconName } from './pipeline_tour_mock_data';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import {
SP_TRACK_LABEL,
SP_LINK_TRACK_EVENT,
SP_SHOW_TRACK_EVENT,
SP_LINK_TRACK_VALUE,
SP_SHOW_TRACK_VALUE,
SP_HELP_URL,
} from '~/vue_merge_request_widget/constants';
describe('MRWidgetSuggestPipeline', () => { describe('MRWidgetSuggestPipeline', () => {
describe('template', () => { describe('template', () => {
...@@ -80,7 +88,7 @@ describe('MRWidgetSuggestPipeline', () => { ...@@ -80,7 +88,7 @@ describe('MRWidgetSuggestPipeline', () => {
const link = wrapper.find('[data-testid="help"]'); const link = wrapper.find('[data-testid="help"]');
expect(link.exists()).toBe(true); expect(link.exists()).toBe(true);
expect(link.attributes('href')).toBe(wrapper.vm.$options.helpURL); expect(link.attributes('href')).toBe(SP_HELP_URL);
}); });
it('renders the empty pipelines image', () => { it('renders the empty pipelines image', () => {
...@@ -96,7 +104,7 @@ describe('MRWidgetSuggestPipeline', () => { ...@@ -96,7 +104,7 @@ describe('MRWidgetSuggestPipeline', () => {
const expectedAction = undefined; const expectedAction = undefined;
expect(trackingSpy).toHaveBeenCalledWith(expectedCategory, expectedAction, { expect(trackingSpy).toHaveBeenCalledWith(expectedCategory, expectedAction, {
label: wrapper.vm.$options.trackLabel, label: SP_TRACK_LABEL,
property: suggestProps.humanAccess, property: suggestProps.humanAccess,
}); });
}); });
...@@ -106,10 +114,10 @@ describe('MRWidgetSuggestPipeline', () => { ...@@ -106,10 +114,10 @@ describe('MRWidgetSuggestPipeline', () => {
const link = wrapper.find('[data-testid="add-pipeline-link"]'); const link = wrapper.find('[data-testid="add-pipeline-link"]');
triggerEvent(link.element); triggerEvent(link.element);
expect(trackingSpy).toHaveBeenCalledWith('_category_', 'click_link', { expect(trackingSpy).toHaveBeenCalledWith('_category_', SP_LINK_TRACK_EVENT, {
label: wrapper.vm.$options.trackLabel, label: SP_TRACK_LABEL,
property: suggestProps.humanAccess, property: suggestProps.humanAccess,
value: '30', value: SP_LINK_TRACK_VALUE.toString(),
}); });
}); });
...@@ -118,10 +126,10 @@ describe('MRWidgetSuggestPipeline', () => { ...@@ -118,10 +126,10 @@ describe('MRWidgetSuggestPipeline', () => {
const okBtn = findOkBtn(); const okBtn = findOkBtn();
triggerEvent(okBtn.element); triggerEvent(okBtn.element);
expect(trackingSpy).toHaveBeenCalledWith('_category_', 'click_button', { expect(trackingSpy).toHaveBeenCalledWith('_category_', SP_SHOW_TRACK_EVENT, {
label: wrapper.vm.$options.trackLabel, label: SP_TRACK_LABEL,
property: suggestProps.humanAccess, property: suggestProps.humanAccess,
value: '10', value: SP_SHOW_TRACK_VALUE.toString(),
}); });
}); });
}); });
......
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