mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-09 06:55:03 +00:00
* feat: add response data type selector in response viewer * chore: fixed lint issue * test: add test for resonse format change and preview. * refactor: streamline response format tests with utility functions for navigation and format switching * refactor: simplify ButtonDropdown component and enhance QueryResultTypeSelector with header and toggle switch * feat: enhance ButtonDropdown with prefix and suffix props; implement content type detection and update QueryResult for improved format handling * fix: lint errors resolved * fix: remove unnecessary blank line to resolve lint issues * fix: update response format tests * refactor: remove preview tab locator from response format tests * fix: update dependency in useEffect to include previewFormatOptions for accurate format handling * refactor: reorganize imports and enhance QueryResult component for improved format handling and error display * fix: update error messages in response format preview tests and adjust version in JSON fixture * feat: add drag detection to HtmlPreview component and update structure for improved user interaction * refactor: update ResponsePane components for improved structure and functionality; replace QueryResult with QueryResponse, enhance layout handling, and streamline response actions * refactor: remove ButtonDropdown component and associated styles; * refactor: moved ErrorAlert to ui folder * fix: lint error * feat: add data-testid attributes to Collection and CollectionItem components for improved testability * feat: hide dropdown on select in response selector * fix: update QueryResult component to use detectedContentType for format handling * test: update ResponseLayoutToggle tests to use data-testid for button selection * feat: add data-testid attribute to ResponseClear component for improved testability * refactor: implement clickResponseAction utility for streamlined response action handling in tests * feat: add data-testid attribute to ResponseCopy component for enhanced testability * fix: unwanted code in test
28 lines
717 B
JavaScript
28 lines
717 B
JavaScript
import React from 'react';
|
|
import StyledWrapper from './StyledWrapper';
|
|
|
|
const ResponseSize = ({ size }) => {
|
|
if (!Number.isFinite(size)) {
|
|
return null;
|
|
}
|
|
|
|
let sizeToDisplay = '';
|
|
|
|
// If size is greater than 1024 bytes, format as KB
|
|
if (size > 1024) {
|
|
let kb = Math.floor(size / 1024);
|
|
let decimal = Math.round(((size % 1024) / 1024).toFixed(2) * 100);
|
|
sizeToDisplay = kb + '.' + decimal + 'KB';
|
|
} else {
|
|
// If size is less than or equal to 1024 bytes, display as bytes (B)
|
|
sizeToDisplay = size + 'B';
|
|
}
|
|
|
|
return (
|
|
<StyledWrapper title={(size?.toLocaleString() || '0') + 'B'} className="ml-2">
|
|
{sizeToDisplay}
|
|
</StyledWrapper>
|
|
);
|
|
};
|
|
export default ResponseSize;
|