Skip to content

Commit

Permalink
[BreakableText]: Replace defaultProps with destructuring
Browse files Browse the repository at this point in the history
Partially Resolves jaegertracing#2596
- Remove defaultProps and updated the snapshots for the same

Signed-off-by: Abhishek <[email protected]>
  • Loading branch information
its-me-abhishek committed Jan 24, 2025
1 parent 2d880b4 commit ce50891
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ exports[`<DdgNodeContent> omits the operation if it is null 1`] = `
}
>
<BreakableText
className="BreakableText"
text="some-service"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
Expand All @@ -96,7 +95,6 @@ exports[`<DdgNodeContent> omits the operation if it is null 1`] = `
}
>
<BreakableText
className="BreakableText"
text="some-operation"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
Expand Down Expand Up @@ -230,7 +228,6 @@ exports[`<DdgNodeContent> omits the operation if it is null 2`] = `
}
>
<BreakableText
className="BreakableText"
text="some-service"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
Expand Down Expand Up @@ -364,7 +361,6 @@ exports[`<DdgNodeContent> renders correctly when decorationValue is a string 1`]
}
>
<BreakableText
className="BreakableText"
text="some-service"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
Expand All @@ -379,7 +375,6 @@ exports[`<DdgNodeContent> renders correctly when decorationValue is a string 1`]
}
>
<BreakableText
className="BreakableText"
text="some-operation"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
Expand Down Expand Up @@ -513,7 +508,6 @@ exports[`<DdgNodeContent> renders correctly when decorationValue is a string 2`]
}
>
<BreakableText
className="BreakableText"
text="some-service"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
Expand All @@ -528,7 +522,6 @@ exports[`<DdgNodeContent> renders correctly when decorationValue is a string 2`]
}
>
<BreakableText
className="BreakableText"
text="some-operation"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
Expand Down Expand Up @@ -662,7 +655,6 @@ exports[`<DdgNodeContent> renders correctly when given decorationProgressbar 1`]
}
>
<BreakableText
className="BreakableText"
text="some-service"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
Expand All @@ -677,7 +669,6 @@ exports[`<DdgNodeContent> renders correctly when given decorationProgressbar 1`]
}
>
<BreakableText
className="BreakableText"
text="some-operation"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
Expand Down Expand Up @@ -814,7 +805,6 @@ exports[`<DdgNodeContent> renders correctly when given decorationProgressbar 2`]
}
>
<BreakableText
className="BreakableText"
text="some-service"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
Expand All @@ -829,7 +819,6 @@ exports[`<DdgNodeContent> renders correctly when given decorationProgressbar 2`]
}
>
<BreakableText
className="BreakableText"
text="some-operation"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
Expand Down Expand Up @@ -963,7 +952,6 @@ exports[`<DdgNodeContent> renders correctly when isFocalNode = true and focalNod
}
>
<BreakableText
className="BreakableText"
text="some-service"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
Expand All @@ -978,7 +966,6 @@ exports[`<DdgNodeContent> renders correctly when isFocalNode = true and focalNod
}
>
<BreakableText
className="BreakableText"
text="some-operation"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
Expand Down Expand Up @@ -1112,7 +1099,6 @@ exports[`<DdgNodeContent> renders correctly when isFocalNode = true and focalNod
}
>
<BreakableText
className="BreakableText"
text="some-service"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
Expand All @@ -1127,7 +1113,6 @@ exports[`<DdgNodeContent> renders correctly when isFocalNode = true and focalNod
}
>
<BreakableText
className="BreakableText"
text="some-operation"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
Expand Down Expand Up @@ -1188,7 +1173,6 @@ exports[`<DdgNodeContent> renders the number of operations if there are multiple
}
>
<BreakableText
className="BreakableText"
text="some-service"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
Expand All @@ -1203,7 +1187,6 @@ exports[`<DdgNodeContent> renders the number of operations if there are multiple
}
>
<BreakableText
className="BreakableText"
text="some-operation"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
Expand Down Expand Up @@ -1337,7 +1320,6 @@ exports[`<DdgNodeContent> renders the number of operations if there are multiple
}
>
<BreakableText
className="BreakableText"
text="some-service"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ exports[`<SidePanel> render renders 1`] = `
className="Ddg--DetailsPanel--SvcOpHeader"
>
<BreakableText
className="BreakableText"
text="test svc"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
</div>
<div
Expand Down Expand Up @@ -53,9 +51,7 @@ exports[`<SidePanel> render renders detailLink 1`] = `
className="Ddg--DetailsPanel--SvcOpHeader"
>
<BreakableText
className="BreakableText"
text="test svc"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
</div>
<div
Expand Down Expand Up @@ -113,9 +109,7 @@ exports[`<SidePanel> render renders details 1`] = `
className="Ddg--DetailsPanel--SvcOpHeader"
>
<BreakableText
className="BreakableText"
text="test svc"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
</div>
<div
Expand Down Expand Up @@ -158,9 +152,7 @@ exports[`<SidePanel> render renders details error 1`] = `
className="Ddg--DetailsPanel--SvcOpHeader"
>
<BreakableText
className="BreakableText"
text="test svc"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
</div>
<div
Expand Down Expand Up @@ -203,9 +195,7 @@ exports[`<SidePanel> render renders omitted array of operations 1`] = `
className="Ddg--DetailsPanel--SvcOpHeader"
>
<BreakableText
className="BreakableText"
text="test svc"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
</div>
<div
Expand Down Expand Up @@ -243,9 +233,7 @@ exports[`<SidePanel> render renders while loading 1`] = `
className="Ddg--DetailsPanel--SvcOpHeader"
>
<BreakableText
className="BreakableText"
text="test svc"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
</div>
<div
Expand Down Expand Up @@ -290,14 +278,10 @@ exports[`<SidePanel> render renders with operation 1`] = `
className="Ddg--DetailsPanel--SvcOpHeader"
>
<BreakableText
className="BreakableText"
text="test svc"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
<BreakableText
className="BreakableText"
text="::test op"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
</div>
<div
Expand Down Expand Up @@ -335,9 +319,7 @@ exports[`<SidePanel> render renders with progressbar 1`] = `
className="Ddg--DetailsPanel--SvcOpHeader"
>
<BreakableText
className="BreakableText"
text="test svc"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
</div>
<div
Expand Down
16 changes: 6 additions & 10 deletions packages/jaeger-ui/src/components/common/BreakableText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ import './BreakableText.css';

const WORD_RX = /\W*\w+\W*/g;

type Props = {
export default function BreakableText({
className = 'BreakableText',
wordRegexp = WORD_RX,
text,
}: {
text: string;
className?: string;
wordRegexp?: RegExp;
};

export default function BreakableText(props: Props) {
const { className, text, wordRegexp = WORD_RX } = props;
}) {
if (!text) {
return typeof text === 'string' ? text : null;
}
Expand All @@ -43,8 +44,3 @@ export default function BreakableText(props: Props) {
}
return spans;
}

BreakableText.defaultProps = {
className: 'BreakableText',
wordRegexp: WORD_RX,
};
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ exports[`<NameSelector> clear renders with clear icon when not required and with
<BreakableText
className="NameSelector--value"
text="foo"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
<IoChevronDown
className="NameSelector--chevron"
Expand Down Expand Up @@ -75,7 +74,6 @@ exports[`<NameSelector> renders with is-invalid when required and without a valu
<BreakableText
className="NameSelector--value"
text="This is the placeholder"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
<IoChevronDown
className="NameSelector--chevron"
Expand Down Expand Up @@ -112,7 +110,6 @@ exports[`<NameSelector> renders without exploding 1`] = `
<BreakableText
className="NameSelector--value"
text="This is the placeholder"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
<IoChevronDown
className="NameSelector--chevron"
Expand Down Expand Up @@ -149,7 +146,6 @@ exports[`<NameSelector> renders without is-invalid when not required and without
<BreakableText
className="NameSelector--value"
text="This is the placeholder"
wordRegexp={/\\\\W\\*\\\\w\\+\\\\W\\*/g}
/>
<IoChevronDown
className="NameSelector--chevron"
Expand Down

0 comments on commit ce50891

Please sign in to comment.