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

[AccordianKeyValues]: replace defaultProps with destructuring #2667

Merged
merged 7 commits into from
Feb 15, 2025

Conversation

its-me-abhishek
Copy link
Contributor

Which problem is this PR solving?

Description of the changes

  • removed defaultProps from AccordianKeyValues

How was this change tested?

  • npm ci
  • npm test

Checklist

@its-me-abhishek its-me-abhishek requested a review from a team as a code owner February 14, 2025 14:11
@its-me-abhishek its-me-abhishek requested review from jkowall and removed request for a team February 14, 2025 14:11
Copy link

codecov bot commented Feb 14, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 96.59%. Comparing base (655f2b7) to head (9f06302).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ceTimelineViewer/SpanDetail/AccordianKeyValues.tsx 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2667      +/-   ##
==========================================
- Coverage   96.62%   96.59%   -0.03%     
==========================================
  Files         256      256              
  Lines        7733     7733              
  Branches     1946     2022      +76     
==========================================
- Hits         7472     7470       -2     
- Misses        261      263       +2     

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

@yurishkuro yurishkuro added the changelog:bugfix-or-minor-feature 🐞 Bug fixes, Minor Improvements label Feb 14, 2025
// export for tests
export function KeyValuesSummary(props: { data?: KeyValuePair[] }) {
const { data } = props;
const { data } = props || null;
Copy link
Member

Choose a reason for hiding this comment

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

don't follow this. If props are empty you replace them with null? How then can you deconstruct null into { data } object?

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 think setting this to

const { data = null } = props || {};

should work

if props is truthy, destructuring happens normally else if props is falsy (null, undefined, false, etc.), then {} is used instead as null value

Copy link
Member

Choose a reason for hiding this comment

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

props || {}

why do you need even that? props are not nullable in the signature, so they are already required to be at least {}

linksGetter: ((pairs: KeyValuePair[], index: number) => Link[]) | TNil;
onToggle?: null | (() => void);
};

// export for tests
export function KeyValuesSummary(props: { data?: KeyValuePair[] }) {
Copy link
Member

Choose a reason for hiding this comment

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

KeyValuesSummary is used from AccordianKeyValues, where data is not nullable. Why suddenly does it become nullable here?

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 had set this as the defaultProps suggested for KeyValuesSummary that the data would be null by default

KeyValuesSummary.defaultProps = {
  data: null,
};

Copy link
Member

Choose a reason for hiding this comment

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

doesn't answer my question. Previous bug is not the reason to repeat it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

was unaware of that, in that case I guess

export function KeyValuesSummary({ data }: { data: KeyValuePair[] }) {

works well here, and also passes the CI, as only data was being passed through props so I have replaced it, and removed the nullable assignment

yurishkuro
yurishkuro previously approved these changes Feb 15, 2025
@yurishkuro
Copy link
Member

can you add tests to in crease coverage?

@yurishkuro
Copy link
Member

please run npm run prettier

@its-me-abhishek
Copy link
Contributor Author

still shows as uncovered, will try to find a fix for this

@yurishkuro yurishkuro merged commit b8986b3 into jaegertracing:main Feb 15, 2025
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:bugfix-or-minor-feature 🐞 Bug fixes, Minor Improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants