Skip to content

Commit

Permalink
Merge branch 'main' into e2e_catalog_versions
Browse files Browse the repository at this point in the history
  • Loading branch information
tplevko authored Jan 13, 2025
2 parents 82f5221 + 6da8b04 commit 038665e
Show file tree
Hide file tree
Showing 36 changed files with 902 additions and 380 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kaoto",
"version": "2.4.0-dev",
"version": "2.5.0-dev",
"description": "Kaoto - The Integration Designer for Apache Camel",
"repository": "https://github.com/KaotoIO/kaoto",
"author": "The Kaoto Team",
Expand All @@ -10,12 +10,12 @@
],
"resolutions": {
"@patternfly/patternfly": "5.4.2",
"@patternfly/react-code-editor": "5.4.11",
"@patternfly/react-core": "5.4.8",
"@patternfly/react-code-editor": "5.4.15",
"@patternfly/react-core": "5.4.12",
"@patternfly/react-icons": "5.4.2",
"@patternfly/react-table": "5.4.9",
"@patternfly/react-table": "5.4.13",
"@patternfly/react-topology": "5.4.1",
"axios": "1.7.7",
"axios": "1.7.9",
"react": "18.3.1",
"react-dom": "18.3.1",
"prettier": "3.3.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/catalog-generator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kaoto/camel-catalog",
"version": "2.4.0-dev",
"version": "2.5.0-dev",
"type": "commonjs",
"description": "Camel Catalog and schemas for Kaoto",
"repository": "https://github.com/KaotoIO/kaoto",
Expand Down
2 changes: 1 addition & 1 deletion packages/catalog-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<version.camel.quarkus>3.15.0</version.camel.quarkus>
<version.camel-kamelets>4.8.0</version.camel-kamelets>
<version.jackson>2.17.2</version.jackson>
<version.junit>5.11.3</version.junit>
<version.junit>5.11.4</version.junit>
<version.kubernetes-model>6.13.4</version.kubernetes-model>
<version.maven-enforcer-plugin>3.5.0</version.maven-enforcer-plugin>
<version.maven-compiler-plugin>3.13.0</version.maven-compiler-plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public String getDataFormatCatalog() throws Exception {
eipModelOptions = eipModel.getOptions();
}

sortPropertiesAccordingToCamelCatalog(dataFormatSchema, eipModelOptions);
sortPropertiesAccordingToCamelCatalog(dataFormatSchema, eipModelOptions);

var dataFormatCatalog = (EipModel) camelCatalog.model(Kind.eip, dataFormatName);
if (dataFormatCatalog == null) {
Expand Down Expand Up @@ -260,7 +260,7 @@ public String getLanguageCatalog() throws Exception {
eipModelOptions = eipModel.getOptions();
}

sortPropertiesAccordingToCamelCatalog(languageSchema, eipModelOptions);
sortPropertiesAccordingToCamelCatalog(languageSchema, eipModelOptions);

var languageCatalog = (EipModel) camelCatalog.model(Kind.eip, languageName);
if (languageCatalog == null) {
Expand Down Expand Up @@ -362,12 +362,17 @@ public String getPatternCatalog() throws Exception {
continue;
}

sortedSchemaProperties.set(propertyName, propertySchema);

var catalogOpOptional = eipModel.getOptions().stream()
.filter(op -> op.getName().equals(propertyName)).findFirst();

if (catalogOpOptional.isEmpty()) {
throw new Exception(
LOGGER.warning(
String.format("Option '%s' not found for processor '%s'", propertyName, processorFQCN));
continue;
}

var catalogOp = catalogOpOptional.get();
if ("object".equals(catalogOp.getType()) && !catalogOp.getJavaType().startsWith("java.util.Map")
&& !propertySchema.has("$comment")) {
Expand All @@ -383,8 +388,6 @@ public String getPatternCatalog() throws Exception {
} else if (catalogOp.getGroup() != null) {
propertySchema.put("group", catalogOp.getGroup());
}

sortedSchemaProperties.set(propertyName, propertySchema);
}

var json = JsonMapper.asJsonObject(eipModel).toJson();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class CamelYamlDslSchemaProcessor {
private static final String PROCESSOR_DEFINITION = "org.apache.camel.model.ProcessorDefinition";
private static final String TOKENIZER_DEFINITION = "org.apache.camel.model.TokenizerDefinition";
private static final String ROUTE_CONFIGURATION_DEFINITION = "org.apache.camel.model.RouteConfigurationDefinition";
private static final String REST_DEFINITION = "org.apache.camel.model.rest.RestDefinition";
private static final String LOAD_BALANCE_DEFINITION = "org.apache.camel.model.LoadBalanceDefinition";
private static final String EXPRESSION_SUB_ELEMENT_DEFINITION =
"org.apache.camel.model.ExpressionSubElementDefinition";
Expand All @@ -58,7 +59,20 @@ public class CamelYamlDslSchemaProcessor {
"org.apache.camel.model.ToDefinition",
List.of("uri", "parameters"),
"org.apache.camel.model.WireTapDefinition",
List.of("uri", "parameters"));
List.of("uri", "parameters"),
"org.apache.camel.model.rest.GetDefinition",
List.of("to"),
"org.apache.camel.model.rest.PostDefinition",
List.of("to"),
"org.apache.camel.model.rest.PutDefinition",
List.of("to"),
"org.apache.camel.model.rest.DeleteDefinition",
List.of("to"),
"org.apache.camel.model.rest.HeadDefinition",
List.of("to"),
"org.apache.camel.model.rest.PatchDefinition",
List.of("to"));

private final List<String> processorReferenceBlockList = List.of(PROCESSOR_DEFINITION);

public CamelYamlDslSchemaProcessor(ObjectMapper mapper, ObjectNode yamlDslSchema) throws Exception {
Expand Down Expand Up @@ -269,6 +283,7 @@ public Map<String, ObjectNode> getProcessors() throws Exception {
.withObject(PROCESSOR_DEFINITION)
.withObject("/properties");
addRouteConfigurationProcessors(relocatedDefinitions, processors);
addRestProcessors(relocatedDefinitions, processors);

var answer = new LinkedHashMap<String, ObjectNode>();
for (var processorEntry : processors) {
Expand Down Expand Up @@ -354,6 +369,24 @@ private void addRouteConfigurationProcessors(ObjectNode relocatedDefinitions, Ob
processors.setAll(onCompletionProcessor);
}

private void addRestProcessors(ObjectNode relocatedDefinitions, ObjectNode processors) {
var restProcessor = relocatedDefinitions
.withObject(REST_DEFINITION)
.withObject("/properties");
var restGetProcessor = restProcessor.withObject("get").withObject("items");
var restPostProcessor = restProcessor.withObject("post").withObject("items");
var restPutProcessor = restProcessor.withObject("put").withObject("items");
var restDeleteProcessor = restProcessor.withObject("delete").withObject("items");
var restHeadProcessor = restProcessor.withObject("head").withObject("items");
var restPatchProcessor = restProcessor.withObject("patch").withObject("items");
processors.set("get", restGetProcessor);
processors.set("post", restPostProcessor);
processors.set("put", restPutProcessor);
processors.set("delete", restDeleteProcessor);
processors.set("head", restHeadProcessor);
processors.set("patch", restPatchProcessor);
}

private ObjectNode extractFromOneOf(String name, ObjectNode definition) throws Exception {
if (!definition.has("oneOf")) {
return definition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,35 @@ void testGetDataFormatCatalog() throws Exception {
assertEquals(1, customPropertiesSchemaRequiredFields.size(), "Size should be 1");
}

@Test
void testRestProcessors() throws Exception {
var restGetProcessorSchema = processorCatalog
.withObject("/get")
.withObject("propertiesSchema");
var restPostProcessorSchema = processorCatalog
.withObject("/post")
.withObject("propertiesSchema");
var restPutProcessorSchema = processorCatalog
.withObject("/put")
.withObject("propertiesSchema");
var restDeleteProcessorSchema = processorCatalog
.withObject("/delete")
.withObject("propertiesSchema");
var restHeadProcessorSchema = processorCatalog
.withObject("/head")
.withObject("propertiesSchema");
var restPatchProcessorSchema = processorCatalog
.withObject("/patch")
.withObject("propertiesSchema");

assertFalse(restGetProcessorSchema.isEmpty(), "get processor schema should not be empty");
assertFalse(restPostProcessorSchema.isEmpty(), "post processor schema should not be empty");
assertFalse(restPutProcessorSchema.isEmpty(), "put processor schema should not be empty");
assertFalse(restDeleteProcessorSchema.isEmpty(), "delete processor schema should not be empty");
assertFalse(restHeadProcessorSchema.isEmpty(), "head processor schema should not be empty");
assertFalse(restPatchProcessorSchema.isEmpty(), "patch processor schema should not be empty");
}

@Test
void testDataFormatEnumParameter() throws Exception {
checkEnumParameters(dataFormatCatalog);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ describe('Test source code editor', () => {
it('loads the YAML editor and deletes steps, check with visualization', () => {
cy.uploadFixture('flows/kameletBinding/kafkaSourceSink.yaml');
cy.openDesignPage();
cy.get('[data-id^="json-deserialize-action"]').should('exist');
cy.get('[data-id^="Updated integration|steps.0"]').should('exist');
cy.openSourceCode();
cy.editorDeleteLine(19, 5);

// CHECK that the code editor contains the new timer source step
cy.openDesignPage();
cy.checkNodeExist('json-deserialize-action', 0);
cy.checkNodeExist('Updated integration|steps.0', 0);
});

it('User adds step to the YAML', () => {
Expand All @@ -36,7 +36,7 @@ describe('Test source code editor', () => {
cy.editorDeleteLine(12, 6);
cy.openDesignPage();
// CHECK the kafka-sink step was removed
cy.checkNodeExist('kafka-sink', 0);
cy.checkNodeExist('integration|kafka-sink', 0);
});

it('User edits step in the YAML', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe('Test for Branching actions from the canvas', () => {

cy.checkNodeExist('activemq', 1);
cy.checkEdgeExists(
'eip-action',
'template.from.steps.1.choice.when.0.steps.1.setHeader',
'template.from.steps.1.choice.when.0.steps.2.to',
);
Expand All @@ -77,6 +78,7 @@ describe('Test for Branching actions from the canvas', () => {

cy.checkNodeExist('activemq', 1);
cy.checkEdgeExists(
'eip-action',
'template.from.steps.1.choice.when.0.steps.0.to',
'template.from.steps.1.choice.when.0.steps.1.to',
);
Expand All @@ -91,6 +93,6 @@ describe('Test for Branching actions from the canvas', () => {
cy.chooseFromCatalog('component', 'activemq');

cy.checkNodeExist('activemq', 1);
cy.checkEdgeExists('template.from.steps.2.to', 'template.from.steps.3.filter');
cy.checkEdgeExists('eip-action', 'template.from.steps.2.to', 'template.from.steps.3.filter');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Test for missing config props canvas warnings', () => {
cy.uploadFixture('flows/pipe/errorHandler.yaml');
cy.openDesignPage();

cy.get('[data-id^="webhook-binding|delay-action"] g')
cy.get('[data-id^="webhook-binding"] g[data-nodelabel="delay-action"]')
.find('span[data-warning="true"].pf-v5-c-icon')
.should('have.attr', 'title', '1 required parameter is not yet configured: [ milliseconds ]');

Expand All @@ -39,7 +39,7 @@ describe('Test for missing config props canvas warnings', () => {
cy.interactWithConfigInputObject('milliseconds', '1000');
cy.closeStepConfigurationTab();

cy.get('[data-id^="webhook-binding|delay-action"] g')
cy.get('[data-id^="webhook-binding"] g[data-nodelabel="delay-action"]')
.find('span[data-warning="true"].pf-v5-c-icon')
.should('not.exist');
});
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-tests/cypress/support/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ declare global {
selectRemoveGroup(groupName: string, nodeIndex?: number): Chainable<JQuery<Element>>;
performNodeAction(nodeName: string, action: ActionType, nodeIndex?: number): Chainable<JQuery<Element>>;
checkNodeExist(inputName: string, nodesCount: number): Chainable<JQuery<Element>>;
checkEdgeExists(sourceName: string, targetName: string): Chainable<JQuery<Element>>;
checkEdgeExists(scope: string, sourceName: string, targetName: string): Chainable<JQuery<Element>>;
deleteBranch(branchIndex: number): Chainable<JQuery<Element>>;
selectCamelRouteType(type: string, subType?: string): Chainable<JQuery<Element>>;
selectRuntimeVersion(type: string): Chainable<JQuery<Element>>;
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-tests/cypress/support/next-commands/design.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ Cypress.Commands.add('checkNodeExist', (inputName, nodesCount) => {
cy.get(`foreignObject[data-nodelabel="${inputName}"]`).should('have.length', nodesCount);
});

Cypress.Commands.add('checkEdgeExists', (sourceName: string, targetName: string) => {
const idPattern = `${sourceName} >>> ${targetName}`;
Cypress.Commands.add('checkEdgeExists', (scope: string, sourceName: string, targetName: string) => {
const idPattern = `${scope}|${sourceName} >>> ${targetName}`;
// Check if an element with the matching id exists
cy.get('g').should(($elements) => {
// Use Cypress commands to check if any element matches the id pattern
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@kaoto/kaoto-tests",
"private": true,
"version": "2.4.0-dev",
"version": "2.5.0-dev",
"type": "module",
"description": "Kaoto UI tests and storybook",
"repository": "https://github.com/KaotoIO/kaoto",
Expand Down
9 changes: 9 additions & 0 deletions packages/ui-tests/stories/settings/SettingsForm.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { SettingsForm } from '@kaoto/kaoto';
import { SettingsProvider, ReloadContext, DefaultSettingsAdapter } from '@kaoto/kaoto/testing';
import { Meta, StoryFn } from '@storybook/react';
import { reactRouterOutlet, reactRouterParameters, withRouter } from 'storybook-addon-remix-react-router';

export default {
title: 'Settings/SettingsForm',
decorators: [withRouter],
parameters: {
reactRouter: reactRouterParameters({
routing: reactRouterOutlet({
path: '*',
}),
}),
},
component: SettingsForm,
} as Meta<typeof SettingsForm>;

Expand Down
8 changes: 4 additions & 4 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kaoto/kaoto",
"version": "2.4.0-dev",
"version": "2.5.0-dev",
"type": "module",
"description": "Kaoto UI",
"repository": "https://github.com/KaotoIO/kaoto",
Expand Down Expand Up @@ -96,10 +96,10 @@
"@eslint/js": "^9.10.0",
"@kaoto/camel-catalog": "workspace:*",
"@patternfly/patternfly": "5.4.2",
"@patternfly/react-code-editor": "5.4.11",
"@patternfly/react-core": "5.4.8",
"@patternfly/react-code-editor": "5.4.15",
"@patternfly/react-core": "5.4.12",
"@patternfly/react-icons": "5.4.2",
"@patternfly/react-table": "5.4.9",
"@patternfly/react-table": "5.4.13",
"@patternfly/react-topology": "5.4.1",
"@swc/core": "^1.7.14",
"@swc/jest": "^0.2.36",
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/assets/settingsSchema.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"additionalProperties": false,
"description": "JSON Schema for Kaoto configuration",
Expand All @@ -20,7 +20,7 @@
},
"nodeToolbarTrigger": {
"title": "Open Node toolbar",
"description": "Choose when to open the Node toolbar. Can be either `onHover` or `onSelection`. If `onHover` is selected, the toolbar will be automatically open upon hoevring a node, otherwise, it will be open when selecting a node",
"description": "Choose when to open the Node toolbar. Can be either `onHover` or `onSelection`. If `onHover` is selected, the toolbar will be automatically open upon hovering a node, otherwise, it will be open when selecting a node",
"default": "onHover",
"type": "string",
"enum": ["onHover", "onSelection"]
Expand Down
Loading

0 comments on commit 038665e

Please sign in to comment.