From 93e16c4b7cb91070d515371de5a783450917d749 Mon Sep 17 00:00:00 2001 From: kv Date: Tue, 16 Jan 2024 11:40:52 -0800 Subject: [PATCH] tags ui --- frontend/src/components/layouts.tsx | 3 +- .../src/components/resources/server/index.tsx | 33 ++++++++++--------- frontend/src/main.tsx | 20 +++++------ frontend/src/pages/resource.tsx | 2 +- frontend/src/ui/badge.tsx | 14 ++++---- frontend/src/ui/command.tsx | 7 ++-- 6 files changed, 42 insertions(+), 37 deletions(-) diff --git a/frontend/src/components/layouts.tsx b/frontend/src/components/layouts.tsx index 852c102eb..db083e108 100644 --- a/frontend/src/components/layouts.tsx +++ b/frontend/src/components/layouts.tsx @@ -27,7 +27,7 @@ import { } from "@ui/card"; import { Logout, ResourceTypeDropdown, ResourcesDropdown } from "./util"; import { HeaderUpdates } from "./updates/header"; -import { ManageTags, ResourceTags } from "./tags"; +import { ResourceTags } from "./tags"; export const Layout = () => { const type = useResourceParamType(); @@ -173,7 +173,6 @@ export const ResourceCard = ({ - diff --git a/frontend/src/components/resources/server/index.tsx b/frontend/src/components/resources/server/index.tsx index 43d44ad6a..a94213dd2 100644 --- a/frontend/src/components/resources/server/index.tsx +++ b/frontend/src/components/resources/server/index.tsx @@ -123,6 +123,14 @@ const NewServer = () => { ); }; +const DeploymentCountOnServer = ({ id }: { id: string }) => { + const { data } = useRead("ListDeployments", { + query: { specific: { server_ids: [id] } }, + }); + + return <>{data?.length ?? 0}; +}; + export const ServerComponents: RequiredResourceComponents = { Name: ({ id }: { id: string }) => <>{useServer(id)?.name}, Description: ({ id }) => <>{useServer(id)?.info.status}, @@ -136,6 +144,8 @@ export const ServerComponents: RequiredResourceComponents = { New: () => , Table: () => { const servers = useRead("ListServers", {}).data; + const all_tags = useRead("ListTags", {}).data; + // const nav = useNavigate(); return ( tags.join(", ") }, + { + header: "Tags", + accessorFn: ({ tags }) => + tags + .map((t) => all_tags?.find((tg) => tg._id?.$oid === t)?.name) + .join(", "), + }, { header: "Deployments", - cell: ({ - row: { - original: { id }, - }, - }) => { - const count = useRead("ListDeployments", { - query: { specific: { server_ids: [id] } }, - }).data?.length; - if (count) { - return <>{count}; - } else { - return <>0; - } - }, + cell: ({ row }) => , }, { header: "Region", accessorKey: "info.region" }, { diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx index d45716cb9..20f6434bb 100644 --- a/frontend/src/main.tsx +++ b/frontend/src/main.tsx @@ -18,14 +18,14 @@ const query_client = new QueryClient({ }); ReactDOM.createRoot(document.getElementById("root")!).render( - - - - - - - - - - + // + + + + + + + + + // ); diff --git a/frontend/src/pages/resource.tsx b/frontend/src/pages/resource.tsx index 49a998366..b0e818e0b 100644 --- a/frontend/src/pages/resource.tsx +++ b/frontend/src/pages/resource.tsx @@ -27,7 +27,7 @@ export const Resource = () => {
-
+
diff --git a/frontend/src/ui/badge.tsx b/frontend/src/ui/badge.tsx index 5900b7989..df5b03ee7 100644 --- a/frontend/src/ui/badge.tsx +++ b/frontend/src/ui/badge.tsx @@ -1,10 +1,10 @@ -import * as React from "react" -import { cva, type VariantProps } from "class-variance-authority" +import * as React from "react"; +import { cva, type VariantProps } from "class-variance-authority"; -import { cn } from "@lib/utils" +import { cn } from "@lib/utils"; const badgeVariants = cva( - "inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", + "inline-flex items-center rounded-sm border px-3 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", { variants: { variant: { @@ -21,7 +21,7 @@ const badgeVariants = cva( variant: "default", }, } -) +); export interface BadgeProps extends React.HTMLAttributes, @@ -30,7 +30,7 @@ export interface BadgeProps function Badge({ className, variant, ...props }: BadgeProps) { return (
- ) + ); } -export { Badge, badgeVariants } +export { Badge, badgeVariants }; diff --git a/frontend/src/ui/command.tsx b/frontend/src/ui/command.tsx index b88da1bee..2befc11f2 100644 --- a/frontend/src/ui/command.tsx +++ b/frontend/src/ui/command.tsx @@ -70,10 +70,13 @@ CommandList.displayName = CommandPrimitive.List.displayName; const CommandEmpty = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef ->((props, ref) => ( +>(({ className, ...props }, ref) => ( ));