mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 21:07:28 -08:00
feat: Enable code capture in ai transform node (no-changelog) (#11241)
This commit is contained in:
parent
b028d81390
commit
4bd4b6977a
|
@ -30,6 +30,7 @@ type Props = {
|
||||||
isReadOnly?: boolean;
|
isReadOnly?: boolean;
|
||||||
fillParent?: boolean;
|
fillParent?: boolean;
|
||||||
rows?: number;
|
rows?: number;
|
||||||
|
posthogCapture?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), { fillParent: false, isReadOnly: false, rows: 4 });
|
const props = withDefaults(defineProps<Props>(), { fillParent: false, isReadOnly: false, rows: 4 });
|
||||||
|
@ -74,6 +75,10 @@ const jsEditorRef = ref<HTMLDivElement>();
|
||||||
const editor = ref<EditorView | null>(null);
|
const editor = ref<EditorView | null>(null);
|
||||||
const editorState = ref<EditorState | null>(null);
|
const editorState = ref<EditorState | null>(null);
|
||||||
|
|
||||||
|
const generatedCodeCapture = computed(() => {
|
||||||
|
return props.posthogCapture ? '' : 'ph-no-capture ';
|
||||||
|
});
|
||||||
|
|
||||||
const extensions = computed(() => {
|
const extensions = computed(() => {
|
||||||
const extensionsToApply: Extension[] = [
|
const extensionsToApply: Extension[] = [
|
||||||
javascript(),
|
javascript(),
|
||||||
|
@ -119,7 +124,7 @@ const extensions = computed(() => {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div :class="$style.editor" :style="isReadOnly ? 'opacity: 0.7' : ''">
|
<div :class="$style.editor" :style="isReadOnly ? 'opacity: 0.7' : ''">
|
||||||
<div ref="jsEditorRef" class="ph-no-capture js-editor"></div>
|
<div ref="jsEditorRef" :class="generatedCodeCapture + 'js-editor'"></div>
|
||||||
<slot name="suffix" />
|
<slot name="suffix" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -40,6 +40,7 @@ import { hasExpressionMapping, isValueExpression } from '@/utils/nodeTypesUtils'
|
||||||
import { isResourceLocatorValue } from '@/utils/typeGuards';
|
import { isResourceLocatorValue } from '@/utils/typeGuards';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
AI_TRANSFORM_NODE_TYPE,
|
||||||
APP_MODALS_ELEMENT_ID,
|
APP_MODALS_ELEMENT_ID,
|
||||||
CORE_NODES_CATEGORY,
|
CORE_NODES_CATEGORY,
|
||||||
CUSTOM_API_CALL_KEY,
|
CUSTOM_API_CALL_KEY,
|
||||||
|
@ -541,6 +542,13 @@ const showDragnDropTip = computed(
|
||||||
ndvStore.isInputParentOfActiveNode,
|
ndvStore.isInputParentOfActiveNode,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const shouldCaptureForPosthog = computed(() => {
|
||||||
|
if (node.value?.type) {
|
||||||
|
return [AI_TRANSFORM_NODE_TYPE].includes(node.value?.type);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
function isRemoteParameterOption(option: INodePropertyOptions) {
|
function isRemoteParameterOption(option: INodePropertyOptions) {
|
||||||
return remoteParameterOptionsKeys.value.includes(option.name);
|
return remoteParameterOptionsKeys.value.includes(option.name);
|
||||||
}
|
}
|
||||||
|
@ -1124,6 +1132,7 @@ onUpdated(async () => {
|
||||||
:model-value="modelValueString"
|
:model-value="modelValueString"
|
||||||
:is-read-only="isReadOnly"
|
:is-read-only="isReadOnly"
|
||||||
:rows="editorRows"
|
:rows="editorRows"
|
||||||
|
:posthog-capture="shouldCaptureForPosthog"
|
||||||
fill-parent
|
fill-parent
|
||||||
@update:model-value="valueChangedDebounced"
|
@update:model-value="valueChangedDebounced"
|
||||||
/>
|
/>
|
||||||
|
@ -1223,6 +1232,7 @@ onUpdated(async () => {
|
||||||
:model-value="modelValueString"
|
:model-value="modelValueString"
|
||||||
:is-read-only="isReadOnly || editorIsReadOnly"
|
:is-read-only="isReadOnly || editorIsReadOnly"
|
||||||
:rows="editorRows"
|
:rows="editorRows"
|
||||||
|
:posthog-capture="shouldCaptureForPosthog"
|
||||||
@update:model-value="valueChangedDebounced"
|
@update:model-value="valueChangedDebounced"
|
||||||
>
|
>
|
||||||
<template #suffix>
|
<template #suffix>
|
||||||
|
|
Loading…
Reference in a new issue