Skip to content

Commit

Permalink
fix(editor): Disable fromAI override button for credentialsSelect (no…
Browse files Browse the repository at this point in the history
…-changelog) (#13314)
  • Loading branch information
CharlieKolb authored Feb 19, 2025
1 parent 143cb22 commit 301f5a5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 8 additions & 3 deletions packages/editor-ui/src/utils/fromAIOverrideUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down Expand Up @@ -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();
});
Expand Down
6 changes: 5 additions & 1 deletion packages/editor-ui/src/utils/fromAIOverrideUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ const PATH_DENYLIST = [
'parameters.toolDescription',
];

const PROP_TYPE_DENYLIST = ['options', 'credentialsSelect'];

export const fromAIExtraProps: Record<FromAIExtraProps, ExtraPropValue> = {
description: {
initialValue: '',
Expand Down Expand Up @@ -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') ||
Expand All @@ -173,7 +177,7 @@ export function canBeContentOverride(
)
return false;

return !props.parameter.noDataExpression && 'options' !== props.parameter.type;
return !props.parameter.noDataExpression;
}

export function makeOverrideValue(
Expand Down

0 comments on commit 301f5a5

Please sign in to comment.