feat(editor): Replace root events with event bus events (no-changelog) (#6454)
* feat: replace root events with event bus events * fix: prevent cypress from replacing global with globalThis in import path * feat: remove emitter mixin * fix: replace component events with event bus * fix: fix linting issue * fix: fix breaking expression switch * chore: prettify ndv e2e suite code
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
function broadcast(
|
||||
this: InstanceType<typeof EmitterMixin>,
|
||||
componentName: string,
|
||||
eventName: string,
|
||||
params: any,
|
||||
) {
|
||||
this.$children.forEach((child) => {
|
||||
const name = child.$options.name;
|
||||
|
||||
if (name === componentName) {
|
||||
// eslint-disable-next-line prefer-spread
|
||||
child.$emit.apply(child, [eventName].concat(params) as Parameters<typeof child.$emit>);
|
||||
} else {
|
||||
broadcast.apply(
|
||||
child as InstanceType<typeof EmitterMixin>,
|
||||
[componentName, eventName].concat([params]) as Parameters<typeof broadcast>,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const EmitterMixin = defineComponent({
|
||||
methods: {
|
||||
$dispatch(componentName: string, eventName: string, params: any) {
|
||||
let parent = this.$parent || this.$root;
|
||||
let name = parent.$options.name;
|
||||
|
||||
while (parent && (!name || name !== componentName)) {
|
||||
parent = parent.$parent as InstanceType<typeof EmitterMixin>;
|
||||
|
||||
if (parent) {
|
||||
name = parent.$options.name;
|
||||
}
|
||||
}
|
||||
if (parent) {
|
||||
// eslint-disable-next-line prefer-spread
|
||||
parent.$emit.apply(parent, [eventName].concat(params) as Parameters<typeof parent.$emit>);
|
||||
}
|
||||
},
|
||||
|
||||
$broadcast(componentName: string, eventName: string, params: any) {
|
||||
broadcast.call(this, componentName, eventName, params);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default EmitterMixin;
|
||||
@@ -24,7 +24,7 @@ import { TelemetryHelpers } from 'n8n-workflow';
|
||||
|
||||
import { WORKFLOW_SETTINGS_MODAL_KEY } from '@/constants';
|
||||
import { getTriggerNodeServiceName } from '@/utils';
|
||||
import { codeNodeEditorEventBus } from '@/event-bus';
|
||||
import { codeNodeEditorEventBus, globalLinkActionsEventBus } from '@/event-bus';
|
||||
import { mapStores } from 'pinia';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
@@ -351,9 +351,12 @@ export const pushConnection = defineComponent({
|
||||
|
||||
let action;
|
||||
if (!isSavingExecutions) {
|
||||
this.$root.$emit('registerGlobalLinkAction', 'open-settings', async () => {
|
||||
if (this.workflowsStore.isNewWorkflow) await this.saveAsNewWorkflow();
|
||||
this.uiStore.openModal(WORKFLOW_SETTINGS_MODAL_KEY);
|
||||
globalLinkActionsEventBus.emit('registerGlobalLinkAction', {
|
||||
key: 'open-settings',
|
||||
action: async () => {
|
||||
if (this.workflowsStore.isNewWorkflow) await this.saveAsNewWorkflow();
|
||||
this.uiStore.openModal(WORKFLOW_SETTINGS_MODAL_KEY);
|
||||
},
|
||||
});
|
||||
|
||||
action =
|
||||
|
||||
Reference in New Issue
Block a user