feat(editor): Add Python to Code actions (#18668)

This commit is contained in:
Iván Ovejero
2025-08-26 14:29:50 +02:00
committed by GitHub
parent b73f2393b4
commit 38f25d74eb
16 changed files with 185 additions and 59 deletions

View File

@@ -1586,6 +1586,15 @@ function resolveResourceAndOperation(
nodeParameters: INodeParameters,
nodeTypeDescription: INodeTypeDescription,
) {
if (nodeTypeDescription.name === 'n8n-nodes-base.code') {
const language = nodeParameters.language as string;
const langProp = nodeTypeDescription.properties.find((p) => p.name === 'language');
if (langProp?.options && isINodePropertyOptionsList(langProp.options)) {
const found = langProp.options.find((o) => o.value === language);
if (found?.action) return { action: found.action };
}
}
const resource = nodeParameters.resource as string;
const operation = nodeParameters.operation as string;
const nodeTypeOperation = nodeTypeDescription.properties.find(

View File

@@ -5630,6 +5630,44 @@ describe('NodeHelpers', () => {
// Assert
expect(result).toBe('Create user in Test Node');
});
test.each([
['javaScript', 'Code in JavaScript'],
['python', 'Code in Python (Beta)'],
['pythonNative', 'Code in Python (Native) (Beta)'],
])(
'should return action-based name for Code node with %s language',
(language, expectedAction) => {
mockNodeTypeDescription.name = 'n8n-nodes-base.code';
mockNodeTypeDescription.properties = [
{
displayName: 'Language',
name: 'language',
type: 'options',
options: [
{
name: 'JavaScript',
value: 'javaScript',
action: 'Code in JavaScript',
},
{
name: 'Python (Beta)',
value: 'python',
action: 'Code in Python (Beta)',
},
{
name: 'Python (Native) (Beta)',
value: 'pythonNative',
action: 'Code in Python (Native) (Beta)',
},
],
default: 'javaScript',
},
];
const result = makeNodeName({ language }, mockNodeTypeDescription);
expect(result).toBe(expectedAction);
},
);
});
describe('isTool', () => {
it('should return true for a node with AiTool output', () => {