mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
feat(editor): Add Python to Code actions (#18668)
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user