From cd7d95ea24a0f0364b10a5c7767bfe75b3c06b11 Mon Sep 17 00:00:00 2001 From: tplevko Date: Mon, 23 Sep 2024 09:16:32 +0200 Subject: [PATCH] fix(787): Display connector icon in catalog detail modal --- .../src/camel-utils/camel-to-tile.adapter.ts | 4 ++++ .../src/components/Catalog/Catalog.models.ts | 3 +++ .../PropertiesModal/PropertiesModal.scss | 9 ++++++++ .../PropertiesModal/PropertiesModal.tsx | 21 +++++++++++++++---- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/packages/ui/src/camel-utils/camel-to-tile.adapter.ts b/packages/ui/src/camel-utils/camel-to-tile.adapter.ts index 235f7e13a..af57169db 100644 --- a/packages/ui/src/camel-utils/camel-to-tile.adapter.ts +++ b/packages/ui/src/camel-utils/camel-to-tile.adapter.ts @@ -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; @@ -30,6 +31,7 @@ export const camelComponentToTile = (componentDef: ICamelComponentDefinition): I tags, provider, version, + nodeIconType: NodeIconType.Component, }; }; @@ -44,6 +46,7 @@ export const camelProcessorToTile = (processorDef: ICamelProcessorDefinition): I description, headerTags: ['Processor'], tags, + nodeIconType: NodeIconType.EIP, }; }; @@ -71,5 +74,6 @@ export const kameletToTile = (kameletDef: IKameletDefinition): ITile => { headerTags, tags, version, + nodeIconType: NodeIconType.Kamelet, }; }; diff --git a/packages/ui/src/components/Catalog/Catalog.models.ts b/packages/ui/src/components/Catalog/Catalog.models.ts index 1d6325c97..93d0ac835 100644 --- a/packages/ui/src/components/Catalog/Catalog.models.ts +++ b/packages/ui/src/components/Catalog/Catalog.models.ts @@ -1,3 +1,5 @@ +import { NodeIconType } from '../../utils'; + export interface ITile { type: string; name: string; @@ -7,6 +9,7 @@ export interface ITile { tags: string[]; version?: string; provider?: string; + nodeIconType?: NodeIconType; } export type TileFilter = (item: ITile) => boolean; diff --git a/packages/ui/src/components/PropertiesModal/PropertiesModal.scss b/packages/ui/src/components/PropertiesModal/PropertiesModal.scss index 9dc2c4d35..e7044325b 100644 --- a/packages/ui/src/components/PropertiesModal/PropertiesModal.scss +++ b/packages/ui/src/components/PropertiesModal/PropertiesModal.scss @@ -41,4 +41,13 @@ height: 60vh; } } + + &__title-image { + height: 50px; + width: 50px; + } + + &__title { + padding: 10px; + } } diff --git a/packages/ui/src/components/PropertiesModal/PropertiesModal.tsx b/packages/ui/src/components/PropertiesModal/PropertiesModal.tsx index cd94adc32..3a08f444a 100644 --- a/packages/ui/src/components/PropertiesModal/PropertiesModal.tsx +++ b/packages/ui/src/components/PropertiesModal/PropertiesModal.tsx @@ -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; @@ -50,6 +51,18 @@ export const PropertiesModal: FunctionComponent = (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 = ( +
+ {`${props.tile.type} +

{props.tile.title}

+
+ ); const description = (
@@ -66,7 +79,7 @@ export const PropertiesModal: FunctionComponent = (props) return (