diff --git a/frontend-v2/src/components/layouts.tsx b/frontend-v2/src/components/layouts.tsx index d447e8210..f70b909d4 100644 --- a/frontend-v2/src/components/layouts.tsx +++ b/frontend-v2/src/components/layouts.tsx @@ -23,6 +23,15 @@ import { DialogTitle, DialogTrigger, } from "@ui/dialog"; +import { Types } from "@monitor/client"; +import { ResourceComponents } from "./resources"; +import { + Card, + CardHeader, + CardTitle, + CardDescription, + CardContent, +} from "@ui/card"; export const Layout = () => { const type = useResourceParamType(); @@ -160,3 +169,35 @@ export const NewResource = ({ ); }; + +export const ResourceCard = ({ + target: { type, id }, +}: { + target: Exclude; +}) => { + const Components = ResourceComponents[type]; + + return ( + + + +
+ + + + + + +
+ +
+ + + +
+ + ); +}; diff --git a/frontend-v2/src/components/resources/builder/index.tsx b/frontend-v2/src/components/resources/builder/index.tsx new file mode 100644 index 000000000..db645a500 --- /dev/null +++ b/frontend-v2/src/components/resources/builder/index.tsx @@ -0,0 +1,27 @@ +import { useRead } from "@lib/hooks"; +import { RequiredResourceComponents } from "@types"; +import { Cloud, Bot, Factory } from "lucide-react"; + +const useBuilder = (id?: string) => + useRead("ListBuilders", {}).data?.find((d) => d.id === id); + +export const Builder: RequiredResourceComponents = { + Name: ({ id }) => <>{useBuilder(id)?.name}, + Description: ({ id }) => <>{id}, + Info: ({ id }) => ( + <> +
+ + {useBuilder(id)?.info.provider} +
+
+ + {useBuilder(id)?.info.instance_type ?? "N/A"} +
+ + ), + Icon: () => , + Page: {}, + Actions: () => null, + New: () => null, +}; diff --git a/frontend-v2/src/components/resources/index.tsx b/frontend-v2/src/components/resources/index.tsx index 799a82142..9e1d2e4ab 100644 --- a/frontend-v2/src/components/resources/index.tsx +++ b/frontend-v2/src/components/resources/index.tsx @@ -1,92 +1,18 @@ -import { useRead } from "@lib/hooks"; -import { Types } from "@monitor/client"; import { RequiredResourceComponents, UsableResource } from "@types"; -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, -} from "@ui/card"; -import { Bot, Cloud, Factory, GitBranch } from "lucide-react"; -import { Link } from "react-router-dom"; import { Deployment } from "./deployment"; import { Server } from "./server"; import { Alerter } from "./alerter"; import { Build } from "./build"; - -const useBuilder = (id?: string) => - useRead("ListBuilders", {}).data?.find((d) => d.id === id); - -const useRepo = (id?: string) => - useRead("ListRepos", {}).data?.find((d) => d.id === id); +import { Builder } from "./builder"; +import { Repo } from "./repo"; export const ResourceComponents: { [key in UsableResource]: RequiredResourceComponents; } = { Alerter, Build, - Builder: { - Name: ({ id }) => <>{useBuilder(id)?.name}, - Description: ({ id }) => <>{id}, - Info: ({ id }) => ( - <> -
- - {useBuilder(id)?.info.provider} -
-
- - {useBuilder(id)?.info.instance_type ?? "N/A"} -
- - ), - Icon: () => , - Page: {}, - Actions: () => null, - New: () => null, - }, - Repo: { - Name: ({ id }) => <>{useRepo(id)?.name}, - Description: ({ id }) => <>{id}, - Info: ({ id }) => <>{id}, - Icon: () => , - Page: {}, - Actions: () => null, - New: () => null, - }, + Builder, Deployment, Server, -}; - -export const ResourceCard = ({ - target: { type, id }, -}: { - target: Exclude; -}) => { - const Components = ResourceComponents[type]; - - return ( - - - -
- - - - - - -
- -
- - - -
- - ); + Repo, }; diff --git a/frontend-v2/src/components/resources/repo/index.tsx b/frontend-v2/src/components/resources/repo/index.tsx new file mode 100644 index 000000000..f065be772 --- /dev/null +++ b/frontend-v2/src/components/resources/repo/index.tsx @@ -0,0 +1,16 @@ +import { useRead } from "@lib/hooks"; +import { RequiredResourceComponents } from "@types"; +import { GitBranch } from "lucide-react"; + +const useRepo = (id?: string) => + useRead("ListRepos", {}).data?.find((d) => d.id === id); + +export const Repo: RequiredResourceComponents = { + Name: ({ id }) => <>{useRepo(id)?.name}, + Description: ({ id }) => <>{id}, + Info: ({ id }) => <>{id}, + Icon: () => , + Page: {}, + Actions: () => null, + New: () => null, +};