diff --git a/frontend-v2/src/components/config/index.tsx b/frontend-v2/src/components/config/index.tsx index e2d4d404e..67ea24334 100644 --- a/frontend-v2/src/components/config/index.tsx +++ b/frontend-v2/src/components/config/index.tsx @@ -4,7 +4,7 @@ import { ConfirmUpdate, } from "@components/config/util"; import { Section } from "@components/layouts"; -import { Resource } from "@monitor/client/dist/types"; +import { Types } from "@monitor/client"; import { Button } from "@ui/button"; import { Card, CardHeader, CardTitle, CardContent } from "@ui/card"; import { History, Settings } from "lucide-react"; @@ -13,7 +13,9 @@ import { Fragment, ReactNode, SetStateAction, useState } from "react"; const keys = >(obj: T) => Object.keys(obj) as Array; -export const ConfigAgain = ["config"]>({ +export const ConfigAgain = < + T extends Types.Resource["config"], +>({ config, update, components, @@ -76,7 +78,7 @@ export const ConfigAgain = ["config"]>({ ); }; -const ConfigLayout = ["config"]>({ +const ConfigLayout = ["config"]>({ content, children, onConfirm, diff --git a/frontend-v2/src/components/resources/deployment/actions.tsx b/frontend-v2/src/components/resources/deployment/actions.tsx index 87e26deee..4b650f4d4 100644 --- a/frontend-v2/src/components/resources/deployment/actions.tsx +++ b/frontend-v2/src/components/resources/deployment/actions.tsx @@ -5,11 +5,11 @@ import { } from "@components/util"; import { Play, Trash, Pause, Rocket, Pen } from "lucide-react"; import { useExecute, useInvalidate, useRead, useWrite } from "@lib/hooks"; -import { DockerContainerState } from "@monitor/client/dist/types"; import { useNavigate } from "react-router-dom"; import { Input } from "@ui/input"; import { useToast } from "@ui/use-toast"; import { useState } from "react"; +import { Types } from "@monitor/client"; interface DeploymentId { id: string; @@ -79,9 +79,10 @@ export const StartOrStopContainer = ({ id }: DeploymentId) => { const deployments = useRead("ListDeployments", {}).data; const deployment = deployments?.find((d) => d.id === id); - if (deployment?.info.state === DockerContainerState.NotDeployed) return null; + if (deployment?.info.state === Types.DockerContainerState.NotDeployed) + return null; - if (deployment?.info.state === DockerContainerState.Running) + if (deployment?.info.state === Types.DockerContainerState.Running) return ; return ; }; @@ -98,7 +99,7 @@ export const RemoveContainer = ({ id }: DeploymentId) => { }).data?.removing; if (!deployment) return null; - if (state === DockerContainerState.NotDeployed) return null; + if (state === Types.DockerContainerState.NotDeployed) return null; return ( ) => void; + set: (update: Partial) => void; }) => { return ( diff --git a/frontend-v2/src/components/updates/header.tsx b/frontend-v2/src/components/updates/header.tsx index 4571807c8..04fac8b05 100644 --- a/frontend-v2/src/components/updates/header.tsx +++ b/frontend-v2/src/components/updates/header.tsx @@ -9,14 +9,14 @@ import { Bell, Circle } from "lucide-react"; import { Button } from "@ui/button"; import { Calendar, User } from "lucide-react"; import { UpdateDetails, UpdateUser } from "./details"; -import { UpdateListItem, UpdateStatus } from "@monitor/client/dist/types"; import { ResourceComponents } from "@components/resources"; import { cn } from "@lib/utils"; +import { Types } from "@monitor/client"; const fmt_date = (d: Date) => `${d.getDate()}/${d.getMonth() + 1} @ ${d.getHours()}:${d.getMinutes()}`; -export const SingleUpdate = ({ update }: { update: UpdateListItem }) => { +export const SingleUpdate = ({ update }: { update: Types.UpdateListItem }) => { const Components = update.target.type !== "System" ? ResourceComponents[update.target.type] @@ -37,7 +37,7 @@ export const SingleUpdate = ({ update }: { update: UpdateListItem }) => {
- {update.status === UpdateStatus.InProgress + {update.status === Types.UpdateStatus.InProgress ? "ongoing" : fmt_date(new Date(update.start_ts))}
@@ -58,7 +58,7 @@ export const HeaderUpdates = () => { const last_opened = useRead("GetUser", {}).data?.last_update_view; const unseen_update = updates?.updates.some( - (u) => u.start_ts > (last_opened ?? Number.MAX_SAFE_INTEGER) + (u) => u.start_ts > (last_opened ?? Number.MAX_SAFE_INTEGER), ); const invalidate = useInvalidate(); @@ -74,7 +74,7 @@ export const HeaderUpdates = () => { diff --git a/frontend-v2/src/components/updates/resource.tsx b/frontend-v2/src/components/updates/resource.tsx index a3b301c36..3e8b24b06 100644 --- a/frontend-v2/src/components/updates/resource.tsx +++ b/frontend-v2/src/components/updates/resource.tsx @@ -11,7 +11,6 @@ import { Bell, ExternalLink, User, Calendar, Check, X } from "lucide-react"; import { Link } from "react-router-dom"; import { Types } from "@monitor/client"; import { Section } from "@components/layouts"; -import { ResourceTarget } from "@monitor/client/dist/types"; import { fmt_update_date } from "@lib/utils"; import { UpdateDetails, UpdateUser } from "./details"; @@ -55,7 +54,7 @@ const UpdateCard = ({ update }: { update: Types.UpdateListItem }) => ( ); -export const ResourceUpdates = ({ type, id }: ResourceTarget) => { +export const ResourceUpdates = ({ type, id }: Types.ResourceTarget) => { const { data, isLoading } = useRead("ListUpdates", { query: { "target.type": type, @@ -77,9 +76,9 @@ export const ResourceUpdates = ({ type, id }: ResourceTarget) => { >
{isLoading && } - {data?.updates.slice(0, 3).map((update) => ( - - ))} + {data?.updates + .slice(0, 3) + .map((update) => )}
); diff --git a/frontend-v2/src/lib/hooks.ts b/frontend-v2/src/lib/hooks.ts index 3c9fdb4bd..023027494 100644 --- a/frontend-v2/src/lib/hooks.ts +++ b/frontend-v2/src/lib/hooks.ts @@ -5,7 +5,6 @@ import { ReadResponses, WriteResponses, } from "@monitor/client/dist/responses"; -import { ResourceTarget } from "@monitor/client/dist/types"; import { UseMutationOptions, UseQueryOptions, @@ -35,11 +34,11 @@ export const useRead = < (T | P)[] >, "queryFn" | "queryKey" - > + >, >( type: T, params: P, - config?: C + config?: C, ) => useQuery([type, params], () => client.read({ type, params } as R), config); export const useWrite = < @@ -49,10 +48,10 @@ export const useWrite = < C extends Omit< UseMutationOptions, "mutationKey" | "mutationFn" - > + >, >( type: T, - config?: C + config?: C, ) => useMutation([type], (params: P) => client.write({ type, params } as R), { ...config, @@ -68,10 +67,10 @@ export const useExecute = < C extends Omit< UseMutationOptions, "mutationKey" | "mutationFn" - > + >, >( type: T, - config?: C + config?: C, ) => useMutation([type], (params: P) => client.execute({ type, params } as R), { ...config, @@ -86,7 +85,7 @@ export const useInvalidate = () => { return < T extends Types.ReadRequest["type"], - P = Extract["params"] + P = Extract["params"], >( ...keys: Array<[T] | [T, P]> ) => @@ -96,7 +95,7 @@ export const useInvalidate = () => { }); }; -export const usePushRecentlyViewed = ({ type, id }: ResourceTarget) => { +export const usePushRecentlyViewed = ({ type, id }: Types.ResourceTarget) => { const invalidate = useInvalidate(); const push = useWrite("PushRecentlyViewed", {