feat: Community Nodes in the Nodes Panel (#13923)

Co-authored-by: Dana Lee <dana@n8n.io>
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Michael Kret
2025-05-09 13:14:41 +03:00
committed by GitHub
parent 345b60e8d3
commit 24638420bd
55 changed files with 2548 additions and 152 deletions

View File

@@ -3,6 +3,7 @@ import type { IVersionNode } from '../Interface';
import { useRootStore } from '../stores/root.store';
import { useUIStore } from '../stores/ui.store';
import { getThemedValue } from './nodeTypesUtils';
import { isNodePreviewKey } from '../components/Node/NodeCreator/utils';
type NodeIconSourceIcon = { type: 'icon'; name: string; color?: string };
type NodeIconSourceFile = {
@@ -17,9 +18,9 @@ export type NodeIconType = 'file' | 'icon' | 'unknown';
type IconNodeTypeDescription = Pick<
INodeTypeDescription,
'icon' | 'iconUrl' | 'iconColor' | 'defaults' | 'badgeIconUrl'
'icon' | 'iconUrl' | 'iconColor' | 'defaults' | 'badgeIconUrl' | 'name'
>;
type IconVersionNode = Pick<IVersionNode, 'icon' | 'iconUrl' | 'iconData' | 'defaults'>;
type IconVersionNode = Pick<IVersionNode, 'icon' | 'iconUrl' | 'iconData' | 'defaults' | 'name'>;
export type IconNodeType = IconNodeTypeDescription | IconVersionNode;
export const getNodeIcon = (nodeType: IconNodeType): string | null => {
@@ -72,6 +73,15 @@ export function getNodeIconSource(nodeType?: IconNodeType | null): NodeIconSourc
}
}
if (nodeType.name && isNodePreviewKey(nodeType.name) && typeof nodeType.iconUrl === 'string') {
// If node type is a node preview it would have full icon url
return {
type: 'file',
src: nodeType.iconUrl,
badge: undefined,
};
}
const iconUrl = getNodeIconUrl(nodeType);
if (iconUrl) {
return createFileIconSource(prefixBaseUrl(iconUrl));