Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1780338: fix(che-icon): add che Icon in the topology #3629

Merged
merged 1 commit into from
Dec 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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
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
@@ -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;
Expand Up @@ -100,6 +100,7 @@ export interface ConnectedWorkloadPipeline {
export interface WorkloadData {
url?: string;
editUrl?: string;
cheEnabled?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we're better off having a cheUrl here and in the react component check if cheUrl is present then use it and the che icon, else do the status quo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

editUrl is already determining the correct url to pick, this cheEnabled variable is used only to pick the right icons.

builderImage?: string;
kind?: string;
isKnativeResource?: boolean;
Expand Down
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
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
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