mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix: Fix issue with icon themes not loading for preview nodes (#17869)
Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
@@ -57,6 +57,29 @@ describe('util: Node Icon', () => {
|
||||
getNodeIconUrl(mock<IconNodeType>({ icon: 'foo', iconUrl: undefined })),
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return the iconUrl from nodeType when using https', () => {
|
||||
expect(
|
||||
getNodeIconUrl(
|
||||
mock<IconNodeType>({
|
||||
iconUrl: 'https://my-site.com/icon.svg',
|
||||
}),
|
||||
),
|
||||
).toBe('https://my-site.com/icon.svg');
|
||||
});
|
||||
|
||||
it('should return the iconUrl from nodeType when using https with themed values', () => {
|
||||
expect(
|
||||
getNodeIconUrl(
|
||||
mock<IconNodeType>({
|
||||
iconUrl: {
|
||||
light: 'https://my-site.com/light-icon.svg',
|
||||
dark: 'https://my-site.com/dark-icon.svg',
|
||||
},
|
||||
}),
|
||||
),
|
||||
).toBe('https://my-site.com/light-icon.svg');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getBadgeIconUrl', () => {
|
||||
|
||||
@@ -73,13 +73,25 @@ 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,
|
||||
};
|
||||
if (nodeType.name && isNodePreviewKey(nodeType.name)) {
|
||||
// Handle both string and object iconUrl for preview nodes
|
||||
if (typeof nodeType.iconUrl === 'string') {
|
||||
return {
|
||||
type: 'file',
|
||||
src: nodeType.iconUrl,
|
||||
badge: undefined,
|
||||
};
|
||||
} else if (nodeType.iconUrl && typeof nodeType.iconUrl === 'object') {
|
||||
// Use getThemedValue to get the appropriate theme URL
|
||||
const themedUrl = getThemedValue(nodeType.iconUrl, useUIStore().appliedTheme);
|
||||
if (themedUrl) {
|
||||
return {
|
||||
type: 'file',
|
||||
src: themedUrl,
|
||||
badge: undefined,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const iconUrl = getNodeIconUrl(nodeType);
|
||||
|
||||
Reference in New Issue
Block a user