mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -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;
|
||||
fillParent?: boolean;
|
||||
rows?: number;
|
||||
posthogCapture?: boolean;
|
||||
};
|
||||
|
||||
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 editorState = ref<EditorState | null>(null);
|
||||
|
||||
const generatedCodeCapture = computed(() => {
|
||||
return props.posthogCapture ? '' : 'ph-no-capture ';
|
||||
});
|
||||
|
||||
const extensions = computed(() => {
|
||||
const extensionsToApply: Extension[] = [
|
||||
javascript(),
|
||||
|
@ -119,7 +124,7 @@ const extensions = computed(() => {
|
|||
|
||||
<template>
|
||||
<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" />
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -40,6 +40,7 @@ import { hasExpressionMapping, isValueExpression } from '@/utils/nodeTypesUtils'
|
|||
import { isResourceLocatorValue } from '@/utils/typeGuards';
|
||||
|
||||
import {
|
||||
AI_TRANSFORM_NODE_TYPE,
|
||||
APP_MODALS_ELEMENT_ID,
|
||||
CORE_NODES_CATEGORY,
|
||||
CUSTOM_API_CALL_KEY,
|
||||
|
@ -541,6 +542,13 @@ const showDragnDropTip = computed(
|
|||
ndvStore.isInputParentOfActiveNode,
|
||||
);
|
||||
|
||||
const shouldCaptureForPosthog = computed(() => {
|
||||
if (node.value?.type) {
|
||||
return [AI_TRANSFORM_NODE_TYPE].includes(node.value?.type);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
function isRemoteParameterOption(option: INodePropertyOptions) {
|
||||
return remoteParameterOptionsKeys.value.includes(option.name);
|
||||
}
|
||||
|
@ -1124,6 +1132,7 @@ onUpdated(async () => {
|
|||
:model-value="modelValueString"
|
||||
:is-read-only="isReadOnly"
|
||||
:rows="editorRows"
|
||||
:posthog-capture="shouldCaptureForPosthog"
|
||||
fill-parent
|
||||
@update:model-value="valueChangedDebounced"
|
||||
/>
|
||||
|
@ -1223,6 +1232,7 @@ onUpdated(async () => {
|
|||
:model-value="modelValueString"
|
||||
:is-read-only="isReadOnly || editorIsReadOnly"
|
||||
:rows="editorRows"
|
||||
:posthog-capture="shouldCaptureForPosthog"
|
||||
@update:model-value="valueChangedDebounced"
|
||||
>
|
||||
<template #suffix>
|
||||
|
|
Loading…
Reference in a new issue