From 4174eebffe4fc2a3364094d92bc8dd414bcad7ee Mon Sep 17 00:00:00 2001 From: mbecker20 Date: Sun, 24 Mar 2024 16:07:52 -0700 Subject: [PATCH] TagsWithBadge --- .../components/resources/deployment/index.tsx | 47 ++++++++++--------- frontend/src/components/tags/index.tsx | 16 +++++-- 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/frontend/src/components/resources/deployment/index.tsx b/frontend/src/components/resources/deployment/index.tsx index e25c50f9e..e75c480d2 100644 --- a/frontend/src/components/resources/deployment/index.tsx +++ b/frontend/src/components/resources/deployment/index.tsx @@ -20,6 +20,7 @@ import { DeploymentLogs } from "./logs"; import { Link } from "react-router-dom"; import { DataTable } from "@ui/data-table"; import { ResourceComponents } from ".."; +import { TagsWithBadge } from "@components/tags"; export const useDeployment = (id?: string) => useRead("ListDeployments", {}, { refetchInterval: 5000 }).data?.find( @@ -121,8 +122,6 @@ export const Deployment: RequiredResourceComponents = { }, Table: () => { const deployments = useRead("ListDeployments", {}).data; - const all_tags = useRead("ListTags", {}).data; - return ( - tags - .map((t) => all_tags?.find((tg) => tg._id?.$oid === t)?.name) - .join(", "), - }, + { header: "Server", cell: ({ row }) => { @@ -166,19 +159,19 @@ export const Deployment: RequiredResourceComponents = { ); }, }, - { - header: "Build", - cell: ({ row }) => { - const id = row.original.info.build_id; - if (!id) return null; - return ( - - - - - ); - }, - }, + // { + // header: "Build", + // cell: ({ row }) => { + // const id = row.original.info.build_id; + // if (!id) return null; + // return ( + // + // + // + // + // ); + // }, + // }, { accessorKey: "info.image", header: "Image", @@ -193,6 +186,16 @@ export const Deployment: RequiredResourceComponents = { return
{status}
; }, }, + { + header: "Tags", + cell: ({ row }) => { + return ( +
+ +
+ ); + } + }, { header: "Created", accessorFn: ({ created_at }) => diff --git a/frontend/src/components/tags/index.tsx b/frontend/src/components/tags/index.tsx index 9bb1a5f06..d44b1d5ae 100644 --- a/frontend/src/components/tags/index.tsx +++ b/frontend/src/components/tags/index.tsx @@ -19,12 +19,22 @@ type TargetExcludingSystem = Exclude; export const ResourceTags = ({ target }: { target: TargetExcludingSystem }) => { const { type, id } = target; const resource = useRead(`List${type}s`, {}).data?.find((d) => d.id === id); - const tags = useRead("ListTags", {}).data; + return ; +}; + +export const TagsWithBadge = ({ + resource_tags, +}: { + resource_tags?: string[]; +}) => { + const all_tags = useRead("ListTags", {}).data; return ( <> - {resource?.tags.map((id) => ( - {tags?.find((t) => t._id?.$oid === id)?.name} + {resource_tags?.map((tag_id) => ( + + {all_tags?.find((t) => t._id?.$oid === tag_id)?.name} + ))} );