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

fix(viz): Use metadata.name as flow identifier #2059

Merged
merged 1 commit into from
Jun 29, 2023
Merged

fix(viz): Use metadata.name as flow identifier #2059

merged 1 commit into from
Jun 29, 2023

Conversation

lordrip
Copy link
Member

@lordrip lordrip commented Jun 27, 2023

Context

Currently, the UI creates the flows IDs in two places:

  1. Upon syncing the code through the useFlowsStore.setFlowsWrapper() method
  2. Upon creating a new flow when using the New Flow button

For the .1, since the UI doesn't have a previous ID because we're starting from the source code, the UI creates an ID using the DSL name and the position index, i.e. "Camel Route-1".

For the .2, the UI uses a service to generate an ID with the word "route-####" while "####" it's a 4 digits random number.

Changes

In this commit, the UI leverages the IFlowsWrapper.flows[0].metadata.name property as an ID for each flow, this way, whenever a sync happens, the IDs will be the same.

fixes: KaotoIO/vscode-kaoto#280
fixes: #1910

@lordrip lordrip requested a review from a team June 27, 2023 15:21
@codecov
Copy link

codecov bot commented Jun 27, 2023

Codecov Report

Merging #2059 (61f6e54) into main (e01f4ef) will decrease coverage by 0.10%.
The diff coverage is 81.25%.

@@            Coverage Diff             @@
##             main    #2059      +/-   ##
==========================================
- Coverage   65.15%   65.05%   -0.10%     
==========================================
  Files          88       88              
  Lines        2858     2859       +1     
  Branches      659      661       +2     
==========================================
- Hits         1862     1860       -2     
- Misses        949      953       +4     
+ Partials       47       46       -1     
Impacted Files Coverage Δ
src/store/settingsStore.tsx 100.00% <ø> (ø)
src/components/SourceCodeEditor.tsx 57.81% <16.66%> (ø)
src/components/KaotoToolbar.tsx 54.54% <50.00%> (ø)
src/components/Visualization.tsx 74.22% <100.00%> (-0.31%) ⬇️
src/services/FlowsService.ts 100.00% <100.00%> (ø)
src/services/visualizationService.ts 84.95% <100.00%> (+1.12%) ⬆️
src/store/FlowsStore.ts 98.91% <100.00%> (-1.09%) ⬇️

... and 4 files with indirect coverage changes

@lordrip lordrip requested a review from apupier June 27, 2023 15:29
@@ -18,11 +18,10 @@ Cypress.Commands.add('openCodeEditor', () => {
});

Cypress.Commands.add('editorAddText', (line, text) => {
const arr = text.split('\n');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @unsortedhashsets, I updated these lines, but if it was like that for a reason that maybe I'm not aware of, I'll be happy to revert the file.

Currently, the UI creates the flows IDs in two places:
1. Upon syncing the code through the useFlowsStore.setFlowsWrapper() method
2. Upon creating a new flow when using the New Flow button

For the .1, since the UI doesn't have a previous ID
because we're starting from the source code, the UI
creates an ID using the DSL name and the position index,
i.e. "Camel Route-1".

For the .2, the UI uses a service to generate an ID
with the word "route-####" while "####" it's a 4 digits
random number.

In this commit, the UI leverages the IFlowsWrapper.flows[0].metadata.name
property as an ID for each flow, this way, whenever a sync happens,
the IDs will be the same.

fixes: KaotoIO/vscode-kaoto#280
fixes: #1910
@sonarcloud
Copy link

sonarcloud bot commented Jun 27, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
9.4% 9.4% Duplication

Copy link
Member

@apupier apupier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is working for Camel route, Kamelet Binding and Integration kind but not for Kamelet:

kameletRouteHiddenWhenCreatngAnewOne.mp4

@apupier
Copy link
Member

apupier commented Jun 29, 2023

it is working for Camel route, Kamelet Binding and Integration kind but not for Kamelet:

This won't be a problem after #2064 as the Ui will prevent creating several routes for Kamelet.

@lordrip lordrip merged commit 149a4c9 into KaotoIO:main Jun 29, 2023
@lordrip lordrip deleted the feat/add-routes-identifier branch June 29, 2023 13:41
@lordrip lordrip modified the milestone: 1.1.0 Jun 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants