mirror of
https://github.com/moghtech/komodo.git
synced 2026-03-11 17:44:19 -05:00
fix only show version if non none
This commit is contained in:
@@ -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)}
|
||||
</SheetTitle>
|
||||
<SheetDescription className="flex flex-col gap-2">
|
||||
<div className="flex items-center gap-2">
|
||||
|
||||
@@ -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 }) => {
|
||||
<Icon />
|
||||
{update.operation.match(/[A-Z][a-z]+|[0-9]+/g)?.join(" ")}
|
||||
<div className="text-xs text-muted-foreground">
|
||||
{fmt_version(update.version)}
|
||||
{!version_is_none(update.version) &&
|
||||
fmt_version(update.version)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 text-muted-foreground">
|
||||
|
||||
@@ -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 }) => {
|
||||
</div>
|
||||
<div className="flex items-center gap-2 text-muted-foreground">
|
||||
<Milestone className="w-4" />
|
||||
{fmt_version(update.version)}
|
||||
{!version_is_none(update.version) && fmt_version(update.version)}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
@@ -49,53 +50,6 @@ const UpdateCard = ({ update }: { update: Types.UpdateListItem }) => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/* <Card>
|
||||
<CardHeader className="items-center justify-between">
|
||||
<div>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<Icon />
|
||||
{update.operation}
|
||||
</CardTitle>
|
||||
<CardDescription className="flex items-center gap-2">
|
||||
<Milestone className="w-4" />
|
||||
{fmt_version(update.version)}
|
||||
</CardDescription>
|
||||
</div>
|
||||
<div>
|
||||
<CardDescription className="flex items-center gap-2">
|
||||
<User className="w-4" />
|
||||
<UpdateUser user_id={update.operator} />
|
||||
</CardDescription>
|
||||
<CardDescription className="flex items-center gap-2">
|
||||
<Milestone className="w-4" />
|
||||
{fmt_version(update.version)}
|
||||
</CardDescription>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent />
|
||||
</Card> */}
|
||||
{/* <Card className="cursor-pointer hover:translate-y-[-2.5%] hover:bg-accent/50 transition-all">
|
||||
<CardHeader className="justify-between">
|
||||
<div>
|
||||
<CardTitle>{update.operation}</CardTitle>
|
||||
<CardDescription className="flex items-center gap-2">
|
||||
<Milestone className="w-4 h-4" />
|
||||
{fmt_version(update.version)}
|
||||
</CardDescription>
|
||||
</div>
|
||||
<Icon />
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<CardDescription className="flex items-center gap-2">
|
||||
<User className="w-4 h-4" />{" "}
|
||||
<UpdateUser user_id={update.operator} />
|
||||
</CardDescription>
|
||||
<CardDescription className="flex items-center gap-2">
|
||||
<Calendar className="w-4 h-4" />
|
||||
{fmt_update_date(new Date(update.start_ts))}
|
||||
</CardDescription>
|
||||
</CardContent>
|
||||
</Card> */}
|
||||
</UpdateDetails>
|
||||
);
|
||||
};
|
||||
@@ -121,7 +75,6 @@ export const ResourceUpdates = ({ type, id }: Types.ResourceTarget) => {
|
||||
}
|
||||
>
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
{/* {isLoading && <UpdatePlaceHolder />} */}
|
||||
{data?.updates.slice(0, 3).map((update) => (
|
||||
<UpdateCard update={update} key={update.id} />
|
||||
))}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user