Skip to content

Commit

Permalink
add cheIcon in topology
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikjeeyar committed Dec 2, 2019
1 parent 0ff7e4a commit 4d66de1
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Object {
"data": Object {
"build": undefined,
"builderImage": "test-file-stub",
"cheEnabled": false,
"connectedPipeline": Object {
"pipeline": undefined,
"pipelineRuns": Array [],
Expand Down Expand Up @@ -559,6 +560,7 @@ Object {
"data": Object {
"build": undefined,
"builderImage": "test-file-stub",
"cheEnabled": false,
"connectedPipeline": Object {
"pipeline": undefined,
"pipelineRuns": Array [],
Expand Down Expand Up @@ -1532,6 +1534,7 @@ Object {
"data": Object {
"build": undefined,
"builderImage": "test-file-stub",
"cheEnabled": false,
"connectedPipeline": Object {
"pipeline": undefined,
"pipelineRuns": Array [],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as React from 'react';
import { getImageForIconClass } from '@console/internal/components/catalog/catalog-item-icon';
import { createSvgIdUrl, SVGDefs } from '@console/topology';

type CheIconProps = {
x: number;
y: number;
width: number;
height: number;
};

const FILTER_ID = 'CheIconOutlineFilterId';

const CheIcon: React.FC<CheIconProps> = ({ x, y, width, height }) => (
<>
<SVGDefs id={FILTER_ID}>
<filter id={FILTER_ID}>
<feOffset result="nw" in="SourceAlpha" dx="-0.5" dy="-0.5" />
<feOffset result="ne" in="SourceAlpha" dx="0.5" dy="-0.5" />
<feOffset result="se" in="SourceAlpha" dx="0.5" dy="0.5" />
<feOffset result="sw" in="SourceAlpha" dx="-0.5" dy="0.5" />
<feMerge result="blackborder">
<feMergeNode in="nw" />
<feMergeNode in="ne" />
<feMergeNode in="se" />
<feMergeNode in="sw" />
</feMerge>
<feFlood floodColor="#FFFFFF" />
<feComposite in2="blackborder" operator="in" result="offsetColor" />
<feMerge>
<feMergeNode in="offsetColor" />
<feMergeNode in="SourceGraphic" />
</feMerge>
</filter>
</SVGDefs>
<image
x={x}
y={y}
width={width}
height={height}
xlinkHref={getImageForIconClass('icon-che')}
filter={createSvgIdUrl(FILTER_ID)}
/>
</>
);

export default React.memo(CheIcon);
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export interface ConnectedWorkloadPipeline {
export interface WorkloadData {
url?: string;
editUrl?: string;
cheEnabled?: boolean;
builderImage?: string;
kind?: string;
isKnativeResource?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export const createTopologyNodeData = (
editUrl:
deploymentsAnnotations['app.openshift.io/edit-url'] ||
getEditURL(deploymentsAnnotations['app.openshift.io/vcs-uri'], cheURL),
cheEnabled: !!cheURL,
builderImage:
getImageForIconClass(`icon-${deploymentsLabels['app.openshift.io/runtime']}`) ||
getImageForIconClass(`icon-${deploymentsLabels['app.kubernetes.io/name']}`) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Decorator from '../../../topology/shapes/Decorator';
import { routeDecoratorIcon } from '../../../import/render-utils';
import PodSet from '../../../topology/shapes/PodSet';
import KnativeIcon from '../../../topology/shapes/KnativeIcon';
import CheIcon from '../../../topology/shapes/CheIcon';
import BuildDecorator from './build-decorators/BuildDecorator';
import BaseNode from './BaseNode';

Expand Down Expand Up @@ -43,12 +44,21 @@ const WorkloadNode: React.FC<WorkloadNodeProps> = ({
const { width, height } = element.getBounds();
const workloadData = element.getData().data;
const size = Math.min(width, height);
const { donutStatus } = workloadData;
const { donutStatus, editUrl, cheEnabled } = workloadData;
const { radius, decoratorRadius } = calculateRadius(size);
const repoIcon = routeDecoratorIcon(workloadData.editUrl, decoratorRadius);
const cx = width / 2;
const cy = height / 2;

const repoIcon =
cheEnabled && editUrl ? (
<CheIcon
x={cx - radius * 1.07}
y={cx - radius * 1.02}
width={radius * 0.39}
height={radius * 0.31}
/>
) : (
routeDecoratorIcon(editUrl, decoratorRadius)
);
const tipContent = `Create a ${
element.getData().operatorBackedService ? 'binding' : 'visual'
} connector`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export const createTopologyServiceNodeData = (
editUrl:
annotations['app.openshift.io/edit-url'] ||
getEditURL(annotations['app.openshift.io/vcs-uri'], cheURL),
cheEnabled: !!cheURL,
isKnativeResource: true,
},
};
Expand Down
2 changes: 2 additions & 0 deletions frontend/public/components/catalog/catalog-item-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import * as camelImg from '../../imgs/logos/camel.svg';
import * as capedwarfImg from '../../imgs/logos/capedwarf.svg';
import * as catalogImg from '../../imgs/logos/catalog-icon.svg';
import * as cassandraImg from '../../imgs/logos/cassandra.svg';
import * as cheImg from '../../imgs/logos/che.svg';
import * as clojureImg from '../../imgs/logos/clojure.svg';
import * as codeigniterImg from '../../imgs/logos/codeigniter.svg';
import * as cordovaImg from '../../imgs/logos/cordova.png';
Expand Down Expand Up @@ -102,6 +103,7 @@ const logos = new Map()
.set('icon-capedwarf', capedwarfImg)
.set('icon-catalog', catalogImg)
.set('icon-cassandra', cassandraImg)
.set('icon-che', cheImg)
.set('icon-clojure', clojureImg)
.set('icon-codeigniter', codeigniterImg)
.set('icon-cordova', cordovaImg)
Expand Down
18 changes: 18 additions & 0 deletions frontend/public/imgs/logos/che.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4d66de1

Please sign in to comment.