fixes icon crash for plugins (#4744)

This commit is contained in:
Arpit 2022-11-10 15:51:45 +05:30 committed by GitHub
parent 572db9d09f
commit c1f0408605
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View file

@ -78,7 +78,7 @@ export const LeftSidebarInspector = ({
}
const icon = dataSources.find((ds) => ds.kind === value.kind);
const iconFile = icon?.plugin?.icon_file?.data ?? undefined;
const Icon = () => getSvgIcon(icon.kind, 25, 25, iconFile);
const Icon = () => getSvgIcon(icon?.kind, 25, 25, iconFile ?? undefined);
return { iconName: key, jsx: () => <Icon style={{ height: 16, width: 16, marginRight: 12 }} /> };
});

View file

@ -997,6 +997,8 @@ export const getSvgIcon = (key, height = 50, width = 50, iconFile = undefined, s
if (key === 'runjs') return <RunjsIcon style={{ height, width }} />;
const Icon = allSvgs[key];
if (!Icon) return <></>;
return <Icon style={{ height, width, ...styles }} />;
};