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:
Alex Grozav
2023-06-20 13:00:53 +03:00
committed by GitHub
parent 18f588444f
commit 0154a97773
17 changed files with 215 additions and 158 deletions

View File

@@ -28,6 +28,7 @@
:droppable="droppable"
:node="node"
:path="path"
:event-bus="eventBus"
@input="valueChanged"
@modalOpenerClick="openExpressionEditorModal"
@focus="setFocus"
@@ -391,8 +392,8 @@ import { useCredentialsStore } from '@/stores/credentials.store';
import { useSettingsStore } from '@/stores/settings.store';
import { htmlEditorEventBus } from '@/event-bus';
import Vue from 'vue';
type ResourceLocatorRef = InstanceType<typeof ResourceLocator>;
import type { EventBus } from 'n8n-design-system/utils';
import { createEventBus } from 'n8n-design-system/utils';
export default defineComponent({
name: 'parameter-input',
@@ -463,6 +464,10 @@ export default defineComponent({
size: 'small',
}),
},
eventBus: {
type: Object as PropType<EventBus>,
default: () => createEventBus(),
},
},
data() {
return {
@@ -1112,9 +1117,7 @@ export default defineComponent({
}
} else if (command === 'refreshOptions') {
if (this.isResourceLocatorParameter) {
const resourceLocatorRef = this.$refs.resourceLocator as ResourceLocatorRef | undefined;
resourceLocatorRef?.$emit('refreshList');
this.eventBus.emit('refreshList');
}
void this.loadRemoteParameterOptions();
} else if (command === 'formatHtml') {
@@ -1146,7 +1149,7 @@ export default defineComponent({
});
},
mounted() {
this.$on('optionSelected', this.optionSelected);
this.eventBus.on('optionSelected', this.optionSelected);
this.tempValue = this.displayValue as string;
if (this.node !== null) {
@@ -1186,6 +1189,9 @@ export default defineComponent({
inputFieldRef: this.$refs['inputField'],
});
},
beforeDestroy() {
this.eventBus.off('optionSelected', this.optionSelected);
},
});
</script>