feat: Replace new Vue() with custom event bus (no-changelog) (#5780)

* refactor: replace new Vue() with custom event bus (no-changelog)

* fix: export types from design system main

* fix: update component types

* fix: update form inputs event bus
This commit is contained in:
Alex Grozav
2023-04-06 16:32:45 +03:00
committed by GitHub
parent 89c12fc1a7
commit 5651a52364
67 changed files with 347 additions and 210 deletions

View File

@@ -51,7 +51,7 @@ import mixins from 'vue-typed-mixins';
import { EnterpriseEditionFeature } from '@/constants';
import { showMessage } from '@/mixins/showMessage';
import { useLogStreamingStore } from '../../stores/logStreamingStore';
import Vue from 'vue';
import Vue, { PropType } from 'vue';
import { mapStores } from 'pinia';
import {
deepCopy,
@@ -59,6 +59,7 @@ import {
MessageEventBusDestinationOptions,
} from 'n8n-workflow';
import { BaseTextKey } from '../../plugins/i18n';
import { EventBus } from '@/event-bus';
export const DESTINATION_LIST_ITEM_ACTIONS = {
OPEN: 'open',
@@ -75,7 +76,7 @@ export default mixins(showMessage).extend({
components: {},
props: {
eventBus: {
type: Vue,
type: Object as PropType<EventBus>,
},
destination: {
type: Object,
@@ -91,7 +92,7 @@ export default mixins(showMessage).extend({
deepCopy(defaultMessageEventBusDestinationOptions),
this.destination,
);
this.eventBus.$on('destinationWasSaved', () => {
this.eventBus.on('destinationWasSaved', () => {
const updatedDestination = this.logStreamingStore.getDestination(this.destination.id);
if (updatedDestination) {
this.nodeParameters = Object.assign(

View File

@@ -193,7 +193,7 @@ import {
defaultMessageEventBusDestinationSyslogOptions,
defaultMessageEventBusDestinationSentryOptions,
} from 'n8n-workflow';
import Vue from 'vue';
import Vue, { PropType } from 'vue';
import { LOG_STREAM_MODAL_KEY } from '../../constants';
import Modal from '@/components/Modal.vue';
import { showMessage } from '@/mixins/showMessage';
@@ -210,6 +210,7 @@ import InlineNameEdit from '../InlineNameEdit.vue';
import SaveButton from '../SaveButton.vue';
import EventSelection from '@/components/SettingsLogStreaming/EventSelection.ee.vue';
import { Checkbox } from 'element-ui';
import { createEventBus, EventBus } from '@/event-bus';
export default mixins(showMessage).extend({
name: 'event-destination-settings-modal',
@@ -221,7 +222,7 @@ export default mixins(showMessage).extend({
},
isNew: Boolean,
eventBus: {
type: Vue,
type: Object as PropType<EventBus>,
},
},
components: {
@@ -248,7 +249,7 @@ export default mixins(showMessage).extend({
webhookDescription: webhookModalDescription,
sentryDescription: sentryModalDescription,
syslogDescription: syslogModalDescription,
modalBus: new Vue(),
modalBus: createEventBus(),
headerLabel: this.$props.destination.label,
testMessageSent: false,
testMessageResult: false,
@@ -450,7 +451,7 @@ export default mixins(showMessage).extend({
if (deleteConfirmed === false) {
return;
} else {
this.$props.eventBus.$emit('remove', this.destination.id);
this.$props.eventBus.emit('remove', this.destination.id);
this.uiStore.closeModal(LOG_STREAM_MODAL_KEY);
this.uiStore.stateIsDirty = false;
}
@@ -461,7 +462,7 @@ export default mixins(showMessage).extend({
this.logStreamingStore.removeDestination(this.nodeParameters.id!);
}
this.ndvStore.activeNodeName = null;
this.$props.eventBus.$emit('closing', this.destination.id);
this.$props.eventBus.emit('closing', this.destination.id);
this.uiStore.stateIsDirty = false;
},
async saveDestination() {
@@ -473,7 +474,7 @@ export default mixins(showMessage).extend({
this.hasOnceBeenSaved = true;
this.testMessageSent = false;
this.unchanged = true;
this.$props.eventBus.$emit('destinationWasSaved', this.destination.id);
this.$props.eventBus.emit('destinationWasSaved', this.destination.id);
this.uiStore.stateIsDirty = false;
}
},