X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/26e9e3a95aa7e99c9b15a0181e972f75781169b9..a6d1469a04f5a6a658cdeac5fc8a11f01d3a1c02:/src/common/formatters.ts diff --git a/src/common/formatters.ts b/src/common/formatters.ts index e2097878..60e6cd59 100644 --- a/src/common/formatters.ts +++ b/src/common/formatters.ts @@ -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 ""; +};