Commit 3945e181 authored by Enrique Alcantara's avatar Enrique Alcantara

CE-backport track uninstall button clicks

parent f9875875
<script> <script>
import { GlModal } from '@gitlab/ui'; import { GlModal } from '@gitlab/ui';
import { sprintf, s__ } from '~/locale'; import { sprintf, s__ } from '~/locale';
import trackUninstallButtonClickMixin from 'ee_else_ce/clusters/mixins/track_uninstall_button_click';
import { INGRESS, CERT_MANAGER, PROMETHEUS, RUNNER, KNATIVE, JUPYTER } from '../constants'; import { INGRESS, CERT_MANAGER, PROMETHEUS, RUNNER, KNATIVE, JUPYTER } from '../constants';
const CUSTOM_APP_WARNING_TEXT = { const CUSTOM_APP_WARNING_TEXT = {
...@@ -20,6 +21,7 @@ export default { ...@@ -20,6 +21,7 @@ export default {
components: { components: {
GlModal, GlModal,
}, },
mixins: [trackUninstallButtonClickMixin],
props: { props: {
application: { application: {
type: String, type: String,
...@@ -51,6 +53,12 @@ export default { ...@@ -51,6 +53,12 @@ export default {
return `uninstall-${this.application}`; return `uninstall-${this.application}`;
}, },
}, },
methods: {
confirmUninstall() {
this.trackUninstallButtonClick(this.application);
this.$emit('confirm');
},
},
}; };
</script> </script>
<template> <template>
...@@ -60,7 +68,7 @@ export default { ...@@ -60,7 +68,7 @@ export default {
:ok-title="title" :ok-title="title"
:modal-id="modalId" :modal-id="modalId"
:title="title" :title="title"
@ok="$emit('confirm')" @ok="confirmUninstall()"
>{{ warningText }} {{ customAppWarningText }}</gl-modal >{{ warningText }} {{ customAppWarningText }}</gl-modal
> >
</template> </template>
export default {
methods: {
trackUninstallButtonClick: () => {},
},
};
...@@ -29,10 +29,19 @@ describe('UninstallApplicationConfirmationModal', () => { ...@@ -29,10 +29,19 @@ describe('UninstallApplicationConfirmationModal', () => {
expect(wrapper.find(GlModal).attributes('ok-title')).toEqual(`Uninstall ${appTitle}`); expect(wrapper.find(GlModal).attributes('ok-title')).toEqual(`Uninstall ${appTitle}`);
}); });
it('triggers confirm event when ok button is clicked', () => { describe('when ok button is clicked', () => {
wrapper.find(GlModal).vm.$emit('ok'); beforeEach(() => {
jest.spyOn(wrapper.vm, 'trackUninstallButtonClick');
wrapper.find(GlModal).vm.$emit('ok');
});
it('emits confirm event', () => {
expect(wrapper.emitted('confirm')).toBeTruthy();
});
expect(wrapper.emitted('confirm')).toBeTruthy(); it('calls track uninstall button click mixin', () => {
expect(wrapper.vm.trackUninstallButtonClick).toHaveBeenCalledWith(INGRESS);
});
}); });
it('displays a warning text indicating the app will be uninstalled', () => { it('displays a warning text indicating the app will be uninstalled', () => {
......
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