mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-02 17:57:06 +02:00
fix(editor): Disable fromAI override button for credentialsSelect (no-changelog) (#13314)
This commit is contained in:
parent
143cb22bc5
commit
301f5a50d9
|
|
@ -6,16 +6,20 @@ import {
|
|||
makeOverrideValue,
|
||||
parseOverrides,
|
||||
} from './fromAIOverrideUtils';
|
||||
import type { INodeTypeDescription } from 'n8n-workflow';
|
||||
import type { INodeTypeDescription, NodePropertyTypes } from 'n8n-workflow';
|
||||
|
||||
const DISPLAY_NAME = 'aDisplayName';
|
||||
const PARAMETER_NAME = 'aName';
|
||||
|
||||
const makeContext = (value: string, path?: string): OverrideContext => ({
|
||||
const makeContext = (
|
||||
value: string,
|
||||
path?: string,
|
||||
type: NodePropertyTypes = 'string',
|
||||
): OverrideContext => ({
|
||||
parameter: {
|
||||
name: PARAMETER_NAME,
|
||||
displayName: DISPLAY_NAME,
|
||||
type: 'string',
|
||||
type,
|
||||
},
|
||||
value,
|
||||
path: path ?? `parameters.${PARAMETER_NAME}`,
|
||||
|
|
@ -77,6 +81,7 @@ describe('makeOverrideValue', () => {
|
|||
['ai node type on denylist', makeContext(''), AI_DENYLIST_NODE_TYPE],
|
||||
['vector store type', makeContext(''), AI_VECTOR_STORE_NODE_TYPE],
|
||||
['denied parameter name', makeContext('', 'parameters.toolName'), AI_NODE_TYPE],
|
||||
['denied parameter type', makeContext('', undefined, 'credentialsSelect'), AI_NODE_TYPE],
|
||||
])('should not create an override for %s', (_name, context, nodeType) => {
|
||||
expect(makeOverrideValue(context, nodeType)).toBeNull();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ const PATH_DENYLIST = [
|
|||
'parameters.toolDescription',
|
||||
];
|
||||
|
||||
const PROP_TYPE_DENYLIST = ['options', 'credentialsSelect'];
|
||||
|
||||
export const fromAIExtraProps: Record<FromAIExtraProps, ExtraPropValue> = {
|
||||
description: {
|
||||
initialValue: '',
|
||||
|
|
@ -165,6 +167,8 @@ export function canBeContentOverride(
|
|||
|
||||
if (PATH_DENYLIST.includes(props.path)) return false;
|
||||
|
||||
if (PROP_TYPE_DENYLIST.includes(props.parameter.type)) return false;
|
||||
|
||||
const codex = nodeType?.codex;
|
||||
if (
|
||||
!codex?.categories?.includes('AI') ||
|
||||
|
|
@ -173,7 +177,7 @@ export function canBeContentOverride(
|
|||
)
|
||||
return false;
|
||||
|
||||
return !props.parameter.noDataExpression && 'options' !== props.parameter.type;
|
||||
return !props.parameter.noDataExpression;
|
||||
}
|
||||
|
||||
export function makeOverrideValue(
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user