Skip to content

Commit

Permalink
Bug 1810046: Show CSV icon from default channel
Browse files Browse the repository at this point in the history
We were always showing the icon from the first CSV channel in OperatorHub.
We should prefer the icon from the `defaultChannel` when specified.
  • Loading branch information
spadgett committed Jun 5, 2020
1 parent e90c722 commit bf8957d
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,25 @@ export const providedAPIsForChannel = (pkg: PackageManifestKind) => (channel: st
]),
);

export const iconFor = (pkg: PackageManifestKind) =>
resourceURL(PackageManifestModel, {
ns: _.get(pkg.status, 'catalogSourceNamespace'),
export const iconFor = (pkg: PackageManifestKind) => {
const defaultChannel = pkg?.status?.defaultChannel
? pkg.status.channels?.find((ch) => ch.name === pkg.status.defaultChannel)
: pkg?.status?.channels?.[0];
if (!defaultChannel) {
return null;
}

return resourceURL(PackageManifestModel, {
ns: pkg?.status?.catalogSourceNamespace,
name: pkg.metadata.name,
path: 'icon',
queryParams: {
resourceVersion: [
pkg.metadata.name,
_.get(pkg.status, 'channels[0].name'),
_.get(pkg.status, 'channels[0].currentCSV'),
].join('.'),
resourceVersion: [pkg.metadata.name, defaultChannel.name, defaultChannel.currentCSV].join(
'.',
),
},
});
};

export const ClusterServiceVersionLogo: React.SFC<ClusterServiceVersionLogoProps> = (props) => {
const { icon, displayName, provider, version } = props;
Expand Down

0 comments on commit bf8957d

Please sign in to comment.