diff --git a/frontend/src/components/export.tsx b/frontend/src/components/export.tsx new file mode 100644 index 000000000..ee63779be --- /dev/null +++ b/frontend/src/components/export.tsx @@ -0,0 +1,59 @@ +import { useRead } from "@lib/hooks"; +import { Types } from "@monitor/client"; +import { Button } from "@ui/button"; +import { + Dialog, + DialogContent, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@ui/dialog"; +import { FileDown, Loader2 } from "lucide-react"; +import { useState } from "react"; +import { CopyButton } from "./util"; + +export const ExportButton = ({}: { + target?: Types.ResourceTarget; + user_group?: string; +}) => { + const [open, setOpen] = useState(false); + return ( + + + + + + + Export to toml + + + + + ); +}; + +const ExportLoader = () => { + const { data, isPending } = useRead("ExportAllResourcesToToml", {}); + return ; +}; + +const ExportPre = ({ + loading, + content, +}: { + loading: boolean; + content: string | undefined; +}) => { + return ( +
+ {loading && } +
+
{content}
+
+ +
+ ); +}; diff --git a/frontend/src/components/resources/deployment/index.tsx b/frontend/src/components/resources/deployment/index.tsx index 44188fd11..bd671763e 100644 --- a/frontend/src/components/resources/deployment/index.tsx +++ b/frontend/src/components/resources/deployment/index.tsx @@ -12,7 +12,7 @@ import { DeleteDeployment, RenameDeployment, } from "./actions"; -import { DeploymentLogs } from "./logs"; +import { DeploymentLogs } from "./log"; import { snake_case_to_upper_space_case } from "@lib/formatting"; import { bg_color_class_by_intention, diff --git a/frontend/src/components/resources/deployment/logs.tsx b/frontend/src/components/resources/deployment/log.tsx similarity index 91% rename from frontend/src/components/resources/deployment/logs.tsx rename to frontend/src/components/resources/deployment/log.tsx index 95408c793..33b5bde8b 100644 --- a/frontend/src/components/resources/deployment/logs.tsx +++ b/frontend/src/components/resources/deployment/log.tsx @@ -10,7 +10,7 @@ import { ChevronDown, X, } from "lucide-react"; -import { useState } from "react"; +import { useEffect, useRef, useState } from "react"; import { useDeployment } from "."; import { Select, @@ -102,10 +102,8 @@ const DeploymentLogsInner = ({ id }: { id: string }) => { - - stdout - - + stdout + stderr {stderr && ( @@ -175,18 +173,24 @@ const Log = ({ stream: "stdout" | "stderr"; }) => { const _log = log?.[stream as keyof typeof log] as string | undefined; + const ref = useRef(null); + const scroll = () => + ref.current?.scroll({ + top: ref.current.scrollHeight, + behavior: "smooth", + }); + useEffect(scroll, []); return ( <> -
+
       
- @@ -218,11 +222,6 @@ const TailLengthSelector = ({ ); -const to_bottom = (id: string) => () => - document - .getElementById(id) - ?.scrollIntoView({ behavior: "smooth", block: "end", inline: "nearest" }); - const convert = new Convert(); /** * Converts the ansi colors in log to html. diff --git a/frontend/src/components/util.tsx b/frontend/src/components/util.tsx index 23a6b12e2..06ea91cc9 100644 --- a/frontend/src/components/util.tsx +++ b/frontend/src/components/util.tsx @@ -260,13 +260,19 @@ export const UserSettings = () => ( ); -export const CopyButton = ({ content }: { content: string | undefined }) => { +export const CopyButton = ({ + content, + className, +}: { + content: string | undefined; + className?: string; +}) => { const { toast } = useToast(); const [copied, set] = useState(false); useEffect(() => { if (copied) { - toast({ title: `Copied "${content}"` }); + toast({ title: "Copied selection" }); const timeout = setTimeout(() => set(false), 3000); return () => { clearTimeout(timeout); @@ -276,7 +282,7 @@ export const CopyButton = ({ content }: { content: string | undefined }) => { return (