Skip to content

Commit

Permalink
[TraceHeader]: Replace defaultProps with destructuring (#2621)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
- Part of #2596

## Description of the changes
- Remove defaultProps from the component, replace with destructuring

## How was this change tested?
- By `npm run test`, `npm run update-snapshots`

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [ ] I have added unit tests for the new functionality
- [ ] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `npm run lint` and `npm run test`

---------

Signed-off-by: Abhishek <[email protected]>
  • Loading branch information
its-me-abhishek authored Feb 13, 2025
1 parent b4ee6a9 commit df2cfe8
Showing 1 changed file with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,6 @@ import TraceId from '../../common/TraceId';

import './TraceHeader.css';

type Props = {
duration: number | TNil;
error?: ApiError;
startTime: number | TNil;
state: FetchedState | TNil;
traceID: string | TNil;
traceName: string | TNil;
totalSpans: number | TNil;
};

type AttrsProps = {
startTime: number | TNil;
duration: number | TNil;
totalSpans: number | TNil;
};

// exported for tests
export function EmptyAttrs() {
return (
Expand All @@ -55,8 +39,15 @@ export function EmptyAttrs() {
}

// exported for tests
export function Attrs(props: AttrsProps) {
const { startTime, duration, totalSpans } = props;
export function Attrs({
startTime,
duration,
totalSpans,
}: {
startTime: number | TNil;
duration: number | TNil;
totalSpans: number | TNil;
}) {
return (
<ul className="TraceDiffHeader--traceAttributes" data-testid="TraceDiffHeader--traceAttributes">
<li className="TraceDiffHeader--traceAttr" data-testid="TraceDiffHeader--traceAttr">
Expand Down Expand Up @@ -84,7 +75,15 @@ export default function TraceHeader({
traceID,
totalSpans,
traceName,
}: Props) {
}: {
duration: number | TNil;
error?: ApiError;
startTime: number | TNil;
state: FetchedState | TNil;
traceID: string | TNil;
traceName: string | TNil;
totalSpans: number | TNil;
}) {
const AttrsComponent = state === fetchedState.DONE ? Attrs : EmptyAttrs;

return (
Expand Down

0 comments on commit df2cfe8

Please sign in to comment.