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


The following commit(s) were added to refs/heads/main by this push:
     new 2fe51138 Workaround for CAMEL-21004
2fe51138 is described below

commit 2fe51138a347be79fdc85c2562a442a60c474777
Author: Marat Gubaidullin <ma...@talismancloud.io>
AuthorDate: Mon Jul 22 11:10:53 2024 -0400

    Workaround for CAMEL-21004
---
 karavan-vscode/src/exec.ts                         |  5 ++--
 karavan-vscode/src/jbang.ts                        |  4 ++--
 karavan-vscode/webview/topology/CustomNode.tsx     | 22 ++++++++++++++---
 karavan-vscode/webview/topology/TopologyApi.tsx    | 28 ++++++++++++++++++----
 .../webview/topology/TopologyPropertiesPanel.tsx   |  3 ++-
 karavan-vscode/webview/topology/TopologyStore.ts   |  2 +-
 karavan-vscode/webview/topology/topology.css       | 10 ++++++++
 7 files changed, 60 insertions(+), 14 deletions(-)

diff --git a/karavan-vscode/src/exec.ts b/karavan-vscode/src/exec.ts
index a012ef33..29d2c062 100644
--- a/karavan-vscode/src/exec.ts
+++ b/karavan-vscode/src/exec.ts
@@ -45,7 +45,8 @@ export function execTerminalCommand(terminalId: string, 
command: string, env?: {
 }
 
 export async function runWithRuntime(fullPath: string, run?: boolean) {
-    let command = jbang.createExportCommand(fullPath);
+    const runtime = await utils.getRuntime();
+    let command = jbang.createExportCommand(fullPath, runtime);
     if (run) {
         const runtime = await utils.getRuntime();
         const mvn = runtime === 'quarkus' ? "quarkus:dev" : (runtime === 
'spring-boot' ? "spring-boot:run" : "camel:run");
@@ -71,7 +72,7 @@ export function camelDeploy(directory: string) {
             window.showErrorMessage("Namespace not set \n" + val[3].error);
         }
         const deployCommand: string = 
workspace.getConfiguration().get("Karavan.".concat(runtime.replaceAll("-", 
"")).concat(utils.capitalize(target)).concat("Deploy")) || '';
-        const command = jbang.createExportCommand(directory).concat(" && 
").concat(deployCommand).concat(" -f ").concat(exportFolder);
+        const command = jbang.createExportCommand(directory, runtime).concat(" 
&& ").concat(deployCommand).concat(" -f ").concat(exportFolder);
         execTerminalCommand("deploy", command, env);
     }).catch((reason: any) => {
         window.showErrorMessage("Error: \n" + reason.message);
diff --git a/karavan-vscode/src/jbang.ts b/karavan-vscode/src/jbang.ts
index 5649aeee..b33df038 100644
--- a/karavan-vscode/src/jbang.ts
+++ b/karavan-vscode/src/jbang.ts
@@ -60,12 +60,12 @@ export function camelJbangRun() {
     exec.execTerminalCommand("jbang-run", command);
 }
 
-export function createExportCommand(fullPath: string) {
+export function createExportCommand(fullPath: string, runtime: string) {
     const kameletsPath: string | undefined = 
workspace.getConfiguration().get("Karavan.kameletsPath");
     const cmd = "export --fresh " 
         + (fullPath ? " --directory=" + fullPath : '')
         + (kameletsPath && kameletsPath.trim().length > 0 ? " 
--local-kamelet-dir=" + kameletsPath : "")
-        + " --runtime=" + utils.getRuntime(); // workaround for 
https://issues.apache.org/jira/browse/CAMEL-21004
+        + " --runtime=" + runtime; // workaround for 
https://issues.apache.org/jira/browse/CAMEL-21004
     return prepareCommand(cmd);
 }
 
diff --git a/karavan-vscode/webview/topology/CustomNode.tsx 
b/karavan-vscode/webview/topology/CustomNode.tsx
index 83792a0c..e0a022d0 100644
--- a/karavan-vscode/webview/topology/CustomNode.tsx
+++ b/karavan-vscode/webview/topology/CustomNode.tsx
@@ -40,12 +40,27 @@ function getIcon(data: any) {
     return <RegionsIcon/>;
 }
 
-const CustomNode: React.FC<any> = observer(({ element, ...rest }) => {
+function getAttachments(data: any) {
+    if (data?.step?.dslName === 'RouteDefinition' && data?.step?.autoStartup 
!== false) {
+        const x = 0;
+        const y = 0;
+        const rx = x + 9;
+        const ry = y + 9;
+        return (
+            <g className="pf-topology__node__label__badge auto-start" 
transform="translate(-4, -4)">
+                <rect className="badge" x={x} width="22" y={y} height="17" 
rx={rx} ry={ry}></rect>
+                <text className='text' x={rx + 2} y={ry} textAnchor="middle" 
dy="0.35em">A</text>
+            </g>
+        )
+    } else <></>
+}
+
+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) + '...');
+        element.setLabel(element.getLabel()?.substring(0, 30) + '...');
     }
 
     return (
@@ -55,6 +70,7 @@ const CustomNode: React.FC<any> = observer(({ element, 
...rest }) => {
             className="common-node"
             scaleLabel={false}
             element={element}
+            attachments={getAttachments(data)}
             {...rest}
         >
             {getIcon(data)}
diff --git a/karavan-vscode/webview/topology/TopologyApi.tsx 
b/karavan-vscode/webview/topology/TopologyApi.tsx
index bb09ce8f..a6385542 100644
--- a/karavan-vscode/webview/topology/TopologyApi.tsx
+++ b/karavan-vscode/webview/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,
@@ -233,11 +234,13 @@ export function getRestEdges(rest: TopologyRestNode[], 
tins: TopologyIncomingNod
 export function getInternalEdges(tons: TopologyOutgoingNode[], tins: 
TopologyIncomingNode[]): EdgeModel[] {
     const result: EdgeModel[] = [];
     tons.filter(ton => ton.type === 'internal').forEach((ton, index) => {
-        const uri: string = (ton.step as any).uri;
-        if (uri.startsWith("direct") || uri.startsWith("seda")) {
-            const name = (ton.step as any).parameters.name;
+        const step = (ton.step as any);
+        if (step?.dslName === 'DeadLetterChannelDefinition') {
+            const parts = step.deadLetterUri?.split(":");
+            const uri: string = parts[0];
+            const name: string = parts[1];
             const target = TopologyUtils.getRouteIdByUriAndName(tins, uri, 
name);
-                const node: EdgeModel = {
+            const node: EdgeModel = {
                 id: 'internal-' + ton.id + '-' + index,
                 type: 'edge',
                 source: 'route-' + ton.routeId,
@@ -246,6 +249,21 @@ export function getInternalEdges(tons: 
TopologyOutgoingNode[], tins: TopologyInc
                 animationSpeed: EdgeAnimationSpeed.medium
             }
             if (target) result.push(node);
+        } else {
+            const uri: string = (ton.step as any).uri;
+            if (uri?.startsWith("direct") || uri?.startsWith("seda")) {
+                const name = (ton.step as any).parameters.name;
+                const target = TopologyUtils.getRouteIdByUriAndName(tins, uri, 
name);
+                const node: EdgeModel = {
+                    id: 'internal-' + ton.id + '-' + index,
+                    type: 'edge',
+                    source: 'route-' + ton.routeId,
+                    target: target,
+                    edgeStyle: EdgeStyle.solid,
+                    animationSpeed: EdgeAnimationSpeed.medium
+                }
+                if (target) result.push(node);
+            }
         }
     });
     return result;
@@ -307,7 +325,7 @@ export function getModel(files: IntegrationFile[], 
grouping?: boolean): Model {
     edges.push(...getRestEdges(trestns, tins));
     edges.push(...getInternalEdges(tons, tins));
     edges.push(...getInternalEdges(trcons, tins));
-    edges.push(...getExternalEdges(tons,tins));
+    // edges.push(...getExternalEdges(tons,tins));
 
     return {nodes: nodes, edges: edges, graph: {id: 'g1', type: 'graph', 
layout: 'Dagre'}};
 }
diff --git a/karavan-vscode/webview/topology/TopologyPropertiesPanel.tsx 
b/karavan-vscode/webview/topology/TopologyPropertiesPanel.tsx
index a32d6969..0fd93b3d 100644
--- a/karavan-vscode/webview/topology/TopologyPropertiesPanel.tsx
+++ b/karavan-vscode/webview/topology/TopologyPropertiesPanel.tsx
@@ -30,6 +30,7 @@ import {
     TooltipPosition
 } from "@patternfly/react-core";
 import CloseIcon from "@patternfly/react-icons/dist/esm/icons/times-icon";
+import {NAV_COMPONENTS} from "../designer/utils/CamelUi";
 
 interface Props {
     onSetFile: (fileName: string) => void
@@ -68,7 +69,7 @@ export function TopologyPropertiesPanel(props: Props) {
         if (isRoute()) {
             const uri: string = nodeData?.step?.from.uri || '';
             const name: string = nodeData?.step?.from.parameters?.name || '';
-            if (['direct','seda'].includes(uri)) {
+            if (NAV_COMPONENTS.includes(uri)) {
                 return uri.concat(":").concat(name);
             } else {
                 return uri;
diff --git a/karavan-vscode/webview/topology/TopologyStore.ts 
b/karavan-vscode/webview/topology/TopologyStore.ts
index 63b7ed4f..0ba80503 100644
--- a/karavan-vscode/webview/topology/TopologyStore.ts
+++ b/karavan-vscode/webview/topology/TopologyStore.ts
@@ -56,7 +56,7 @@ export const useTopologyStore = 
createWithEqualityFn<TopologyState>((set) => ({
             return {nodeData: nodeData};
         });
     },
-    showGroups: false,
+    showGroups: true,
     setShowGroups: (showGroups: boolean) => {
         set((state: TopologyState) => {
             return {showGroups: showGroups};
diff --git a/karavan-vscode/webview/topology/topology.css 
b/karavan-vscode/webview/topology/topology.css
index 0521a9a9..1828bd1e 100644
--- a/karavan-vscode/webview/topology/topology.css
+++ b/karavan-vscode/webview/topology/topology.css
@@ -105,4 +105,14 @@
 
 .karavan .topology-panel .pf-topology__group 
.pf-topology__node__label__background {
     opacity: 0.5;
+}
+
+.karavan .topology-panel .auto-start .badge {
+    fill: var(--pf-topology__node__label__background--Fill);
+    stroke-width: var(--pf-topology__node__label__background--StrokeWidth);
+    stroke: var(--pf-topology__node__label__background--Stroke);
+}
+
+.karavan .topology-panel .auto-start .text {
+    fill: var(--pf-topology__node__label__text--Fill);
 }
\ No newline at end of file

Reply via email to