Skip to content

Commit

Permalink
fix(canvas): Missing Kamelet icons in the from node
Browse files Browse the repository at this point in the history
Currently, when replacing the `from` node with a source `Kamelet` adds it incorrectly as it doesn't prefix the URI with the `kamelet` string.

The fix is to add `kamelet:` prefix to `Kamelets` nodes

Fixes: #409
  • Loading branch information
lordrip committed Nov 23, 2023
1 parent eed869f commit 6209132
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@ export const ItemReplaceNode: FunctionComponent<IDataTestID> = (props) => {
if (!vizNode || !entitiesContext) return;

/** Find compatible components */
const compatibleNodes = entitiesContext.camelResource.getCompatibleComponents(
AddStepMode.ReplaceStep,
vizNode.data,
);
const catalogFilter = entitiesContext.camelResource.getCompatibleComponents(AddStepMode.ReplaceStep, vizNode.data);

/** Open Catalog modal, filtering the compatible nodes */
const definedComponent = await catalogModalContext?.getNewComponent(compatibleNodes);
const definedComponent = await catalogModalContext?.getNewComponent(catalogFilter);
if (!definedComponent) return;

/** Add new node to the entities */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ export class CamelComponentDefaultService {
* Get the default definition for the `from` component
*/
static getDefaultFromDefinitionValue(definedComponent: DefinedComponent): ProcessorDefinition {
let uri = definedComponent.name;
if (definedComponent.type === CatalogKind.Kamelet) {
uri = this.getPrefixedKameletName(definedComponent.name);
}

return parse(`
id: ${getCamelRandomId('from')}
uri: "${definedComponent.name}"
uri: "${uri}"
parameters: {}
`);
}
Expand Down Expand Up @@ -51,7 +56,7 @@ export class CamelComponentDefaultService {
default:
return parse(`
to:
uri: "kamelet:${kameletName}"
uri: "${this.getPrefixedKameletName(kameletName)}"
id: ${getCamelRandomId('to')}
`);
}
Expand Down Expand Up @@ -99,4 +104,8 @@ export class CamelComponentDefaultService {
};
}
}

private static getPrefixedKameletName(kameletName: string): string {
return `kamelet:${kameletName}`;
}
}

0 comments on commit 6209132

Please sign in to comment.