mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(editor): Handle drag-n-dropping from other nodes in assignment component (#8661)
This commit is contained in:
parent
3279762221
commit
c943a51a28
|
@ -0,0 +1,15 @@
|
||||||
|
import { nameFromExpression } from '../utils';
|
||||||
|
|
||||||
|
describe('AssignmentCollection > utils', () => {
|
||||||
|
describe('nameFromExpression', () => {
|
||||||
|
test('should extract assignment name from previous node', () => {
|
||||||
|
expect(nameFromExpression('{{ $json.foo.bar }}')).toBe('foo.bar');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should extract assignment name from another node', () => {
|
||||||
|
expect(nameFromExpression("{{ $('Node's \"Name\" (copy)').item.json.foo.bar }}")).toBe(
|
||||||
|
'foo.bar',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -4,7 +4,10 @@ import { resolveParameter } from '@/composables/useWorkflowHelpers';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
|
|
||||||
export function nameFromExpression(expression: string): string {
|
export function nameFromExpression(expression: string): string {
|
||||||
return expression.replace(/^{{\s*|\s*}}$/g, '').replace('$json.', '');
|
return expression
|
||||||
|
.replace(/^{{\s*|\s*}}$/g, '')
|
||||||
|
.replace('$json.', '')
|
||||||
|
.replace(/^\$\(.*\)(\.item\.json)?\.(.*)/, '$2');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function inferAssignmentType(value: unknown): string {
|
export function inferAssignmentType(value: unknown): string {
|
||||||
|
|
Loading…
Reference in a new issue