Skip to content

Commit

Permalink
issue #379 - file sizes use locale-specific rendering (i.e. show kb/m…
Browse files Browse the repository at this point in the history
…b/gb/tb)
  • Loading branch information
shivaramakrishna99 committed Dec 10, 2024
1 parent 85086bc commit abe2b55
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions drc-portals/app/data/c2m2/ExpandableTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import DownloadButton from './DownloadButton';
import DRSBundleButton from './DRSBundleButton';
import { isURL, getNameFromBiosampleTable, getNameFromSubjectTable, getNameFromCollectionTable, getNameFromFileProjTable } from './utils';
import Link from '@/utils/link';
import { RowType } from './utils';
import { RowType, formatFileSize } from './utils';

type TableFunction = (column: string) => string | undefined;

Expand Down Expand Up @@ -132,9 +132,19 @@ const ExpandableTable: React.FC<ExpandableTableProps> = ({
{cellValueString}
</Link>
) : (
column.toLowerCase().includes('size_in_bytes') ?
(<Description description={cellValueString.replace(/\.0$/, '')} key={`${rowIndex}-${column}`} />)
: (<Description description={cellValueString} key={`${rowIndex}-${column}`} />)
column.toLowerCase().includes('size_in_bytes') ? // matches substring 'size_in_bytes' in both "size_in_bytes" and "uncompressed_size_in_bytes"
(
<Description
description={formatFileSize(Number(cellValueString))}
key={`${rowIndex}-${column}`}
/>
)
: (
<Description
description={cellValueString}
key={`${rowIndex}-${column}`}
/>
)
);
});
return { id: row.id, ...renderedColumns };
Expand Down

0 comments on commit abe2b55

Please sign in to comment.