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 6, 2019
1 parent 9d2d435 commit f00612b
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import * as React from 'react';
import { BitbucketIcon, GitAltIcon, GithubIcon, GitlabIcon } from '@patternfly/react-icons';
import CheIcon from '../topology/shapes/CheIcon';
import { detectGitType } from './import-validation-utils';
import { GitTypes } from './import-types';

export const routeDecoratorIcon = (routeURL: string, radius: number): React.ReactElement => {
export const routeDecoratorIcon = (
routeURL: string,
radius: number,
cheEnabled?: boolean,
): React.ReactElement => {
if (cheEnabled && routeURL) {
return <CheIcon style={{ fontSize: radius }} />;
}
switch (detectGitType(routeURL)) {
case GitTypes.invalid:
// Not a valid url and thus not safe to use
Expand Down
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,20 @@
import * as React from 'react';

const CheIcon: React.FC<React.HTMLProps<SVGElement>> = ({ style }): React.ReactElement => {
return (
<svg height="1em" width="1em" version="1.1" viewBox="0 0 47 57" style={style}>
<g fillRule="evenodd" stroke="none" strokeWidth="1" fill="none">
<path
d="M0.032227,30.88l-0.032227-17.087,23.853-13.793,23.796,13.784-14.691,8.51-9.062-5.109-23.864,13.695z"
fill="#fdb940"
/>
<path
d="M0,43.355l23.876,13.622,23.974-13.937v-16.902l-23.974,13.506-23.876-13.506v17.217z"
fill="#525c86"
/>
</g>
</svg>
);
};

export default 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 @@ -43,12 +43,11 @@ 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 = routeDecoratorIcon(editUrl, decoratorRadius, cheEnabled);
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

0 comments on commit f00612b

Please sign in to comment.