feat: Enable code capture in ai transform node (no-changelog) (#11241)

This commit is contained in:
Michael Kret 2024-10-14 16:53:16 +03:00 committed by GitHub
parent b028d81390
commit 4bd4b6977a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View file

@ -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>

View file

@ -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>