From 42c769ed569e72af3639491959d42d63abc14ae4 Mon Sep 17 00:00:00 2001 From: mbecker20 Date: Sun, 7 Apr 2024 02:00:17 -0700 Subject: [PATCH] fix only show version if non none --- frontend/src/components/updates/details.tsx | 3 +- frontend/src/components/updates/header.tsx | 5 +- frontend/src/components/updates/resource.tsx | 51 +------------------- frontend/src/lib/utils.ts | 4 ++ 4 files changed, 11 insertions(+), 52 deletions(-) diff --git a/frontend/src/components/updates/details.tsx b/frontend/src/components/updates/details.tsx index 346d3721e..8ace6335f 100644 --- a/frontend/src/components/updates/details.tsx +++ b/frontend/src/components/updates/details.tsx @@ -19,6 +19,7 @@ import { useRead } from "@lib/hooks"; import { ResourceComponents } from "@components/resources"; import { Link } from "react-router-dom"; import { fmt_duration, fmt_version } from "@lib/formatting"; +import { version_is_none } from "@lib/utils"; export const UpdateUser = ({ user_id }: { user_id: string }) => { const username = useRead("GetUsername", { user_id }).data; @@ -76,7 +77,7 @@ export const UpdateDetailsInner = ({ .split("_") .map((s) => s[0].toUpperCase() + s.slice(1)) .join(" ")}{" "} - {fmt_version(update.version)} + {!version_is_none(update.version) && fmt_version(update.version)}
diff --git a/frontend/src/components/updates/header.tsx b/frontend/src/components/updates/header.tsx index 80d50558d..9e688a840 100644 --- a/frontend/src/components/updates/header.tsx +++ b/frontend/src/components/updates/header.tsx @@ -10,7 +10,7 @@ import { Button } from "@ui/button"; import { Calendar, User } from "lucide-react"; import { UpdateDetails, UpdateUser } from "./details"; import { ResourceComponents } from "@components/resources"; -import { cn } from "@lib/utils"; +import { cn, version_is_none } from "@lib/utils"; import { Types } from "@monitor/client"; import { fmt_date, fmt_version } from "@lib/formatting"; @@ -36,7 +36,8 @@ export const SingleUpdate = ({ update }: { update: Types.UpdateListItem }) => { {update.operation.match(/[A-Z][a-z]+|[0-9]+/g)?.join(" ")}
- {fmt_version(update.version)} + {!version_is_none(update.version) && + fmt_version(update.version)}
diff --git a/frontend/src/components/updates/resource.tsx b/frontend/src/components/updates/resource.tsx index 0ffc1fe3c..2c83b33d4 100644 --- a/frontend/src/components/updates/resource.tsx +++ b/frontend/src/components/updates/resource.tsx @@ -16,6 +16,7 @@ import { Section } from "@components/layouts"; import { UpdateDetails, UpdateUser } from "./details"; import { UpdateStatus } from "@monitor/client/dist/types"; import { fmt_date, fmt_version } from "@lib/formatting"; +import { version_is_none } from "@lib/utils"; const UpdateCard = ({ update }: { update: Types.UpdateListItem }) => { const Icon = () => { @@ -35,7 +36,7 @@ const UpdateCard = ({ update }: { update: Types.UpdateListItem }) => {
- {fmt_version(update.version)} + {!version_is_none(update.version) && fmt_version(update.version)}
@@ -49,53 +50,6 @@ const UpdateCard = ({ update }: { update: Types.UpdateListItem }) => {
- {/* - -
- - - {update.operation} - - - - {fmt_version(update.version)} - -
-
- - - - - - - {fmt_version(update.version)} - -
-
- -
*/} - {/* - -
- {update.operation} - - - {fmt_version(update.version)} - -
- -
- - - {" "} - - - - - {fmt_update_date(new Date(update.start_ts))} - - -
*/} ); }; @@ -121,7 +75,6 @@ export const ResourceUpdates = ({ type, id }: Types.ResourceTarget) => { } >
- {/* {isLoading && } */} {data?.updates.slice(0, 3).map((update) => ( ))} diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts index 52e262d19..1242c513d 100644 --- a/frontend/src/lib/utils.ts +++ b/frontend/src/lib/utils.ts @@ -52,3 +52,7 @@ function keep_line(line: string) { if (line[firstIndex] === "#") return false; return true; } + +export function version_is_none({ major, minor, patch }: Types.Version) { + return major === 0 && minor === 0 && patch === 0; +}