feat(multi-server): add actions to the server

This commit is contained in:
Mauricio Siu
2024-09-21 00:06:41 -06:00
parent 0b22b694e6
commit 497d45129c
15 changed files with 684 additions and 134 deletions
@@ -1,20 +1,38 @@
import React from "react";
import { Tree } from "@/components/ui/file-tree";
import { api } from "@/utils/api";
import { FileIcon, Folder, Workflow } from "lucide-react";
import { FileIcon, Folder, Loader2, Workflow } from "lucide-react";
import { cn } from "@/lib/utils";
import { ShowTraefikFile } from "./show-traefik-file";
import { AlertBlock } from "@/components/shared/alert-block";
export const ShowTraefikSystem = () => {
interface Props {
serverId?: string;
}
export const ShowTraefikSystem = ({ serverId }: Props) => {
const [file, setFile] = React.useState<null | string>(null);
const { data: directories } = api.settings.readDirectories.useQuery();
const {
data: directories,
isLoading,
error,
isError,
} = api.settings.readDirectories.useQuery({
serverId,
});
return (
<div className={cn("mt-6 md:grid gap-4")}>
<div className="flex flex-col lg:flex-row gap-4 md:gap-10 w-full">
{isError && <AlertBlock type="error">{error?.message}</AlertBlock>}
{isLoading && (
<div className="w-full flex-col gap-2 flex items-center justify-center h-[55vh]">
<span className="text-muted-foreground text-lg font-medium">
Loading...
</span>
<Loader2 className="animate-spin size-8 text-muted-foreground" />
</div>
)}
{directories?.length === 0 && (
<div className="w-full flex-col gap-2 flex items-center justify-center h-[55vh]">
<span className="text-muted-foreground text-lg font-medium">
@@ -34,7 +52,7 @@ export const ShowTraefikSystem = () => {
/>
<div className="w-full">
{file ? (
<ShowTraefikFile path={file} />
<ShowTraefikFile path={file} serverId={serverId} />
) : (
<div className="h-full w-full flex-col gap-2 flex items-center justify-center">
<span className="text-muted-foreground text-lg font-medium">