Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
chore: Add id and integrationId properties
Browse files Browse the repository at this point in the history
Within the scope of supporting multiple routes, a way to identify
them is required and for that matter this commit adds:

* 'id' property to the IIntegration interface
* 'integrationId' property to the IStepProps interface

It also updates all related stubs, mocks and test to
support the newly added properties.

relates: [801](#801)
  • Loading branch information
lordrip committed May 4, 2023
1 parent 0de80e7 commit 56bf6ea
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/components/Visualization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const Visualization = () => {
name: '',
type: '',
UUID: '',
integrationId: '',
});
const visualizationStore = useVisualizationStore.getState();
const layout = useVisualizationStore((state) => state.layout);
Expand Down Expand Up @@ -61,7 +62,7 @@ const Visualization = () => {
if (step) {
setSelectedStep(step);
} else {
setSelectedStep({ maxBranches: 0, minBranches: 0, name: '', type: '', UUID: '' });
setSelectedStep({ maxBranches: 0, minBranches: 0, name: '', type: '', UUID: '', integrationId: '' });
visualizationStore.setSelectedStepUuid('');
setIsPanelExpanded(false);
}
Expand All @@ -83,7 +84,7 @@ const Visualization = () => {
const handleDeleteStep = (UUID?: string) => {
if (!UUID) return;

setSelectedStep({ maxBranches: 0, minBranches: 0, name: '', type: '', UUID: '' });
setSelectedStep({ maxBranches: 0, minBranches: 0, name: '', type: '', UUID: '', integrationId: '' });
visualizationStore.setSelectedStepUuid('');
if (isPanelExpanded) setIsPanelExpanded(false);

Expand Down
1 change: 1 addition & 0 deletions src/components/VisualizationStep.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default {
isPlaceholder: false,
step: {
id: 'servlet',
integrationId: 'Camel Route-1',
name: 'servlet',
type: 'START',
description:
Expand Down
1 change: 1 addition & 0 deletions src/components/VisualizationStepViews.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default {
isPanelExpanded: true,
step: {
id: 'servlet',
integrationId: 'Camel Route-1',
name: 'servlet',
type: 'START',
description:
Expand Down
10 changes: 10 additions & 0 deletions src/services/stepsService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ describe('stepsService', () => {

it('getIntegrationSource(): should call apiService to return the source code (YAML) for the current running deployment', async () => {
const integration = {
id: '',
metadata: { name: 'Updated integration' },
dsl: 'KameletBinding',
params: [],
Expand Down Expand Up @@ -529,6 +530,7 @@ describe('stepsService', () => {
steps: [
{
UUID: 'choice-1|branch-0|log-0',
integrationId: 'Camel Route-1',
minBranches: 0,
maxBranches: 0,
name: 'log',
Expand All @@ -542,6 +544,7 @@ describe('stepsService', () => {
steps: [
{
UUID: 'choice-1|branch-1|log-0',
integrationId: 'Camel Route-1',
minBranches: 0,
maxBranches: 0,
name: 'log',
Expand Down Expand Up @@ -571,6 +574,7 @@ describe('stepsService', () => {
steps: [
{
UUID: 'choice-1|branch-0|timer-0',
integrationId: 'Camel Route-1',
minBranches: 0,
maxBranches: 0,
name: 'timer',
Expand All @@ -579,6 +583,7 @@ describe('stepsService', () => {
},
{
UUID: 'choice-1|branch-0|choice-1',
integrationId: 'Camel Route-1',
minBranches: 1,
maxBranches: -1,
name: 'choice',
Expand All @@ -589,6 +594,7 @@ describe('stepsService', () => {
steps: [
{
UUID: 'choice-1|branch-0|choice-1|branch-0|log-0',
integrationId: 'Camel Route-1',
minBranches: 0,
maxBranches: 0,
name: 'log',
Expand All @@ -602,6 +608,7 @@ describe('stepsService', () => {
steps: [
{
UUID: 'choice-1|branch-0|choice-1|branch-1|log-0',
integrationId: 'Camel Route-1',
minBranches: 0,
maxBranches: 0,
name: 'log',
Expand All @@ -620,6 +627,7 @@ describe('stepsService', () => {
steps: [
{
UUID: 'choice-1|branch-1|log-0',
integrationId: 'Camel Route-1',
minBranches: 0,
maxBranches: 0,
name: 'log',
Expand All @@ -646,6 +654,7 @@ describe('stepsService', () => {
steps: [
{
UUID: 'choice-0|branch-0|log-0',
integrationId: 'Camel Route-1',
minBranches: 0,
maxBranches: 0,
name: 'log',
Expand All @@ -659,6 +668,7 @@ describe('stepsService', () => {
steps: [
{
UUID: 'choice-0|branch-1|log-0',
integrationId: 'Camel Route-1',
minBranches: 0,
maxBranches: 0,
name: 'log',
Expand Down
8 changes: 4 additions & 4 deletions src/services/visualizationService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { MarkerType, Position } from 'reactflow';

describe('visualizationService', () => {
const groupWidth = 80;
const baseStep = { UUID: '', name: '', maxBranches: 0, minBranches: 0, type: '' };
const baseStep = { UUID: '', name: '', maxBranches: 0, minBranches: 0, type: '', integrationId: 'Camel Route-1' };

it('buildBranchNodeParams(): should build params for a branch node', () => {
const currentStep = steps[3];
Expand Down Expand Up @@ -208,18 +208,18 @@ describe('visualizationService', () => {
});

it('buildEdges(): should build an edge for every node except the first, given an array of nodes', () => {
const nodes = [
const nodes: IVizStepNode[] = [
{
data: {
label: 'aws-kinesis-source',
step: { ...baseStep, UUID: 'example-1234' },
step: { ...baseStep, UUID: 'example-1234', integrationId: 'Camel Route-1' },
nextStepUuid: 'example-1235',
},
id: 'dndnode_1',
position: { x: 720, y: 250 },
},
{
data: { label: 'avro-deserialize-sink', step: { ...baseStep, UUID: 'example-1235' } },
data: { label: 'avro-deserialize-sink', step: { ...baseStep, UUID: 'example-1235', integrationId: 'Camel Route-1' } },
id: 'dndnode_2',
position: { x: 880, y: 250 },
},
Expand Down
11 changes: 11 additions & 0 deletions src/store/data/branchSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default [
parameters: [],
title: 'Kamelet Source',
UUID: 'kamelet:source-233189',
integrationId: 'Camel Route-1',
},
{
id: 'choice',
Expand Down Expand Up @@ -65,6 +66,7 @@ export default [
required: ['name'],
title: 'Set Header',
UUID: 'set-header-337596',
integrationId: 'Camel Route-1',
},
],
},
Expand Down Expand Up @@ -113,6 +115,7 @@ export default [
required: ['name'],
title: 'Set Property',
UUID: 'set-property-00823',
integrationId: 'Camel Route-1',
},
{
id: 'remove-property',
Expand All @@ -136,6 +139,7 @@ export default [
required: ['name'],
title: 'Remove Property',
UUID: 'remove-property-2403409',
integrationId: 'Camel Route-1',
},
],
},
Expand Down Expand Up @@ -166,6 +170,7 @@ export default [
],
title: 'Transform',
UUID: 'transform-208704',
integrationId: 'Camel Route-1',
},
],
},
Expand Down Expand Up @@ -195,6 +200,7 @@ export default [
],
title: 'Set Body',
UUID: 'set-body-28904309',
integrationId: 'Camel Route-1',
},
{
id: 'remove-header',
Expand All @@ -218,6 +224,7 @@ export default [
required: ['name'],
title: 'Remove Header',
UUID: 'remove-header-281047',
integrationId: 'Camel Route-1',
},
],
},
Expand All @@ -242,6 +249,7 @@ export default [
],
title: 'Content Based Router.',
UUID: 'choice-344294',
integrationId: 'Camel Route-1',
},
{
id: 'filter',
Expand Down Expand Up @@ -275,6 +283,7 @@ export default [
],
title: 'Set Body',
UUID: 'set-body-12334',
integrationId: 'Camel Route-1',
},
],
},
Expand All @@ -299,6 +308,7 @@ export default [
],
title: 'Filter',
UUID: 'filter-3923735',
integrationId: 'Camel Route-1',
},
{
id: 'kamelet:sink',
Expand All @@ -313,5 +323,6 @@ export default [
parameters: [],
title: 'Kamelet Sink',
UUID: 'kamelet:sink-559424',
integrationId: 'Camel Route-1',
},
] as IStepProps[];
4 changes: 4 additions & 0 deletions src/store/data/steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default [
name: 'twitter-search-source',
type: 'START',
UUID: 'twitter-search-source-0',
integrationId: 'Camel Route-1',
description:
'Allows to get all tweets on particular keywords from Twitter.\n\nIt requires tokens that can be obtained by creating an application \nin the Twitter developer portal: https://developer.twitter.com/.',
group: 'Twitter',
Expand Down Expand Up @@ -72,6 +73,7 @@ export default [
name: 'pdf-action',
type: 'MIDDLE',
UUID: 'pdf-action-1',
integrationId: 'Camel Route-1',
description: 'Create a PDF',
group: 'PDF',
icon: 'data:image/svg+xml',
Expand Down Expand Up @@ -116,6 +118,7 @@ export default [
name: 'caffeine-action',
type: 'MIDDLE',
UUID: 'caffeine-action-2',
integrationId: 'Camel Route-1',
description:
"Perform operations on a caffeine cache\n\nThe Kamelet expects the following headers to be set:\n\n- `caffeine-key` / `ce-caffeinekey`: as the cache key used in the operation\n\n- `caffeine-operation` / `ce-caffeineoperation`: as the operation to perform. It can be PUT, GET, INVALIDATE and CLEANUP.\n\nIf the caffeine-key header won't be set the exchange ID will be used as key.\n\nIf the caffeine-operation header won't be set, the GET operation will be performed.",
group: 'Caffeine',
Expand All @@ -141,6 +144,7 @@ export default [
name: 'kafka-sink',
type: 'END',
UUID: 'kafka-sink-3',
integrationId: 'Camel Route-1',
description:
'Send data to Kafka topics.\n\nThe Kamelet is able to understand the following headers to be set:\n\n- `key` / `ce-key`: as message key\n\n- `partition-key` / `ce-partitionkey`: as message partition key\n\nBoth the headers are optional.',
group: 'Kafka',
Expand Down
3 changes: 2 additions & 1 deletion src/store/integrationJsonStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ export interface IIntegrationJsonStore {
views: IViewProps[];
}

export const integrationJsonInitialState = {
export const integrationJsonInitialState: Pick<IIntegrationJsonStore, 'integrationJson' | 'views'> = {
integrationJson: {
id: `${initDsl.name}-1`,
dsl: initDsl.name,
metadata: { name: initialSettings.name, namespace: initialSettings.namespace },
steps: [],
Expand Down
1 change: 1 addition & 0 deletions src/stubs/debezium-mongodb.step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1028,4 +1028,5 @@ export const debeziumMongoDBStep: IStepProps = {
minBranches: 0,
maxBranches: 0,
UUID: 'random-and-unique-id',
integrationId: 'Camel Route-1',
};
4 changes: 4 additions & 0 deletions src/stubs/integration-steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export const integrationSteps: IStepProps[] = [
minBranches: 0,
maxBranches: 0,
UUID: 'timer-0',
integrationId: 'Camel Route-1',
},
{
name: 'choice',
Expand Down Expand Up @@ -447,6 +448,7 @@ export const integrationSteps: IStepProps[] = [
minBranches: 0,
maxBranches: 0,
UUID: 'log-0-3610810635',
integrationId: 'Camel Route-1',
},
],
parameters: [],
Expand Down Expand Up @@ -585,6 +587,7 @@ export const integrationSteps: IStepProps[] = [
minBranches: 0,
maxBranches: 0,
UUID: 'log-0-793453600',
integrationId: 'Camel Route-1',
},
],
parameters: [],
Expand All @@ -595,5 +598,6 @@ export const integrationSteps: IStepProps[] = [
minBranches: 1,
maxBranches: -1,
UUID: 'choice-1',
integrationId: 'Camel Route-1',
},
];
15 changes: 10 additions & 5 deletions src/stubs/steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export const kameletSourceStepStub: IStepProps = {
branches: [],
minBranches: 0,
maxBranches: 1,
UUID: 'timer-source-0'
UUID: 'timer-source-0',
integrationId: 'Camel Route-1',
}

export const stepsStub = {
Expand Down Expand Up @@ -69,7 +70,8 @@ export const integrationJSONStub = {
branches: null,
minBranches: 0,
maxBranches: 0,
UUID: 'timer-source-0'
UUID: 'timer-source-0',
integrationId: 'Camel Route-1',
}
],
params: []
Expand All @@ -87,7 +89,8 @@ export const stepsCatalog: IStepProps[] = [
group: 'Camel-Component',
minBranches: 0,
maxBranches: 0,
UUID: 'random-id-1'
UUID: 'random-id-1',
integrationId: 'Camel Route-1',
},
{
name: 'activemq',
Expand All @@ -100,7 +103,8 @@ export const stepsCatalog: IStepProps[] = [
group: 'Camel-Component',
minBranches: 0,
maxBranches: 0,
UUID: 'random-id-2'
UUID: 'random-id-2',
integrationId: 'Camel Route-1',
},
{
name: 'activemq',
Expand All @@ -113,6 +117,7 @@ export const stepsCatalog: IStepProps[] = [
group: 'Camel-Component',
minBranches: 0,
maxBranches: 0,
UUID: 'random-id-3'
UUID: 'random-id-3',
integrationId: 'Camel Route-1',
},
];
4 changes: 4 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface IDeployment {
}

export interface IIntegration {
id: string;
dsl: string;
metadata: IIntegrationMetadata;
params: IIntegrationParams[];
Expand Down Expand Up @@ -142,6 +143,9 @@ export interface IStepProps {

// generated only for integration steps
UUID: string;

// IntegrationID to which this step belongs to
integrationId: string;
}

export interface IStepPropsBranch {
Expand Down

0 comments on commit 56bf6ea

Please sign in to comment.