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

fix: stale selected item reference in NE details panel #115

Merged
merged 2 commits into from
Nov 6, 2020

Conversation

schottra
Copy link
Contributor

@schottra schottra commented Nov 5, 2020

TL;DR

Fixes an issue where status of a NodeExecution doesn't update in the DetailsPanel if you have the panel open when the status changes.

Type

  • Bug Fix
  • Feature
  • Plugin

Are all requirements met?

  • Code completed
  • Smoke tested
  • Unit tests added
  • Code documentation added
  • Any pending items have an associated Issue

Complete description

We were assigning the selected item for the Details Panel using an object reference, instead of an id reference. When the node executions update, new copies of the items are returned. But the DetailsPanel was still rendering the previously referenced object. To fix it, I updated the state tracking the selected item to be by id / cache key and am now computing the object to return using a memoized find call on the array of executions whenever the array or the selected id change.
Also added a test to cover the regression.

Tracking Issue

flyteorg/flyte#505

Follow-up issue

NA

@codecov-io
Copy link

codecov-io commented Nov 5, 2020

Codecov Report

Merging #115 into master will increase coverage by 0.08%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #115      +/-   ##
==========================================
+ Coverage   70.59%   70.68%   +0.08%     
==========================================
  Files         387      387              
  Lines        6516     6525       +9     
  Branches     1044     1047       +3     
==========================================
+ Hits         4600     4612      +12     
+ Misses       1916     1913       -3     
Impacted Files Coverage Δ
src/components/common/DetailsPanel.tsx 92.30% <ø> (ø)
...s/Executions/Tables/useNodeExecutionsTableState.ts 100.00% <100.00%> (ø)
...ponents/Executions/Tables/nodeExecutionColumns.tsx 93.61% <0.00%> (+2.12%) ⬆️
.../components/Executions/Tables/NodeExecutionRow.tsx 100.00% <0.00%> (+2.22%) ⬆️
...mponents/Executions/Tables/NodeExecutionsTable.tsx 96.55% <0.00%> (+3.44%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6685288...d22a70a. Read the comment docs.

Comment on lines +23 to +25
executions.find(
({ cacheKey }) => cacheKey === selectedExecutionKey
) || null,
Copy link
Contributor

Choose a reason for hiding this comment

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

If .find doesn't find a match it will return undefined. Curious to know if there is a meaningful difference between returning undefined vs null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Short answer: No, not really. The consuming code should handle the undefined case in the same manner as the null case.

Longer answer: It's a matter of preference.

I prefer using null when explicitly setting a value to the "not defined" case and letting it be undefined when it truly was never defined or set. There are also cases where updating a value to be undefined is a little difficult or error-prone (like merging objects or attempting to delete properties). Setting to null feels cleaner in these cases.

To reflect that, the type of the returned value in the state is DetailedNodeExecution | null. It's initialized to null and set to null when the selection is cleared. So allowing it to be undefined here would cause a type error.

@service-github-lyft-semantic-release
Copy link
Contributor

🎉 This PR is included in version 0.17.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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.

4 participants