This is an automated email from the ASF dual-hosted git repository.

marat pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karavan.git

commit 6af0255d873f9835b20f85e9690fe460989f8cb1
Author: Marat Gubaidullin <ma...@talismancloud.io>
AuthorDate: Mon Jun 17 09:52:47 2024 -0400

    Topology REST badge
---
 karavan-app/src/main/webui/src/topology/CustomNode.tsx  |  2 +-
 karavan-app/src/main/webui/src/topology/TopologyApi.tsx |  1 +
 karavan-core/src/core/api/TopologyUtils.ts              |  2 +-
 karavan-designer/public/example/demo.camel.yaml         | 13 +++++++++++++
 karavan-designer/src/App.tsx                            |  2 +-
 karavan-designer/src/topology/CustomNode.tsx            |  2 +-
 karavan-designer/src/topology/TopologyApi.tsx           |  1 +
 karavan-space/src/topology/CustomNode.tsx               |  2 +-
 karavan-space/src/topology/TopologyApi.tsx              |  1 +
 9 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/karavan-app/src/main/webui/src/topology/CustomNode.tsx 
b/karavan-app/src/main/webui/src/topology/CustomNode.tsx
index 83792a0c..44f6e068 100644
--- a/karavan-app/src/main/webui/src/topology/CustomNode.tsx
+++ b/karavan-app/src/main/webui/src/topology/CustomNode.tsx
@@ -43,7 +43,7 @@ function getIcon(data: any) {
 const CustomNode: React.FC<any> = observer(({ element, ...rest }) => {
 
     const data = element.getData();
-    const badge:string = data.badge?.substring(0,1).toUpperCase();
+    const badge:string = data.badge === 'REST' ? data.badge : 
data.badge?.substring(0,1).toUpperCase();
     if (element.getLabel()?.length > 30) {
         element.setLabel(element.getLabel()?.substring(0,30) + '...');
     }
diff --git a/karavan-app/src/main/webui/src/topology/TopologyApi.tsx 
b/karavan-app/src/main/webui/src/topology/TopologyApi.tsx
index 8cca27c9..26d5c40c 100644
--- a/karavan-app/src/main/webui/src/topology/TopologyApi.tsx
+++ b/karavan-app/src/main/webui/src/topology/TopologyApi.tsx
@@ -201,6 +201,7 @@ export function getRestNodes(tins: TopologyRestNode[]): 
NodeModel[] {
             status: NodeStatus.default,
             data: {
                 isAlternate: false,
+                badge: 'REST',
                 icon: 'rest',
                 type: 'rest',
                 step: tin.rest,
diff --git a/karavan-core/src/core/api/TopologyUtils.ts 
b/karavan-core/src/core/api/TopologyUtils.ts
index a3bd8a3d..39045fc1 100644
--- a/karavan-core/src/core/api/TopologyUtils.ts
+++ b/karavan-core/src/core/api/TopologyUtils.ts
@@ -171,7 +171,7 @@ export class TopologyUtils {
                 rest?.head?.forEach((d: HeadDefinition) => {
                     if (d.to) uris.push(d.to);
                 });
-                const title = 'REST: ' + (rest.description ? rest.description 
: rest.id);
+                const title = '' + (rest.description ? rest.description : 
rest.id);
                 result.push(new TopologyRestNode(rest.path || '', '' + 
rest.id, uris, title, filename, rest))
             })
         })
diff --git a/karavan-designer/public/example/demo.camel.yaml 
b/karavan-designer/public/example/demo.camel.yaml
index 873e4e37..5d0138d7 100644
--- a/karavan-designer/public/example/demo.camel.yaml
+++ b/karavan-designer/public/example/demo.camel.yaml
@@ -21,3 +21,16 @@
         - to:
             id: to-1600
             uri: kamelet:kafka-sink
+- rest:
+    id: rest-d262
+    description: Hello
+    get:
+      - id: get-7de4
+        to: direct:test
+- route:
+    id: test
+    from:
+      id: from-aeed
+      uri: direct
+      parameters:
+        name: test
diff --git a/karavan-designer/src/App.tsx b/karavan-designer/src/App.tsx
index bc6d9f7b..b7344e30 100644
--- a/karavan-designer/src/App.tsx
+++ b/karavan-designer/src/App.tsx
@@ -58,7 +58,7 @@ class MenuItem {
 
 export function App() {
 
-    const [pageId, setPageId] = useState<string>('designer');
+    const [pageId, setPageId] = useState<string>('topology');
     const [name, setName] = useState<string>('example.yaml');
     const [key, setKey] = useState<string>('');
     const [yaml, setYaml] = useState<string>('');
diff --git a/karavan-designer/src/topology/CustomNode.tsx 
b/karavan-designer/src/topology/CustomNode.tsx
index 83792a0c..44f6e068 100644
--- a/karavan-designer/src/topology/CustomNode.tsx
+++ b/karavan-designer/src/topology/CustomNode.tsx
@@ -43,7 +43,7 @@ function getIcon(data: any) {
 const CustomNode: React.FC<any> = observer(({ element, ...rest }) => {
 
     const data = element.getData();
-    const badge:string = data.badge?.substring(0,1).toUpperCase();
+    const badge:string = data.badge === 'REST' ? data.badge : 
data.badge?.substring(0,1).toUpperCase();
     if (element.getLabel()?.length > 30) {
         element.setLabel(element.getLabel()?.substring(0,30) + '...');
     }
diff --git a/karavan-designer/src/topology/TopologyApi.tsx 
b/karavan-designer/src/topology/TopologyApi.tsx
index 8cca27c9..26d5c40c 100644
--- a/karavan-designer/src/topology/TopologyApi.tsx
+++ b/karavan-designer/src/topology/TopologyApi.tsx
@@ -201,6 +201,7 @@ export function getRestNodes(tins: TopologyRestNode[]): 
NodeModel[] {
             status: NodeStatus.default,
             data: {
                 isAlternate: false,
+                badge: 'REST',
                 icon: 'rest',
                 type: 'rest',
                 step: tin.rest,
diff --git a/karavan-space/src/topology/CustomNode.tsx 
b/karavan-space/src/topology/CustomNode.tsx
index 83792a0c..44f6e068 100644
--- a/karavan-space/src/topology/CustomNode.tsx
+++ b/karavan-space/src/topology/CustomNode.tsx
@@ -43,7 +43,7 @@ function getIcon(data: any) {
 const CustomNode: React.FC<any> = observer(({ element, ...rest }) => {
 
     const data = element.getData();
-    const badge:string = data.badge?.substring(0,1).toUpperCase();
+    const badge:string = data.badge === 'REST' ? data.badge : 
data.badge?.substring(0,1).toUpperCase();
     if (element.getLabel()?.length > 30) {
         element.setLabel(element.getLabel()?.substring(0,30) + '...');
     }
diff --git a/karavan-space/src/topology/TopologyApi.tsx 
b/karavan-space/src/topology/TopologyApi.tsx
index 8cca27c9..26d5c40c 100644
--- a/karavan-space/src/topology/TopologyApi.tsx
+++ b/karavan-space/src/topology/TopologyApi.tsx
@@ -201,6 +201,7 @@ export function getRestNodes(tins: TopologyRestNode[]): 
NodeModel[] {
             status: NodeStatus.default,
             data: {
                 isAlternate: false,
+                badge: 'REST',
                 icon: 'rest',
                 type: 'rest',
                 step: tin.rest,

Reply via email to