Commit c06aab39 authored by Nick Kipling's avatar Nick Kipling

Created mixin for tab tracking

Added new utils file with mixin code
Changed installation components to use mixin
parent 17ac753e
...@@ -4,6 +4,7 @@ import { s__, sprintf } from '~/locale'; ...@@ -4,6 +4,7 @@ import { s__, sprintf } from '~/locale';
import CodeInstruction from './code_instruction.vue'; import CodeInstruction from './code_instruction.vue';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import { TrackingActions, TrackingLabels } from '../constants'; import { TrackingActions, TrackingLabels } from '../constants';
import trackInstallationTabChange from '../utils';
export default { export default {
name: 'MavenInstallation', name: 'MavenInstallation',
...@@ -16,6 +17,7 @@ export default { ...@@ -16,6 +17,7 @@ export default {
Tracking.mixin({ Tracking.mixin({
label: TrackingLabels.MAVEN_INSTALLATION, label: TrackingLabels.MAVEN_INSTALLATION,
}), }),
trackInstallationTabChange,
], ],
props: { props: {
heading: { heading: {
...@@ -117,19 +119,13 @@ export default { ...@@ -117,19 +119,13 @@ export default {
false, false,
), ),
}, },
methods: {
onTabChanged(tabIndex) {
const action = tabIndex === 0 ? TrackingActions.INSTALLATION : TrackingActions.REGISTRY_SETUP;
this.track(action);
},
},
trackingActions: { ...TrackingActions }, trackingActions: { ...TrackingActions },
}; };
</script> </script>
<template> <template>
<div class="append-bottom-default"> <div class="append-bottom-default">
<gl-tabs @input="onTabChanged"> <gl-tabs @input="trackInstallationTabChange">
<gl-tab :title="s__('PackageRegistry|Installation')" title-item-class="js-installation-tab"> <gl-tab :title="s__('PackageRegistry|Installation')" title-item-class="js-installation-tab">
<div class="prepend-left-default append-right-default"> <div class="prepend-left-default append-right-default">
<p class="prepend-top-8 font-weight-bold">{{ s__('PackageRegistry|Maven XML') }}</p> <p class="prepend-top-8 font-weight-bold">{{ s__('PackageRegistry|Maven XML') }}</p>
......
...@@ -4,6 +4,7 @@ import { s__, sprintf } from '~/locale'; ...@@ -4,6 +4,7 @@ import { s__, sprintf } from '~/locale';
import CodeInstruction from './code_instruction.vue'; import CodeInstruction from './code_instruction.vue';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import { TrackingActions, TrackingLabels } from '../constants'; import { TrackingActions, TrackingLabels } from '../constants';
import trackInstallationTabChange from '../utils';
export default { export default {
name: 'NpmInstallation', name: 'NpmInstallation',
...@@ -16,6 +17,7 @@ export default { ...@@ -16,6 +17,7 @@ export default {
Tracking.mixin({ Tracking.mixin({
label: TrackingLabels.NPM_INSTALLATION, label: TrackingLabels.NPM_INSTALLATION,
}), }),
trackInstallationTabChange,
], ],
props: { props: {
name: { name: {
...@@ -70,19 +72,13 @@ export default { ...@@ -70,19 +72,13 @@ export default {
); );
}, },
}, },
methods: {
onTabChanged(tabIndex) {
const action = tabIndex === 0 ? TrackingActions.INSTALLATION : TrackingActions.REGISTRY_SETUP;
this.track(action);
},
},
trackingActions: { ...TrackingActions }, trackingActions: { ...TrackingActions },
}; };
</script> </script>
<template> <template>
<div class="append-bottom-default"> <div class="append-bottom-default">
<gl-tabs @input="onTabChanged"> <gl-tabs @input="trackInstallationTabChange">
<gl-tab :title="s__('PackageRegistry|Installation')" title-item-class="js-installation-tab"> <gl-tab :title="s__('PackageRegistry|Installation')" title-item-class="js-installation-tab">
<div class="prepend-left-default append-right-default"> <div class="prepend-left-default append-right-default">
<p class="prepend-top-8 font-weight-bold">{{ s__('PackageRegistry|npm') }}</p> <p class="prepend-top-8 font-weight-bold">{{ s__('PackageRegistry|npm') }}</p>
......
import { TrackingActions } from './constants';
const trackInstallationTabChange = {
methods: {
trackInstallationTabChange(tabIndex) {
const action = tabIndex === 0 ? TrackingActions.INSTALLATION : TrackingActions.REGISTRY_SETUP;
this.track(action);
},
},
};
export default trackInstallationTabChange;
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