* Fix the negative segment size problem * Fixed contract topic size bug Co-authored-by: German Osin <german.osin@gmail.com>
This commit is contained in:
parent
e78284aa5b
commit
a153ce7b21
3 changed files with 5 additions and 1 deletions
|
@ -1215,6 +1215,7 @@ components:
|
|||
type: integer
|
||||
segmentSize:
|
||||
type: integer
|
||||
format: int64
|
||||
segmentCount:
|
||||
type: integer
|
||||
underReplicatedPartitions:
|
||||
|
|
|
@ -11,7 +11,7 @@ const BytesFormatted: React.FC<Props> = ({ value, precision = 0 }) => {
|
|||
const formatedValue = React.useMemo((): string => {
|
||||
try {
|
||||
const bytes = typeof value === 'string' ? parseInt(value, 10) : value;
|
||||
if (Number.isNaN(bytes)) return `-Bytes`;
|
||||
if (Number.isNaN(bytes) || (bytes && bytes < 0)) return `-Bytes`;
|
||||
if (!bytes || bytes < 1024) return `${Math.ceil(bytes || 0)}${sizes[0]}`;
|
||||
const pow = Math.floor(Math.log2(bytes) / 10);
|
||||
const multiplier = 10 ** (precision < 0 ? 0 : precision);
|
||||
|
|
|
@ -32,6 +32,9 @@ describe('BytesFormatted', () => {
|
|||
component = shallow(<BytesFormatted value="some string" />);
|
||||
expect(component.text()).toEqual(`-${sizes[0]}`);
|
||||
|
||||
component = shallow(<BytesFormatted value={-100000} />);
|
||||
expect(component.text()).toEqual(`-${sizes[0]}`);
|
||||
|
||||
component = shallow(<BytesFormatted value={undefined} />);
|
||||
expect(component.text()).toEqual(`0${sizes[0]}`);
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue