mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-21 03:18:47 +00:00
refactor(upload): update file upload modal and dropzone components
- Changed zodResolver import to standardSchemaResolver for improved schema handling. - Adjusted Dropzone layout for better visual alignment and user experience. - Removed unused uploadProcedure from the Docker router to streamline the API.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { standardSchemaResolver as zodResolver } from "@hookform/resolvers/standard-schema";
|
||||||
import { Upload } from "lucide-react";
|
import { Upload } from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
@@ -13,6 +13,8 @@ import {
|
|||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogTrigger,
|
DialogTrigger,
|
||||||
} from "@/components/ui/dialog";
|
} from "@/components/ui/dialog";
|
||||||
|
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||||
|
import { Dropzone } from "@/components/ui/dropzone";
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
@@ -22,12 +24,10 @@ import {
|
|||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from "@/components/ui/form";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
|
||||||
import { Dropzone } from "@/components/ui/dropzone";
|
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import {
|
import {
|
||||||
uploadFileToContainerSchema,
|
|
||||||
type UploadFileToContainer,
|
type UploadFileToContainer,
|
||||||
|
uploadFileToContainerSchema,
|
||||||
} from "@/utils/schema";
|
} from "@/utils/schema";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -39,7 +39,7 @@ interface Props {
|
|||||||
export const UploadFileModal = ({ children, containerId, serverId }: Props) => {
|
export const UploadFileModal = ({ children, containerId, serverId }: Props) => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
const { mutateAsync: uploadFile, isLoading } =
|
const { mutateAsync: uploadFile, isPending: isLoading } =
|
||||||
api.docker.uploadFileToContainer.useMutation({
|
api.docker.uploadFileToContainer.useMutation({
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
toast.success("File uploaded successfully");
|
toast.success("File uploaded successfully");
|
||||||
|
|||||||
@@ -56,9 +56,9 @@ export const Dropzone = React.forwardRef<HTMLDivElement, DropzoneProps>(
|
|||||||
onDrop={handleDrop}
|
onDrop={handleDrop}
|
||||||
onClick={handleButtonClick}
|
onClick={handleButtonClick}
|
||||||
>
|
>
|
||||||
<div className="flex items-center justify-center text-muted-foreground">
|
<div className="flex flex-col items-center justify-center text-muted-foreground">
|
||||||
<span className="font-medium text-xl flex items-center gap-2">
|
<FolderIcon className="size-6 text-muted-foreground" />
|
||||||
<FolderIcon className="size-6 text-muted-foreground" />
|
<span className="font-medium text-xl text-center">
|
||||||
{dropMessage}
|
{dropMessage}
|
||||||
</span>
|
</span>
|
||||||
<Input
|
<Input
|
||||||
|
|||||||
@@ -14,12 +14,7 @@ import { TRPCError } from "@trpc/server";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { audit } from "@/server/api/utils/audit";
|
import { audit } from "@/server/api/utils/audit";
|
||||||
import { uploadFileToContainerSchema } from "@/utils/schema";
|
import { uploadFileToContainerSchema } from "@/utils/schema";
|
||||||
import {
|
import { createTRPCRouter, protectedProcedure, withPermission } from "../trpc";
|
||||||
createTRPCRouter,
|
|
||||||
protectedProcedure,
|
|
||||||
uploadProcedure,
|
|
||||||
withPermission,
|
|
||||||
} from "../trpc";
|
|
||||||
|
|
||||||
export const containerIdRegex = /^[a-zA-Z0-9.\-_]+$/;
|
export const containerIdRegex = /^[a-zA-Z0-9.\-_]+$/;
|
||||||
|
|
||||||
@@ -185,7 +180,6 @@ export const dockerRouter = createTRPCRouter({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
uploadFileToContainer: protectedProcedure
|
uploadFileToContainer: protectedProcedure
|
||||||
.use(uploadProcedure)
|
|
||||||
.input(uploadFileToContainerSchema)
|
.input(uploadFileToContainerSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
if (input.serverId) {
|
if (input.serverId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user