Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EDSC-3910: Switching between access methods is not updating the variables displayed #1692

Merged
merged 5 commits into from
Nov 17, 2023

Conversation

eudoroolivares2016
Copy link
Contributor

@eudoroolivares2016 eudoroolivares2016 commented Nov 7, 2023

Overview

What is the feature?

Fixing an issue where selecting a service then selecting from the variables on that service the Tree panel is not updating so we are seeing the variables associated to another service. In the default case should be that the variables which appear are the variable directly associated to the collection in the project, however if the service has variables associated to it we want those to show up instead of the ones on the direct-collection association (even if they are just a subset of those)

What is the Solution?

Update the key prop in the render of the Tree component so that it has a reference to the selectedAccessMethodServiceConceptId such that when we change services this component is going to be re-rendered.

What areas of the application does this impact?

List impacted areas.

Project page and the variables tree view

Reproduction steps

Find a collection with different sets of variables such as C1200196166-SCIOPS in the SIT env in this collection some of the services if selected should have the default set of variables and some should have those associated to the service. If we select one of those sets of variables and then switch to another then the variables on the later are going to be seen on the variable Tree view

We can quickly see these associations from graphql
https://studio.apollographql.com/sandbox/explorer?endpoint=https%3A%2F%2Fgraphql.uat.earthdata.nasa.gov%2Fapi&explorerURLState=N4IgJg9gxgrgtgUwHYBcQC4QEcYIE4CeABABQAkADgIZ5VwDO6RAwhADZsJQoCWES9AJJIKMFAEoiwADpIiRKO07c%2BAktVoMmlGnXqSZc%2BUR4oEDKbOPHFSKAgopBYK9aIA3GjyoAjTvUsjNwUIGFRXYNNzAMNg6yQ6BAi423tHZ2TghN53BAygtwBfTKJigvl6fHceexiS%2BSiLWLj5VIcnF3K3FAIKJK7rTzxvPwQ6gbdFMJR6t0bxlqzE2eC29M7F4zLN7bjd633S1zLCkAAaECGR-wwQGRANPWkMZtdntY7n9GfmAEYAJgADIDfgBOABsv3B4IAtABlZiCADyAAU4c9ZIVToUgA

Attachments

Please include relevant screenshots or files that would be helpful in reviewing and verifying this change.

Checklist

  • I have added automated tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Copy link

codecov bot commented Nov 7, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (12f13a6) 91.91% compared to head (7f8a583) 89.94%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1692      +/-   ##
==========================================
- Coverage   91.91%   89.94%   -1.98%     
==========================================
  Files         726      726              
  Lines       19404    19405       +1     
  Branches     4570     4571       +1     
==========================================
- Hits        17836    17454     -382     
- Misses       1432     1770     +338     
- Partials      136      181      +45     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@eudoroolivares2016 eudoroolivares2016 changed the title EDSC=3910: Switching between access methods is not updating the variables displayed EDSC-3910: Switching between access methods is not updating the variables displayed Nov 7, 2023
@@ -49,7 +49,7 @@ export const Tree = ({
variables,
onUpdateFinished: forceUpdate
})
}, []) // Only execute this useEffect once on initial render
}, [variables]) // Update TreeModel when the list of variables changes
Copy link
Contributor

Choose a reason for hiding this comment

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

This does appear to fix the problem in the tree view, but I don't think it is the best way to fix this problem. Variables in a Tree will never change, so the fact this works means the Tree component is hanging around between the change of the access method, which would lead to unintended side effects like this bug.

You can also this this same behavior in your test SIT collection by selecting an output format, then switching access methods and the output format will not have changed (or reset). I'm not sure if this is actually a problem because the options between those access methods are the same.

You can force React to re-render a component by adding the key prop. When the value you give it changes it will re-render the component. There is probably a more correct way to accomplish the same thing, but just wanted to note those thoughts about this particular solution

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree thank you for the key I'm actively looking for a "better" refactor but, I have updated branch to pass the key with a unique identifier to include both the id of the service and the view so that it re-renders on a change to either

Copy link
Collaborator

@bnp26 bnp26 left a comment

Choose a reason for hiding this comment

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

I went over this, and it looks good, but I'm not super confident about approving it. Just still feel like I don't have enough experience with the TreeNode and VariableTree code.

@eudoroolivares2016 eudoroolivares2016 merged commit 916fb02 into main Nov 17, 2023
@eudoroolivares2016 eudoroolivares2016 deleted the EDSC-3910 branch November 17, 2023 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants