17305: Added handling for non collection file size display
authorDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Wed, 2 Jun 2021 21:52:53 +0000 (23:52 +0200)
committerDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Wed, 2 Jun 2021 21:54:45 +0000 (23:54 +0200)
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>

src/common/formatters.ts
src/views-components/data-explorer/renderers.tsx

index 17917127f1c26ac18221f8b34a2efcfd6413da5f..d8228bf5eb007f5c0843d0f16990a73e9b9a1d28 100644 (file)
@@ -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";
 };
index ee40dd3988a2c4b028863903c5c533a045c1c147..4ec0734442644d0168a9edc18fc0860950113303 100644 (file)
@@ -417,6 +417,11 @@ export const renderFileSize = (fileSize?: number) =>
 export const ResourceFileSize = connect(
     (state: RootState, props: { uuid: string }) => {
         const resource = getResource<CollectionResource>(props.uuid)(state.resources);
+
+        if (resource && resource.kind === ResourceKind.COLLECTION) {
+            return { fileSize: '' };
+        }
+
         return { fileSize: resource ? resource.fileSizeTotal : 0 };
     })((props: { fileSize?: number }) => renderFileSize(props.fileSize));