X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/7f2055dd51e545eb9f9998d001ec6badfa9f0bb7..4b961d16b8f8ef8afbd13697a79fe4684acd0416:/src/common/formatters.ts?ds=sidebyside diff --git a/src/common/formatters.ts b/src/common/formatters.ts index 737ca96f..60e6cd59 100644 --- a/src/common/formatters.ts +++ b/src/common/formatters.ts @@ -2,13 +2,15 @@ // // SPDX-License-Identifier: AGPL-3.0 +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 ""; +};