Skip to content

Commit

Permalink
fix(787): Display connector icon in catalog detail modal
Browse files Browse the repository at this point in the history
  • Loading branch information
tplevko committed Sep 23, 2024
1 parent 57fb9d1 commit cd7d95e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/ui/src/camel-utils/camel-to-tile.adapter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ITile } from '../components/Catalog/Catalog.models';
import { CatalogKind, ICamelComponentDefinition, ICamelProcessorDefinition, IKameletDefinition } from '../models';
import { NodeIconType } from '../utils';

export const camelComponentToTile = (componentDef: ICamelComponentDefinition): ITile => {
const { name, title, description, supportLevel, label, provider, version } = componentDef.component;
Expand Down Expand Up @@ -30,6 +31,7 @@ export const camelComponentToTile = (componentDef: ICamelComponentDefinition): I
tags,
provider,
version,
nodeIconType: NodeIconType.Component,
};
};

Expand All @@ -44,6 +46,7 @@ export const camelProcessorToTile = (processorDef: ICamelProcessorDefinition): I
description,
headerTags: ['Processor'],
tags,
nodeIconType: NodeIconType.EIP,
};
};

Expand Down Expand Up @@ -71,5 +74,6 @@ export const kameletToTile = (kameletDef: IKameletDefinition): ITile => {
headerTags,
tags,
version,
nodeIconType: NodeIconType.Kamelet,
};
};
3 changes: 3 additions & 0 deletions packages/ui/src/components/Catalog/Catalog.models.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { NodeIconType } from '../../utils';

export interface ITile {
type: string;
name: string;
Expand All @@ -7,6 +9,7 @@ export interface ITile {
tags: string[];
version?: string;
provider?: string;
nodeIconType?: NodeIconType;
}

export type TileFilter = (item: ITile) => boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,13 @@
height: 60vh;
}
}

&__title-image {
height: 50px;
width: 50px;
}

&__title {
padding: 10px;
}
}
21 changes: 17 additions & 4 deletions packages/ui/src/components/PropertiesModal/PropertiesModal.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { Modal, ModalBoxBody, Tab, Tabs } from '@patternfly/react-core';
import { FunctionComponent, useContext, useEffect, useMemo, useState } from 'react';
import { IPropertiesTab } from './PropertiesModal.models';
import { FunctionComponent, ReactElement, useContext, useEffect, useMemo, useState } from 'react';
import {
transformCamelComponentIntoTab,
transformCamelProcessorComponentIntoTab,
transformKameletComponentIntoTab,
} from '../../camel-utils/camel-to-tabs.adapter';
import { CatalogKind } from '../../models';
import { CatalogContext } from '../../providers';
import { NodeIconResolver, NodeIconType } from '../../utils';
import { ITile } from '../Catalog';
import { IPropertiesTab } from './PropertiesModal.models';
import './PropertiesModal.scss';
import { PropertiesTabs } from './PropertiesTabs';
import { EmptyTableState } from './Tables';
import { CatalogContext } from '../../providers';

interface IPropertiesModalProps {
tile: ITile;
Expand Down Expand Up @@ -50,6 +51,18 @@ export const PropertiesModal: FunctionComponent<IPropertiesModalProps> = (props)
setActiveTab(tabs[tabIndex as number]);
setActiveTabKey(tabIndex as number);
};
const iconName = props.tile.nodeIconType === NodeIconType.Kamelet ? `kamelet:${props.tile.name}` : props.tile.name;

const title: ReactElement = (
<div style={{ display: 'flex' }}>
<img
className={'properties-modal__title-image'}
src={NodeIconResolver.getIcon(iconName, props.tile.nodeIconType!)}
alt={`${props.tile.type} icon`}
/>
<h1 className="properties-modal__title">{props.tile.title}</h1>
</div>
);

const description = (
<div>
Expand All @@ -66,7 +79,7 @@ export const PropertiesModal: FunctionComponent<IPropertiesModalProps> = (props)
return (
<Modal
className="properties-modal"
title={props.tile.title}
title={title}
isOpen={props.isModalOpen}
onClose={props.onClose}
ouiaId="BasicModal"
Expand Down

0 comments on commit cd7d95e

Please sign in to comment.