mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2026-07-31 00:57:23 +02:00
## Summary Provide details about your pull request and what it adds, fixes, or changes. Photos and videos are recommended. As part of NodeView refactor, this PR migrates all externalHooks calls to `useExternalHooks` composable. #### How to test the change: 1. Run using env `export N8N_DEPLOYMENT_TYPE=cloud` 2. Hooks should still run as expected ## Issues fixed Include links to Github issue or Community forum post or **Linear ticket**: > Important in order to close automatically and provide context to reviewers https://linear.app/n8n/issue/N8N-6349/externalhooks ## Review / Merge checklist - [x] PR title and summary are descriptive. **Remember, the title automatically goes into the changelog. Use `(no-changelog)` otherwise.** ([conventions](https://github.com/n8n-io/n8n/blob/master/.github/pull_request_title_conventions.md)) - [x] [Docs updated](https://github.com/n8n-io/n8n-docs) or follow-up ticket created. - [x] Tests included. > A bug is not considered fixed, unless a test is added to prevent it from happening again. A feature is not complete without tests. > > *(internal)* You can use Slack commands to trigger [e2e tests](https://www.notion.so/n8n/How-to-use-Test-Instances-d65f49dfc51f441ea44367fb6f67eb0a?pvs=4#a39f9e5ba64a48b58a71d81c837e8227) or [deploy test instance](https://www.notion.so/n8n/How-to-use-Test-Instances-d65f49dfc51f441ea44367fb6f67eb0a?pvs=4#f6a177d32bde4b57ae2da0b8e454bfce) or [deploy early access version on Cloud](https://www.notion.so/n8n/Cloudbot-3dbe779836004972b7057bc989526998?pvs=4#fef2d36ab02247e1a0f65a74f6fb534e).
127 lines
3.1 KiB
Vue
127 lines
3.1 KiB
Vue
<script lang="ts" setup>
|
|
import { computed, ref } from 'vue';
|
|
import type { INodeUi } from '@/Interface';
|
|
import RunDataSchemaItem from '@/components/RunDataSchemaItem.vue';
|
|
import Draggable from '@/components/Draggable.vue';
|
|
import { useNDVStore } from '@/stores/ndv.store';
|
|
import { telemetry } from '@/plugins/telemetry';
|
|
import type { IDataObject } from 'n8n-workflow';
|
|
import { isEmpty } from '@/utils/typesUtils';
|
|
import { useExternalHooks } from '@/composables/useExternalHooks';
|
|
import { i18n } from '@/plugins/i18n';
|
|
import MappingPill from './MappingPill.vue';
|
|
import { useDataSchema } from '@/composables/useDataSchema';
|
|
|
|
type Props = {
|
|
data: IDataObject[];
|
|
mappingEnabled: boolean;
|
|
distanceFromActive: number;
|
|
runIndex: number;
|
|
totalRuns: number;
|
|
paneType: 'input' | 'output';
|
|
node: INodeUi | null;
|
|
search: string;
|
|
};
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
distanceFromActive: 0,
|
|
});
|
|
|
|
const draggingPath = ref<string>('');
|
|
const ndvStore = useNDVStore();
|
|
const { getSchemaForExecutionData } = useDataSchema();
|
|
|
|
const schema = computed(() => getSchemaForExecutionData(props.data));
|
|
|
|
const isDataEmpty = computed(() => isEmpty(props.data));
|
|
|
|
const onDragStart = (el: HTMLElement) => {
|
|
if (el?.dataset?.path) {
|
|
draggingPath.value = el.dataset.path;
|
|
}
|
|
|
|
ndvStore.resetMappingTelemetry();
|
|
};
|
|
const onDragEnd = (el: HTMLElement) => {
|
|
draggingPath.value = '';
|
|
|
|
setTimeout(() => {
|
|
const mappingTelemetry = ndvStore.mappingTelemetry;
|
|
const telemetryPayload = {
|
|
src_node_type: props.node?.type,
|
|
src_field_name: el.dataset.name || '',
|
|
src_nodes_back: props.distanceFromActive,
|
|
src_run_index: props.runIndex,
|
|
src_runs_total: props.totalRuns,
|
|
src_field_nest_level: el.dataset.depth || 0,
|
|
src_view: 'schema',
|
|
src_element: el,
|
|
success: false,
|
|
...mappingTelemetry,
|
|
};
|
|
|
|
void useExternalHooks().run('runDataJson.onDragEnd', telemetryPayload);
|
|
|
|
telemetry.track('User dragged data for mapping', telemetryPayload);
|
|
}, 1000); // ensure dest data gets set if drop
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<div :class="$style.schemaWrapper">
|
|
<n8n-info-tip v-if="isDataEmpty">{{
|
|
i18n.baseText('dataMapping.schemaView.emptyData')
|
|
}}</n8n-info-tip>
|
|
<draggable
|
|
v-else
|
|
type="mapping"
|
|
targetDataKey="mappable"
|
|
:disabled="!mappingEnabled"
|
|
@dragstart="onDragStart"
|
|
@dragend="onDragEnd"
|
|
>
|
|
<template #preview="{ canDrop, el }">
|
|
<MappingPill v-if="el" :html="el.outerHTML" :can-drop="canDrop" />
|
|
</template>
|
|
<div :class="$style.schema">
|
|
<run-data-schema-item
|
|
:schema="schema"
|
|
:level="0"
|
|
:parent="null"
|
|
:paneType="paneType"
|
|
:subKey="`${schema.type}-0-0`"
|
|
:mappingEnabled="mappingEnabled"
|
|
:draggingPath="draggingPath"
|
|
:distanceFromActive="distanceFromActive"
|
|
:node="node"
|
|
:search="search"
|
|
/>
|
|
</div>
|
|
</draggable>
|
|
</div>
|
|
</template>
|
|
|
|
<style lang="scss" module>
|
|
.schemaWrapper {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
bottom: 0;
|
|
right: 0;
|
|
overflow: auto;
|
|
line-height: 1.5;
|
|
word-break: normal;
|
|
height: 100%;
|
|
width: 100%;
|
|
|
|
> div[class*='info'] {
|
|
padding: 0 var(--spacing-s);
|
|
}
|
|
}
|
|
|
|
.schema {
|
|
display: inline-block;
|
|
padding: 0 var(--spacing-s) var(--spacing-s);
|
|
}
|
|
</style>
|