Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(editor): Add types to codeNodeEditorEventBus (no-changelog) #10501

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const i18n = useI18n();
const telemetry = useTelemetry();

onMounted(() => {
if (!props.isReadOnly) codeNodeEditorEventBus.on('error-line-number', highlightLine);
if (!props.isReadOnly) codeNodeEditorEventBus.on('highlightLine', highlightLine);

codeNodeEditorEventBus.on('codeDiffApplied', diffApplied);

Expand Down Expand Up @@ -188,7 +188,7 @@ onMounted(() => {

onBeforeUnmount(() => {
codeNodeEditorEventBus.off('codeDiffApplied', diffApplied);
if (!props.isReadOnly) codeNodeEditorEventBus.off('error-line-number', highlightLine);
if (!props.isReadOnly) codeNodeEditorEventBus.off('highlightLine', highlightLine);
});

const aiEnabled = computed(() => {
Expand Down
4 changes: 2 additions & 2 deletions packages/editor-ui/src/components/SqlEditor/SqlEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ watch(segments, () => {
});

onMounted(() => {
codeNodeEditorEventBus.on('error-line-number', highlightLine);
codeNodeEditorEventBus.on('highlightLine', highlightLine);

if (props.fullscreen) {
focus();
}
});

onBeforeUnmount(() => {
codeNodeEditorEventBus.off('error-line-number', highlightLine);
codeNodeEditorEventBus.off('highlightLine', highlightLine);
});

function line(lineNumber: number): Line | null {
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/composables/usePushConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export function usePushConnection({ router }: { router: ReturnType<typeof useRou

const lineNumber = runDataExecuted?.data?.resultData?.error?.lineNumber;

codeNodeEditorEventBus.emit('error-line-number', lineNumber || 'final');
codeNodeEditorEventBus.emit('highlightLine', lineNumber ?? 'final');

const workflow = workflowHelpers.getCurrentWorkflow();
if (runDataExecuted.waitTill !== undefined) {
Expand Down
12 changes: 11 additions & 1 deletion packages/editor-ui/src/event-bus/code-node-editor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
import { createEventBus } from 'n8n-design-system/utils';

export const codeNodeEditorEventBus = createEventBus();
export type HighlightLineEvent = number | 'final';

export interface CodeNodeEditorEventBusEvents {
/** Event that a diff have been applied to the code node editor */
codeDiffApplied: never;

/** Command to highlight a specific line in the code node editor */
highlightLine: HighlightLineEvent;
}

export const codeNodeEditorEventBus = createEventBus<CodeNodeEditorEventBusEvents>();
Loading