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

fix(StepsService): Generate steady IDs for steps and branches #1578

Merged
merged 1 commit into from
Mar 30, 2023
Merged

fix(StepsService): Generate steady IDs for steps and branches #1578

merged 1 commit into from
Mar 30, 2023

Conversation

lordrip
Copy link
Collaborator

@lordrip lordrip commented Mar 28, 2023

Context

At the moment, when a step is no longer available because it was removed, or its id changed, we close the step's detail panel since is no longer editing the right step.

This causes an issue with vscode since there's a circular dependency between the integration JSON and the code editor. Long story short, whenever there's an update of the integration JSON, the steps or branch IDs change, forcing a new sync cycle from the kogito integration side.

A partial fix to this issue is to ensure that the IDs are consistent between syncs, so this way the comparison inside of the KogitoEditorIntegrationProvider.tsx works.

  // Update KaotoEditor content after an integrationJson change (the user interacted with the Kaoto UI).
  useCancelableEffect(
    useCallback(
      ({ canceled }) => {
        if (!integrationJson || isEqual(previousJson.current, integrationJson)) return;
...

Changes

  • Remove the usage of getRandomArbitraryNumber() to calculate IDs
  • Generate IDs based on:
    • Step name
    • Step position
    • Branch position

Considering the following YAML file

- from:
    uri: activemq:queue:null
    steps:
    - choice:
        when:
        - simple: '{{header}}'
          steps:
          - to:
              uri: sql:null
        - simple: '{{body}}'
          steps:
          - to:
              uri: mongodb:null
        otherwise:
          steps:
          - to:
              uri: sql-stored:null

the IDs would be:

- activemq: activemq-0
- choice: choice-1
    - sql: choice-1|branch-0|sql-0
    - mongodb: choice-1|branch-1|mongodb-0
    - sql-stored: choice-1|branch-2|sqlstored-0

fix: #1553

related to: #1475 (comment)

At the moment, when a step is no longer available because it was removed,
or its id changed, we close the step's detail panel since is no longer
editing the right step.

This causes an issue with vscode since there's a circular dependency
between the integration JSON and the code editor. Long story short,
whenever there's an update of the integration JSON, the steps or
branch IDs change, forcing a new sync cycle from the kogito integration side.

A partial fix to this issue is to ensure that the IDs are consistent between syncs,
so this way the comparison inside of the KogitoEditorIntegrationProvider.tsx works.

fix: #1553
@lordrip lordrip requested a review from a team March 28, 2023 12:58
@sonarqubecloud
Copy link

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
57.2% 57.2% Duplication

@codecov
Copy link

codecov bot commented Mar 28, 2023

Codecov Report

Merging #1578 (0db28f7) into main (1f87445) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1578      +/-   ##
==========================================
+ Coverage   57.00%   57.02%   +0.02%     
==========================================
  Files          68       69       +1     
  Lines        2056     2057       +1     
  Branches      470      470              
==========================================
+ Hits         1172     1173       +1     
  Misses        840      840              
  Partials       44       44              
Impacted Files Coverage Δ
src/services/stepsService.ts 33.48% <100.00%> (-0.30%) ⬇️
src/stubs/index.ts 100.00% <100.00%> (ø)
src/stubs/integration-steps.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

@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.

Not looked at the code.

From a functional point of view, in VS Code, the panel is no more closing. Need to combine testing with the other PR otherwise data is lost and it become crazy #1580

Copy link
Contributor

@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.

From functional point of view, I tried with VS Code and it is working better. No more able to reproduce the data loss.

EDIT: argh this was for the other PR #1580

@lordrip lordrip merged commit a2bed61 into kaoto-archive:main Mar 30, 2023
@lordrip lordrip deleted the fix/kogito-integration branch July 10, 2023 11:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Config panel is closing when editing text fields of a step inside a branch in VS Code
3 participants