mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(editor): Updating node reference pattern in expression editor (#6228)
* feat(editor): Updating node reference pattern in expression editor * ⚡ Updated node ref when dragging data, telemetry and some comments * ✔️ Updating tests * 🔨 Removing old telemetry code, updating the current one based on the review feedback * ✔️ Updating mapping e2e tests
This commit is contained in:
committed by
GitHub
parent
fc181ffbff
commit
13bcec1661
@@ -194,7 +194,7 @@ describe('Data mapping', () => {
|
|||||||
ndv.actions.mapToParameter('value');
|
ndv.actions.mapToParameter('value');
|
||||||
ndv.getters
|
ndv.getters
|
||||||
.inlineExpressionEditorInput()
|
.inlineExpressionEditorInput()
|
||||||
.should('have.text', `{{ $node['${SCHEDULE_TRIGGER_NODE_NAME}'].json.input[0].count }}`);
|
.should('have.text', `{{ $('${SCHEDULE_TRIGGER_NODE_NAME}').item.json.input[0].count }}`);
|
||||||
ndv.getters.parameterExpressionPreview('value').should('not.exist');
|
ndv.getters.parameterExpressionPreview('value').should('not.exist');
|
||||||
|
|
||||||
ndv.actions.switchInputMode('Table');
|
ndv.actions.switchInputMode('Table');
|
||||||
@@ -203,7 +203,7 @@ describe('Data mapping', () => {
|
|||||||
.inlineExpressionEditorInput()
|
.inlineExpressionEditorInput()
|
||||||
.should(
|
.should(
|
||||||
'have.text',
|
'have.text',
|
||||||
`{{ $node['${SCHEDULE_TRIGGER_NODE_NAME}'].json.input[0].count }} {{ $node['${SCHEDULE_TRIGGER_NODE_NAME}'].json.input }}`,
|
`{{ $('${SCHEDULE_TRIGGER_NODE_NAME}').item.json.input[0].count }} {{ $('${SCHEDULE_TRIGGER_NODE_NAME}').item.json.input }}`,
|
||||||
);
|
);
|
||||||
ndv.actions.validateExpressionPreview('value', ' ');
|
ndv.actions.validateExpressionPreview('value', ' ');
|
||||||
|
|
||||||
@@ -311,12 +311,12 @@ describe('Data mapping', () => {
|
|||||||
ndv.getters.parameterInput('keepOnlySet').find('input[type="text"]')
|
ndv.getters.parameterInput('keepOnlySet').find('input[type="text"]')
|
||||||
.should('exist')
|
.should('exist')
|
||||||
.invoke('css', 'border')
|
.invoke('css', 'border')
|
||||||
.then((border) => expect(border).to.include('1.5px dashed rgb(90, 76, 194)'));
|
.then((border) => expect(border).to.include('dashed rgb(90, 76, 194)'));
|
||||||
|
|
||||||
ndv.getters.parameterInput('value').find('input[type="text"]')
|
ndv.getters.parameterInput('value').find('input[type="text"]')
|
||||||
.should('exist')
|
.should('exist')
|
||||||
.invoke('css', 'border')
|
.invoke('css', 'border')
|
||||||
.then((border) => expect(border).to.include('1.5px dashed rgb(90, 76, 194)'));
|
.then((border) => expect(border).to.include('dashed rgb(90, 76, 194)'));
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -181,8 +181,10 @@ export default mixins(externalHooks, genericHelpers, debounceHelper).extend({
|
|||||||
trackProperties.variable_type = 'Raw value';
|
trackProperties.variable_type = 'Raw value';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (splitVar[0].startsWith('$node')) {
|
if (splitVar[0].startsWith("$('")) {
|
||||||
const sourceNodeName = splitVar[0].split('"')[1];
|
const match = /\$\('(.*?)'\)/.exec(splitVar[0]);
|
||||||
|
if (match && match.length > 1) {
|
||||||
|
const sourceNodeName = match[1];
|
||||||
trackProperties.node_type_source =
|
trackProperties.node_type_source =
|
||||||
this.workflowsStore.getNodeByName(sourceNodeName)?.type;
|
this.workflowsStore.getNodeByName(sourceNodeName)?.type;
|
||||||
const nodeConnections: Array<Array<{ node: string }>> =
|
const nodeConnections: Array<Array<{ node: string }>> =
|
||||||
@@ -190,13 +192,12 @@ export default mixins(externalHooks, genericHelpers, debounceHelper).extend({
|
|||||||
trackProperties.is_immediate_input =
|
trackProperties.is_immediate_input =
|
||||||
nodeConnections &&
|
nodeConnections &&
|
||||||
nodeConnections[0] &&
|
nodeConnections[0] &&
|
||||||
!!nodeConnections[0].find(({ node }) => node === this.ndvStore.activeNode?.name || '')
|
nodeConnections[0].some(({ node }) => node === this.ndvStore.activeNode?.name || '');
|
||||||
? true
|
|
||||||
: false;
|
|
||||||
|
|
||||||
if (splitVar[1].startsWith('parameter')) {
|
if (splitVar[1].startsWith('parameter')) {
|
||||||
trackProperties.parameter_name_source = splitVar[1].split('"')[1];
|
trackProperties.parameter_name_source = splitVar[1].split('"')[1];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
trackProperties.is_immediate_input = true;
|
trackProperties.is_immediate_input = true;
|
||||||
|
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ export default mixins(workflowHelpers).extend({
|
|||||||
* @param {number} [runIndex=0] The index of the run
|
* @param {number} [runIndex=0] The index of the run
|
||||||
* @param {string} [inputName='main'] The name of the input
|
* @param {string} [inputName='main'] The name of the input
|
||||||
* @param {number} [outputIndex=0] The index of the output
|
* @param {number} [outputIndex=0] The index of the output
|
||||||
* @param {boolean} [useShort=false] Use short notation $json vs. $node[NodeName].json
|
* @param {boolean} [useShort=false] Use short notation $json vs. $('NodeName').json
|
||||||
*/
|
*/
|
||||||
getNodeRunDataOutput(
|
getNodeRunDataOutput(
|
||||||
nodeName: string,
|
nodeName: string,
|
||||||
@@ -351,7 +351,7 @@ export default mixins(workflowHelpers).extend({
|
|||||||
* @param {string} nodeName The name of the node to get the data of
|
* @param {string} nodeName The name of the node to get the data of
|
||||||
* @param {IPinData[string]} pinData The node's pin data
|
* @param {IPinData[string]} pinData The node's pin data
|
||||||
* @param {string} filterText Filter text for parameters
|
* @param {string} filterText Filter text for parameters
|
||||||
* @param {boolean} [useShort=false] Use short notation $json vs. $node[NodeName].json
|
* @param {boolean} [useShort=false] Use short notation $json vs. $('NodeName').json
|
||||||
*/
|
*/
|
||||||
getNodePinDataOutput(
|
getNodePinDataOutput(
|
||||||
nodeName: string,
|
nodeName: string,
|
||||||
@@ -382,7 +382,7 @@ export default mixins(workflowHelpers).extend({
|
|||||||
|
|
||||||
// Get json data
|
// Get json data
|
||||||
if (outputData.hasOwnProperty('json')) {
|
if (outputData.hasOwnProperty('json')) {
|
||||||
const jsonPropertyPrefix = useShort === true ? '$json' : `$node["${nodeName}"].json`;
|
const jsonPropertyPrefix = useShort === true ? '$json' : `$('${nodeName}').item.json`;
|
||||||
|
|
||||||
const jsonDataOptions: IVariableSelectorOption[] = [];
|
const jsonDataOptions: IVariableSelectorOption[] = [];
|
||||||
for (const propertyName of Object.keys(outputData.json)) {
|
for (const propertyName of Object.keys(outputData.json)) {
|
||||||
@@ -407,7 +407,7 @@ export default mixins(workflowHelpers).extend({
|
|||||||
|
|
||||||
// Get binary data
|
// Get binary data
|
||||||
if (outputData.hasOwnProperty('binary')) {
|
if (outputData.hasOwnProperty('binary')) {
|
||||||
const binaryPropertyPrefix = useShort === true ? '$binary' : `$node["${nodeName}"].binary`;
|
const binaryPropertyPrefix = useShort === true ? '$binary' : `$('${nodeName}').item.binary`;
|
||||||
|
|
||||||
const binaryData = [];
|
const binaryData = [];
|
||||||
let binaryPropertyData = [];
|
let binaryPropertyData = [];
|
||||||
@@ -523,7 +523,7 @@ export default mixins(workflowHelpers).extend({
|
|||||||
|
|
||||||
returnData.push({
|
returnData.push({
|
||||||
name: key,
|
name: key,
|
||||||
key: `$node["${nodeName}"].context["${key}"]`,
|
key: `$('${nodeName}').context["${key}"]`,
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
value: nodeContext[key],
|
value: nodeContext[key],
|
||||||
});
|
});
|
||||||
@@ -604,6 +604,7 @@ export default mixins(workflowHelpers).extend({
|
|||||||
const currentNodeData: IVariableSelectorOption[] = [];
|
const currentNodeData: IVariableSelectorOption[] = [];
|
||||||
|
|
||||||
let tempOptions: IVariableSelectorOption[];
|
let tempOptions: IVariableSelectorOption[];
|
||||||
|
|
||||||
if (executionData !== null && executionData.data !== undefined) {
|
if (executionData !== null && executionData.data !== undefined) {
|
||||||
const runExecutionData: IRunExecutionData = executionData.data;
|
const runExecutionData: IRunExecutionData = executionData.data;
|
||||||
|
|
||||||
@@ -774,12 +775,7 @@ export default mixins(workflowHelpers).extend({
|
|||||||
{
|
{
|
||||||
name: this.$locale.baseText('variableSelector.parameters'),
|
name: this.$locale.baseText('variableSelector.parameters'),
|
||||||
options: this.sortOptions(
|
options: this.sortOptions(
|
||||||
this.getNodeParameters(
|
this.getNodeParameters(nodeName, `$('${nodeName}').params`, undefined, filterText),
|
||||||
nodeName,
|
|
||||||
`$node["${nodeName}"].parameter`,
|
|
||||||
undefined,
|
|
||||||
filterText,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
} as IVariableSelectorOption,
|
} as IVariableSelectorOption,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ exports[`RunDataJson.vue > renders json values properly 1`] = `
|
|||||||
data-name="list"
|
data-name="list"
|
||||||
data-path="[0].list"
|
data-path="[0].list"
|
||||||
data-target="mappable"
|
data-target="mappable"
|
||||||
data-value="{{ $node.Set.json.list }}"
|
data-value="{{ $('Set').item.json.list }}"
|
||||||
>
|
>
|
||||||
"list"
|
"list"
|
||||||
</span>
|
</span>
|
||||||
@@ -143,7 +143,7 @@ exports[`RunDataJson.vue > renders json values properly 1`] = `
|
|||||||
data-name="list[0]"
|
data-name="list[0]"
|
||||||
data-path="[0].list[0]"
|
data-path="[0].list[0]"
|
||||||
data-target="mappable"
|
data-target="mappable"
|
||||||
data-value="{{ $node.Set.json.list[0] }}"
|
data-value="{{ $('Set').item.json.list[0] }}"
|
||||||
>
|
>
|
||||||
1
|
1
|
||||||
</span>
|
</span>
|
||||||
@@ -185,7 +185,7 @@ exports[`RunDataJson.vue > renders json values properly 1`] = `
|
|||||||
data-name="list[1]"
|
data-name="list[1]"
|
||||||
data-path="[0].list[1]"
|
data-path="[0].list[1]"
|
||||||
data-target="mappable"
|
data-target="mappable"
|
||||||
data-value="{{ $node.Set.json.list[1] }}"
|
data-value="{{ $('Set').item.json.list[1] }}"
|
||||||
>
|
>
|
||||||
2
|
2
|
||||||
</span>
|
</span>
|
||||||
@@ -227,7 +227,7 @@ exports[`RunDataJson.vue > renders json values properly 1`] = `
|
|||||||
data-name="list[2]"
|
data-name="list[2]"
|
||||||
data-path="[0].list[2]"
|
data-path="[0].list[2]"
|
||||||
data-target="mappable"
|
data-target="mappable"
|
||||||
data-value="{{ $node.Set.json.list[2] }}"
|
data-value="{{ $('Set').item.json.list[2] }}"
|
||||||
>
|
>
|
||||||
3
|
3
|
||||||
</span>
|
</span>
|
||||||
@@ -292,7 +292,7 @@ exports[`RunDataJson.vue > renders json values properly 1`] = `
|
|||||||
data-name="record"
|
data-name="record"
|
||||||
data-path="[0].record"
|
data-path="[0].record"
|
||||||
data-target="mappable"
|
data-target="mappable"
|
||||||
data-value="{{ $node.Set.json.record }}"
|
data-value="{{ $('Set').item.json.record }}"
|
||||||
>
|
>
|
||||||
"record"
|
"record"
|
||||||
</span>
|
</span>
|
||||||
@@ -339,7 +339,7 @@ exports[`RunDataJson.vue > renders json values properly 1`] = `
|
|||||||
data-name="name"
|
data-name="name"
|
||||||
data-path="[0].record.name"
|
data-path="[0].record.name"
|
||||||
data-target="mappable"
|
data-target="mappable"
|
||||||
data-value="{{ $node.Set.json.record.name }}"
|
data-value="{{ $('Set').item.json.record.name }}"
|
||||||
>
|
>
|
||||||
"name"
|
"name"
|
||||||
</span>
|
</span>
|
||||||
@@ -417,7 +417,7 @@ exports[`RunDataJson.vue > renders json values properly 1`] = `
|
|||||||
data-name="myNumber"
|
data-name="myNumber"
|
||||||
data-path="[0].myNumber"
|
data-path="[0].myNumber"
|
||||||
data-target="mappable"
|
data-target="mappable"
|
||||||
data-value="{{ $node.Set.json.myNumber }}"
|
data-value="{{ $('Set').item.json.myNumber }}"
|
||||||
>
|
>
|
||||||
"myNumber"
|
"myNumber"
|
||||||
</span>
|
</span>
|
||||||
@@ -467,7 +467,7 @@ exports[`RunDataJson.vue > renders json values properly 1`] = `
|
|||||||
data-name="myStringNumber"
|
data-name="myStringNumber"
|
||||||
data-path="[0].myStringNumber"
|
data-path="[0].myStringNumber"
|
||||||
data-target="mappable"
|
data-target="mappable"
|
||||||
data-value="{{ $node.Set.json.myStringNumber }}"
|
data-value="{{ $('Set').item.json.myStringNumber }}"
|
||||||
>
|
>
|
||||||
"myStringNumber"
|
"myStringNumber"
|
||||||
</span>
|
</span>
|
||||||
@@ -517,7 +517,7 @@ exports[`RunDataJson.vue > renders json values properly 1`] = `
|
|||||||
data-name="myStringText"
|
data-name="myStringText"
|
||||||
data-path="[0].myStringText"
|
data-path="[0].myStringText"
|
||||||
data-target="mappable"
|
data-target="mappable"
|
||||||
data-value="{{ $node.Set.json.myStringText }}"
|
data-value="{{ $('Set').item.json.myStringText }}"
|
||||||
>
|
>
|
||||||
"myStringText"
|
"myStringText"
|
||||||
</span>
|
</span>
|
||||||
@@ -567,7 +567,7 @@ exports[`RunDataJson.vue > renders json values properly 1`] = `
|
|||||||
data-name="nil"
|
data-name="nil"
|
||||||
data-path="[0].nil"
|
data-path="[0].nil"
|
||||||
data-target="mappable"
|
data-target="mappable"
|
||||||
data-value="{{ $node.Set.json.nil }}"
|
data-value="{{ $('Set').item.json.nil }}"
|
||||||
>
|
>
|
||||||
"nil"
|
"nil"
|
||||||
</span>
|
</span>
|
||||||
@@ -617,7 +617,7 @@ exports[`RunDataJson.vue > renders json values properly 1`] = `
|
|||||||
data-name="d"
|
data-name="d"
|
||||||
data-path="[0].d"
|
data-path="[0].d"
|
||||||
data-target="mappable"
|
data-target="mappable"
|
||||||
data-value="{{ $node.Set.json.d }}"
|
data-value="{{ $('Set').item.json.d }}"
|
||||||
>
|
>
|
||||||
"d"
|
"d"
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ describe('Mapping Utils', () => {
|
|||||||
path: ['sample', 'path'],
|
path: ['sample', 'path'],
|
||||||
};
|
};
|
||||||
const result = getMappedExpression(input);
|
const result = getMappedExpression(input);
|
||||||
expect(result).toBe('{{ $node.nodeName.json.sample.path }}');
|
expect(result).toBe("{{ $('nodeName').item.json.sample.path }}");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should generate a mapped expression with mixed array path', () => {
|
it('should generate a mapped expression with mixed array path', () => {
|
||||||
@@ -217,7 +217,7 @@ describe('Mapping Utils', () => {
|
|||||||
path: ['sample', 0, 'path'],
|
path: ['sample', 0, 'path'],
|
||||||
};
|
};
|
||||||
const result = getMappedExpression(input);
|
const result = getMappedExpression(input);
|
||||||
expect(result).toBe('{{ $node.nodeName.json.sample[0].path }}');
|
expect(result).toBe("{{ $('nodeName').item.json.sample[0].path }}");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should generate a mapped expression with special characters in array path', () => {
|
it('should generate a mapped expression with special characters in array path', () => {
|
||||||
@@ -228,7 +228,7 @@ describe('Mapping Utils', () => {
|
|||||||
};
|
};
|
||||||
const result = getMappedExpression(input);
|
const result = getMappedExpression(input);
|
||||||
expect(result).toBe(
|
expect(result).toBe(
|
||||||
"{{ $node.nodeName.json.sample['path with-space']['path-with-hyphen'] }}",
|
"{{ $('nodeName').item.json.sample['path with-space']['path-with-hyphen'] }}",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@ describe('Mapping Utils', () => {
|
|||||||
};
|
};
|
||||||
const result = getMappedExpression(input);
|
const result = getMappedExpression(input);
|
||||||
expect(result).toBe(
|
expect(result).toBe(
|
||||||
"{{ $node.nodeName.json.sample['\"Execute\"']['`Execute`']['\\'Execute\\'']['[Execute]']['{Execute}']['execute?']['test,']['test:']['path.'] }}",
|
"{{ $('nodeName').item.json.sample['\"Execute\"']['`Execute`']['\\'Execute\\'']['[Execute]']['{Execute}']['execute?']['test,']['test:']['path.'] }}",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ export function getMappedExpression({
|
|||||||
distanceFromActive: number;
|
distanceFromActive: number;
|
||||||
path: Array<string | number> | string;
|
path: Array<string | number> | string;
|
||||||
}) {
|
}) {
|
||||||
const root = distanceFromActive === 1 ? '$json' : generatePath('$node', [nodeName, 'json']);
|
const root =
|
||||||
|
distanceFromActive === 1 ? '$json' : generatePath(`$('${nodeName}')`, ['item', 'json']);
|
||||||
|
|
||||||
if (typeof path === 'string') {
|
if (typeof path === 'string') {
|
||||||
return `{{ ${root}${path} }}`;
|
return `{{ ${root}${path} }}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user