Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove olm package dependency from shared package
- Loading branch information
1 parent
0c6f60b
commit 0799c6a
Showing
5 changed files
with
13 additions
and
18 deletions.
There are no files selected for viewing
10 changes: 4 additions & 6 deletions
10
frontend/packages/console-shared/src/utils/__tests__/icon-utils.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
import * as _ from 'lodash'; | ||
import { sampleClusterServiceVersions } from '@console/dev-console/src/components/topology/__tests__/topology-test-data'; | ||
import { ClusterServiceVersionKind } from '@console/operator-lifecycle-manager'; | ||
import * as operatorLogo from '../../images/operator.svg'; | ||
import { getImageForCSVIcon } from '../icon-utils'; | ||
import { mockCSVIcon } from '../__mocks__/mock-csv-icon'; | ||
|
||
describe('Icon Utils', () => { | ||
it('should return icon from csv data', () => { | ||
const mockCSV = _.cloneDeep(sampleClusterServiceVersions.data[0]) as ClusterServiceVersionKind; | ||
expect(getImageForCSVIcon(mockCSV)).toBe(mockCSVIcon); | ||
const mockCSV = _.cloneDeep(sampleClusterServiceVersions.data[0]); | ||
const icon = _.get(mockCSV, 'spec.icon.0'); | ||
expect(getImageForCSVIcon(icon)).toBe(mockCSVIcon); | ||
}); | ||
|
||
it('should return operator icon if csv has no icon data', () => { | ||
const mockCSV = _.cloneDeep(sampleClusterServiceVersions.data[0]) as ClusterServiceVersionKind; | ||
mockCSV.spec.icon = undefined; | ||
expect(getImageForCSVIcon(mockCSV)).toBe(operatorLogo); | ||
expect(getImageForCSVIcon(undefined)).toBe(operatorLogo); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import * as _ from 'lodash'; | ||
import { | ||
ClusterServiceVersionKind, | ||
ClusterServiceVersionIcon, | ||
} from '@console/operator-lifecycle-manager'; | ||
import * as operatorLogo from '../images/operator.svg'; | ||
|
||
export const getImageForCSVIcon = (csv: ClusterServiceVersionKind) => { | ||
const icon: ClusterServiceVersionIcon = _.get(csv, 'spec.icon', []); | ||
return !_.isEmpty(icon) ? `data:${icon[0].mediatype};base64,${icon[0].base64data}` : operatorLogo; | ||
type CSVIcon = { base64data: string; mediatype: string }; | ||
|
||
export const getImageForCSVIcon = (icon: CSVIcon | undefined) => { | ||
return icon ? `data:${icon.mediatype};base64,${icon.base64data}` : operatorLogo; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters