From 433252ce5563c7cda7cf38c5e50ad53f44335bfe Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Wed, 15 Nov 2023 17:41:10 -0500 Subject: [PATCH] Drop all eventHub usage. --- .../components/Panels/Common/ToolSection.vue | 6 +++--- client/src/components/plugins/eventHub.js | 21 ------------------- client/src/components/plugins/index.js | 1 - client/src/utils/mountVueComponent.js | 7 +------ client/tests/jest/helpers.js | 2 -- 5 files changed, 4 insertions(+), 33 deletions(-) delete mode 100644 client/src/components/plugins/eventHub.js diff --git a/client/src/components/Panels/Common/ToolSection.vue b/client/src/components/Panels/Common/ToolSection.vue index 5c3a00e3e9d6..0747cc71da3f 100644 --- a/client/src/components/Panels/Common/ToolSection.vue +++ b/client/src/components/Panels/Common/ToolSection.vue @@ -15,7 +15,7 @@ const emit = defineEmits<{ (e: "onOperation", tool: any, evt: Event): void; }>(); -const eventHub = useEventBus("open-tool-section"); +const eventBus = useEventBus("open-tool-section"); const props = defineProps({ category: { @@ -134,11 +134,11 @@ watch( ); onMounted(() => { - eventHub.on(openToolSection); + eventBus.on(openToolSection); }); onUnmounted(() => { - eventHub.off(openToolSection); + eventBus.off(openToolSection); }); function openToolSection(sectionId: string) { diff --git a/client/src/components/plugins/eventHub.js b/client/src/components/plugins/eventHub.js deleted file mode 100644 index 16f137964a46..000000000000 --- a/client/src/components/plugins/eventHub.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Mixin provides global event bus other than $root.$emit. Avoids event naming conflicts and makes - * opt-in possible, also works when components aren't part of the same Vue app tree as is often the - * case with our app until backbone is gone. - */ - -import Vue from "vue"; - -export const eventHub = new Vue(); - -export const eventHubMixin = { - created() { - this.eventHub = eventHub; - }, -}; - -export const eventHubPlugin = { - install(Vue) { - Vue.mixin(eventHubMixin); - }, -}; diff --git a/client/src/components/plugins/index.js b/client/src/components/plugins/index.js index fb69bc327c50..47ae8061c664 100644 --- a/client/src/components/plugins/index.js +++ b/client/src/components/plugins/index.js @@ -1,4 +1,3 @@ -export { eventHubMixin, eventHubPlugin } from "./eventHub"; export { iconMixin, iconPlugin } from "./icons"; export { localizationPlugin } from "./localization"; export { vueRxShortcutPlugin, vueRxShortcuts } from "./vueRxShortcuts"; diff --git a/client/src/utils/mountVueComponent.js b/client/src/utils/mountVueComponent.js index 222af94a9b5a..62b969b299ab 100644 --- a/client/src/utils/mountVueComponent.js +++ b/client/src/utils/mountVueComponent.js @@ -3,7 +3,7 @@ // the same plugins and events. import BootstrapVue from "bootstrap-vue"; -import { eventHubPlugin, iconPlugin, localizationPlugin, vueRxShortcutPlugin } from "components/plugins"; +import { iconPlugin, localizationPlugin, vueRxShortcutPlugin } from "components/plugins"; import Vue from "vue"; import Vuex from "vuex"; @@ -14,11 +14,6 @@ Vue.use(Vuex); // Bootstrap components Vue.use(BootstrapVue); -// Add a global event bus. We could just use root but I don't think that will -// work right when we have more than one root, which we often will until the -// application has been completely converted to Vue. -Vue.use(eventHubPlugin); - // localization filters and directives Vue.use(localizationPlugin); diff --git a/client/tests/jest/helpers.js b/client/tests/jest/helpers.js index 4c9a75f604e7..0cfdb6648ce0 100644 --- a/client/tests/jest/helpers.js +++ b/client/tests/jest/helpers.js @@ -3,7 +3,6 @@ */ import { createLocalVue, shallowMount } from "@vue/test-utils"; import BootstrapVue from "bootstrap-vue"; -import { eventHubPlugin } from "components/plugins/eventHub"; import { iconPlugin } from "components/plugins/icons"; import { localizationPlugin } from "components/plugins/localization"; import { vueRxShortcutPlugin } from "components/plugins/vueRxShortcuts"; @@ -190,7 +189,6 @@ export function getLocalVue(instrumentLocalization = false) { const l = instrumentLocalization ? testLocalize : _l; localVue.use(localizationPlugin, l); localVue.use(vueRxShortcutPlugin); - localVue.use(eventHubPlugin); localVue.use(iconPlugin); localVue.directive("b-tooltip", mockedDirective); localVue.directive("b-popover", mockedDirective);