Commit 3a31cedb authored by Arun Kumar Mohan's avatar Arun Kumar Mohan

Migrate from Vue event hub to Mitt

parent 935b1b6d
import Vue from 'vue'; import createEventHub from '~/helpers/event_hub_factory';
export default new Vue(); export default createEventHub();
import Vue from 'vue'; import createEventHub from '~/helpers/event_hub_factory';
export default new Vue(); export default createEventHub();
import Vue from 'vue'; import createEventHub from '~/helpers/event_hub_factory';
export default new Vue(); export default createEventHub();
import Vue from 'vue'; import createEventHub from '~/helpers/event_hub_factory';
export default new Vue(); export default createEventHub();
import Vue from 'vue'; import createEventHub from '~/helpers/event_hub_factory';
export default new Vue(); export default createEventHub();
import Vue from 'vue'; import createEventHub from '~/helpers/event_hub_factory';
export default new Vue(); export default createEventHub();
import Vue from 'vue'; import createEventHub from '~/helpers/event_hub_factory';
export default new Vue(); export default createEventHub();
import Vue from 'vue'; import createEventHub from '~/helpers/event_hub_factory';
export default new Vue(); export default createEventHub();
import Vue from 'vue'; import createEventHub from '~/helpers/event_hub_factory';
export default new Vue(); export default createEventHub();
/* eslint-disable no-new, class-methods-use-this */ /* eslint-disable no-new, class-methods-use-this */
import $ from 'jquery'; import $ from 'jquery';
import Vue from 'vue';
import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils'; import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import createEventHub from '~/helpers/event_hub_factory';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
import flash from './flash'; import flash from './flash';
import BlobForkSuggestion from './blob/blob_fork_suggestion'; import BlobForkSuggestion from './blob/blob_fork_suggestion';
...@@ -93,7 +93,7 @@ export default class MergeRequestTabs { ...@@ -93,7 +93,7 @@ export default class MergeRequestTabs {
this.pipelinesLoaded = false; this.pipelinesLoaded = false;
this.commitsLoaded = false; this.commitsLoaded = false;
this.fixedLayoutPref = null; this.fixedLayoutPref = null;
this.eventHub = new Vue(); this.eventHub = createEventHub();
this.setUrl = setUrl !== undefined ? setUrl : true; this.setUrl = setUrl !== undefined ? setUrl : true;
this.setCurrentAction = this.setCurrentAction.bind(this); this.setCurrentAction = this.setCurrentAction.bind(this);
......
import Vue from 'vue'; import createEventHub from '~/helpers/event_hub_factory';
export default new Vue(); export default createEventHub();
import Vue from 'vue'; import createEventHub from '~/helpers/event_hub_factory';
export default new Vue(); export default createEventHub();
import Vue from 'vue'; import createEventHub from '~/helpers/event_hub_factory';
export default new Vue(); export default createEventHub();
import Vue from 'vue'; import createEventHub from '~/helpers/event_hub_factory';
export default new Vue(); export default createEventHub();
import Vue from 'vue'; import createEventHub from '~/helpers/event_hub_factory';
export default new Vue(); export default createEventHub();
import Vue from 'vue'; import createEventHub from '~/helpers/event_hub_factory';
// see recaptcha_tags in app/views/shared/_recaptcha_form.html.haml // see recaptcha_tags in app/views/shared/_recaptcha_form.html.haml
export const callbackName = 'recaptchaDialogCallback'; export const callbackName = 'recaptchaDialogCallback';
export const eventHub = new Vue(); export const eventHub = createEventHub();
const throwDuplicateCallbackError = () => { const throwDuplicateCallbackError = () => {
throw new Error(`${callbackName} is already defined!`); throw new Error(`${callbackName} is already defined!`);
......
---
title: Migrate from Vue event hub to Mitt
merge_request: 31666
author: Arun Kumar Mohan
type: changed
import Vue from 'vue'; import createEventHub from '~/helpers/event_hub_factory';
export default new Vue(); export default createEventHub();
import Vue from 'vue'; import createEventHub from '~/helpers/event_hub_factory';
export default new Vue(); export default createEventHub();
import Vue from 'vue'; import createEventHub from '~/helpers/event_hub_factory';
export default new Vue(); export default createEventHub();
import Vue from 'vue'; import createEventHub from '~/helpers/event_hub_factory';
const accordionEventBus = new Vue(); export default createEventHub();
export default accordionEventBus;
// TODO: Replace with mitt implementation for Vue3 once it has been verified import createEventHub from '~/helpers/event_hub_factory';
// (https://gitlab.com/gitlab-org/gitlab/-/issues/215672)
import Vue from 'vue';
export default new Vue(); export default createEventHub();
import Vue from 'vue';
import accordionEventBus from 'ee/vue_shared/components/accordion/accordion_event_bus';
describe('Accordion event bus', () => {
it('default exports a vue instance', () => {
expect(accordionEventBus instanceof Vue).toBe(true);
});
});
import Vue from 'vue';
import vulnerabilitiesEventBus from 'ee/vulnerabilities/components/vulnerabilities_event_bus';
describe('Vulnerabilities event bus', () => {
it('default exports a vue instance', () => {
expect(vulnerabilitiesEventBus instanceof Vue).toBe(true);
});
});
import Vue from 'vue'; import createEventHub from '~/helpers/event_hub_factory';
import Vuex from 'vuex'; import Vuex from 'vuex';
import { createLocalVue, mount } from '@vue/test-utils'; import { createLocalVue, mount } from '@vue/test-utils';
...@@ -132,7 +132,7 @@ describe('DiscussionFilter component', () => { ...@@ -132,7 +132,7 @@ describe('DiscussionFilter component', () => {
}); });
describe('Merge request tabs', () => { describe('Merge request tabs', () => {
eventHub = new Vue(); eventHub = createEventHub();
beforeEach(() => { beforeEach(() => {
window.mrTabs = { window.mrTabs = {
......
...@@ -3,6 +3,7 @@ import { shallowMount, createLocalVue } from '@vue/test-utils'; ...@@ -3,6 +3,7 @@ import { shallowMount, createLocalVue } from '@vue/test-utils';
import * as utils from '~/lib/utils/common_utils'; import * as utils from '~/lib/utils/common_utils';
import discussionNavigation from '~/notes/mixins/discussion_navigation'; import discussionNavigation from '~/notes/mixins/discussion_navigation';
import eventHub from '~/notes/event_hub'; import eventHub from '~/notes/event_hub';
import createEventHub from '~/helpers/event_hub_factory';
import notesModule from '~/notes/stores/modules'; import notesModule from '~/notes/stores/modules';
import { setHTMLFixture } from 'helpers/fixtures'; import { setHTMLFixture } from 'helpers/fixtures';
...@@ -67,8 +68,7 @@ describe('Discussion navigation mixin', () => { ...@@ -67,8 +68,7 @@ describe('Discussion navigation mixin', () => {
describe('cycle through discussions', () => { describe('cycle through discussions', () => {
beforeEach(() => { beforeEach(() => {
// eslint-disable-next-line new-cap window.mrTabs = { eventHub: createEventHub(), tabShown: jest.fn() };
window.mrTabs = { eventHub: new localVue(), tabShown: jest.fn() };
}); });
describe.each` describe.each`
......
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