From 887cec3f2182456036ced38c50d03148a51469d6 Mon Sep 17 00:00:00 2001 From: Jacopo Gasparetto <jacopo.gasparetto@cnaf.infn.it> Date: Thu, 6 Apr 2023 18:35:49 +0200 Subject: [PATCH] Add parseReadWrite utilty function --- frontend/src/commons/utils.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frontend/src/commons/utils.ts b/frontend/src/commons/utils.ts index 072df54..0513e6a 100644 --- a/frontend/src/commons/utils.ts +++ b/frontend/src/commons/utils.ts @@ -1,6 +1,13 @@ +import { RWAccess } from "../models/bucket"; + export const getHumanSize = (size: number) => { if (size < 1000) return `${size} B`; if (size < 1000000) return `${(size / 1000).toFixed(1)} kB`; if (size < 1000000000) return `${(size / 1000000).toFixed(1)} MB`; if (size < 1000000000000) return `${(size / 1000000000).toFixed(1)} GB`; } + +export const parseReadWriteAccess = (rwAccess: RWAccess) => { + return rwAccess.read && rwAccess.write ? "R/W" : + rwAccess.read ? "R" : rwAccess.write ? "R" : "Unknown"; +} \ No newline at end of file -- GitLab