Merge branch 'master' into 14565-admin-managing-user
[arvados-workbench2.git] / src / common / formatters.ts
index e2097878a9f98276ffe1d78cf49ac6ca4468d894..60e6cd59c53e284a929cd6143c618020537ffd3a 100644 (file)
@@ -2,13 +2,15 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-export const formatDate = (isoDate?: string) => {
+import { PropertyValue } from "~/models/search-bar";
+
+export const formatDate = (isoDate?: string | null) => {
     if (isoDate) {
         const date = new Date(isoDate);
         const text = date.toLocaleString();
-        return text === 'Invalid Date' ? "" : text;
+        return text === 'Invalid Date' ? "(none)" : text;
     }
-    return "";
+    return "(none)";
 };
 
 export const formatFileSize = (size?: number) => {
@@ -67,3 +69,12 @@ const FILE_SIZES = [
         unit: "B"
     }
 ];
+
+export const formatPropertyValue = (pv: PropertyValue) => {
+    if (pv.key) {
+        return pv.value
+            ? `${pv.key}: ${pv.value}`
+            : pv.key;
+    }
+    return "";
+};