From: Daniel Kutyła Date: Wed, 2 Jun 2021 21:52:53 +0000 (+0200) Subject: 17305: Added handling for non collection file size display X-Git-Tag: 2.2.1~3^2~1 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/ad79cd83fc26c3314a6c79137db02b12d1f2714a 17305: Added handling for non collection file size display Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła --- diff --git a/src/common/formatters.ts b/src/common/formatters.ts index 17917127..d8228bf5 100644 --- a/src/common/formatters.ts +++ b/src/common/formatters.ts @@ -20,7 +20,7 @@ export const formatDate = (isoDate?: string | null, utc: boolean = false) => { return "(none)"; }; -export const formatFileSize = (size?: number) => { +export const formatFileSize = (size?: number | string) => { if (typeof size === "number") { if (size === 0) { return "0 B"; } @@ -29,6 +29,9 @@ export const formatFileSize = (size?: number) => { return `${(size / base).toFixed()} ${unit}`; } } + } + if ((typeof size === "string" && size === '') || size === undefined) { + return ''; } return "0 B"; }; diff --git a/src/views-components/data-explorer/renderers.tsx b/src/views-components/data-explorer/renderers.tsx index ee40dd39..4ec07344 100644 --- a/src/views-components/data-explorer/renderers.tsx +++ b/src/views-components/data-explorer/renderers.tsx @@ -417,6 +417,11 @@ export const renderFileSize = (fileSize?: number) => export const ResourceFileSize = connect( (state: RootState, props: { uuid: string }) => { const resource = getResource(props.uuid)(state.resources); + + if (resource && resource.kind === ResourceKind.COLLECTION) { + return { fileSize: '' }; + } + return { fileSize: resource ? resource.fileSizeTotal : 0 }; })((props: { fileSize?: number }) => renderFileSize(props.fileSize));