mirror of
https://github.com/moghtech/komodo.git
synced 2026-09-11 16:01:27 +00:00
cleanup type imports
This commit is contained in:
@@ -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 = <T extends Record<string, unknown>>(obj: T) =>
|
||||
Object.keys(obj) as Array<keyof T>;
|
||||
|
||||
export const ConfigAgain = <T extends Resource<unknown, unknown>["config"]>({
|
||||
export const ConfigAgain = <
|
||||
T extends Types.Resource<unknown, unknown>["config"],
|
||||
>({
|
||||
config,
|
||||
update,
|
||||
components,
|
||||
@@ -76,7 +78,7 @@ export const ConfigAgain = <T extends Resource<unknown, unknown>["config"]>({
|
||||
);
|
||||
};
|
||||
|
||||
const ConfigLayout = <T extends Resource<unknown, unknown>["config"]>({
|
||||
const ConfigLayout = <T extends Types.Resource<unknown, unknown>["config"]>({
|
||||
content,
|
||||
children,
|
||||
onConfirm,
|
||||
|
||||
@@ -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 <StopContainer id={id} />;
|
||||
return <StartContainer id={id} />;
|
||||
};
|
||||
@@ -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 (
|
||||
<ActionWithDialog
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ConfigItem } from "@components/config/util";
|
||||
import { DeploymentConfig } from "@monitor/client/dist/types";
|
||||
import { Types } from "@monitor/client";
|
||||
import { Button } from "@ui/button";
|
||||
import { Input } from "@ui/input";
|
||||
import { MinusCircle, PlusCircle } from "lucide-react";
|
||||
@@ -9,7 +9,7 @@ export const ExtraArgs = ({
|
||||
set,
|
||||
}: {
|
||||
args: string[];
|
||||
set: (update: Partial<DeploymentConfig>) => void;
|
||||
set: (update: Partial<Types.DeploymentConfig>) => void;
|
||||
}) => {
|
||||
return (
|
||||
<ConfigItem label="Extra Args" className="items-start">
|
||||
|
||||
@@ -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 }) => {
|
||||
<div className="flex items-center gap-2">
|
||||
<Calendar className="w-4 h-4" />
|
||||
<div>
|
||||
{update.status === UpdateStatus.InProgress
|
||||
{update.status === Types.UpdateStatus.InProgress
|
||||
? "ongoing"
|
||||
: fmt_date(new Date(update.start_ts))}
|
||||
</div>
|
||||
@@ -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 = () => {
|
||||
<Circle
|
||||
className={cn(
|
||||
"absolute top-2 right-2 w-2 h-2 stroke-red-500 fill-red-500 transition-opacity",
|
||||
unseen_update ? "opacity-1" : "opacity-0"
|
||||
unseen_update ? "opacity-1" : "opacity-0",
|
||||
)}
|
||||
/>
|
||||
</Button>
|
||||
|
||||
@@ -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 }) => (
|
||||
</UpdateDetails>
|
||||
);
|
||||
|
||||
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) => {
|
||||
>
|
||||
<div className="grid md:grid-cols-3 gap-4">
|
||||
{isLoading && <UpdatePlaceHolder />}
|
||||
{data?.updates.slice(0, 3).map((update) => (
|
||||
<UpdateCard update={update} key={update.id} />
|
||||
))}
|
||||
{data?.updates
|
||||
.slice(0, 3)
|
||||
.map((update) => <UpdateCard update={update} key={update.id} />)}
|
||||
</div>
|
||||
</Section>
|
||||
);
|
||||
|
||||
@@ -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<WriteResponses[T], unknown, P, unknown>,
|
||||
"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<ExecuteResponses[T], unknown, P, unknown>,
|
||||
"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<Types.ReadRequest, { type: T }>["params"]
|
||||
P = Extract<Types.ReadRequest, { type: T }>["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", {
|
||||
|
||||
Reference in New Issue
Block a user