Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(editor): Disable fromAI override button for credentialsSelect (no-changelog) #13314

Merged
merged 2 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading