chore: update dashboard ui
This commit is contained in:
		
							parent
							
								
									08b2ff8b09
								
							
						
					
					
						commit
						af42f625c8
					
				@ -11,8 +11,12 @@ import {
 | 
				
			|||||||
  DialogDescription,
 | 
					  DialogDescription,
 | 
				
			||||||
  DialogHeader,
 | 
					  DialogHeader,
 | 
				
			||||||
  DialogTitle,
 | 
					  DialogTitle,
 | 
				
			||||||
  DialogTrigger,
 | 
					 | 
				
			||||||
} from "@/components/ui/dialog";
 | 
					} from "@/components/ui/dialog";
 | 
				
			||||||
 | 
					import {
 | 
				
			||||||
 | 
					  Tooltip,
 | 
				
			||||||
 | 
					  TooltipContent,
 | 
				
			||||||
 | 
					  TooltipTrigger,
 | 
				
			||||||
 | 
					} from "@/components/ui/tooltip";
 | 
				
			||||||
import * as React from "react";
 | 
					import * as React from "react";
 | 
				
			||||||
import { useState } from "react";
 | 
					import { useState } from "react";
 | 
				
			||||||
import type { UnknownKeysParam, ZodObject, ZodRawShape, z } from "zod";
 | 
					import type { UnknownKeysParam, ZodObject, ZodRawShape, z } from "zod";
 | 
				
			||||||
@ -22,6 +26,8 @@ export function InsertModal<
 | 
				
			|||||||
  Y extends UnknownKeysParam,
 | 
					  Y extends UnknownKeysParam,
 | 
				
			||||||
  Z extends ZodObject<K, Y>
 | 
					  Z extends ZodObject<K, Y>
 | 
				
			||||||
>(props: {
 | 
					>(props: {
 | 
				
			||||||
 | 
					  tooltip?: string;
 | 
				
			||||||
 | 
					  disabled?: boolean;
 | 
				
			||||||
  title: string;
 | 
					  title: string;
 | 
				
			||||||
  description: string;
 | 
					  description: string;
 | 
				
			||||||
  serverAction: (data: z.infer<Z>) => Promise<unknown>;
 | 
					  serverAction: (data: z.infer<Z>) => Promise<unknown>;
 | 
				
			||||||
@ -33,11 +39,37 @@ export function InsertModal<
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <Dialog open={open} onOpenChange={setOpen}>
 | 
					    <Dialog open={open} onOpenChange={setOpen}>
 | 
				
			||||||
      <DialogTrigger asChild>
 | 
					      {/* <DialogTrigger disabled={props.disabled}> */}
 | 
				
			||||||
        <Button variant="default" className="">
 | 
					      {props.tooltip ? (
 | 
				
			||||||
 | 
					        <Tooltip>
 | 
				
			||||||
 | 
					          <TooltipTrigger asChild>
 | 
				
			||||||
 | 
					            <Button
 | 
				
			||||||
 | 
					              variant="default"
 | 
				
			||||||
 | 
					              className={props.disabled ? "opacity-50" : ""}
 | 
				
			||||||
 | 
					              onClick={() => {
 | 
				
			||||||
 | 
					                if (props.disabled) return;
 | 
				
			||||||
 | 
					                setOpen(true);
 | 
				
			||||||
 | 
					              }}
 | 
				
			||||||
 | 
					            >
 | 
				
			||||||
 | 
					              {props.title}
 | 
				
			||||||
 | 
					            </Button>
 | 
				
			||||||
 | 
					          </TooltipTrigger>
 | 
				
			||||||
 | 
					          <TooltipContent>
 | 
				
			||||||
 | 
					            <p>{props.tooltip}</p>
 | 
				
			||||||
 | 
					          </TooltipContent>
 | 
				
			||||||
 | 
					        </Tooltip>
 | 
				
			||||||
 | 
					      ) : (
 | 
				
			||||||
 | 
					        <Button
 | 
				
			||||||
 | 
					          variant="default"
 | 
				
			||||||
 | 
					          disabled={props.disabled}
 | 
				
			||||||
 | 
					          onClick={() => {
 | 
				
			||||||
 | 
					            setOpen(true);
 | 
				
			||||||
 | 
					          }}
 | 
				
			||||||
 | 
					        >
 | 
				
			||||||
          {props.title}
 | 
					          {props.title}
 | 
				
			||||||
        </Button>
 | 
					        </Button>
 | 
				
			||||||
      </DialogTrigger>
 | 
					      )}
 | 
				
			||||||
 | 
					      {/* </DialogTrigger> */}
 | 
				
			||||||
      <DialogContent className="sm:max-w-[425px]">
 | 
					      <DialogContent className="sm:max-w-[425px]">
 | 
				
			||||||
        <DialogHeader>
 | 
					        <DialogHeader>
 | 
				
			||||||
          <DialogTitle>{props.title}</DialogTitle>
 | 
					          <DialogTitle>{props.title}</DialogTitle>
 | 
				
			||||||
 | 
				
			|||||||
@ -304,13 +304,15 @@ export function MachineList({ data }: { data: Machine[] }) {
 | 
				
			|||||||
        />
 | 
					        />
 | 
				
			||||||
        <div className="ml-auto flex gap-2">
 | 
					        <div className="ml-auto flex gap-2">
 | 
				
			||||||
          <InsertModal
 | 
					          <InsertModal
 | 
				
			||||||
            title="Add Machine"
 | 
					            disabled={data.some(
 | 
				
			||||||
            description="Add Comfyui machines to your account."
 | 
					              (machine) => machine.type === "comfy-deploy-serverless"
 | 
				
			||||||
            serverAction={addMachine}
 | 
					            )}
 | 
				
			||||||
            formSchema={addMachineSchema}
 | 
					            tooltip={
 | 
				
			||||||
          />
 | 
					              data.some((machine) => machine.type === "comfy-deploy-serverless")
 | 
				
			||||||
          <InsertModal
 | 
					                ? "Only one hosted machine at preview stage"
 | 
				
			||||||
            title="Custom Machine"
 | 
					                : undefined
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            title="New Machine"
 | 
				
			||||||
            description="Add custom Comfyui machines to your account."
 | 
					            description="Add custom Comfyui machines to your account."
 | 
				
			||||||
            serverAction={addCustomMachine}
 | 
					            serverAction={addCustomMachine}
 | 
				
			||||||
            formSchema={addCustomMachineSchema}
 | 
					            formSchema={addCustomMachineSchema}
 | 
				
			||||||
@ -331,6 +333,12 @@ export function MachineList({ data }: { data: Machine[] }) {
 | 
				
			|||||||
              },
 | 
					              },
 | 
				
			||||||
            }}
 | 
					            }}
 | 
				
			||||||
          />
 | 
					          />
 | 
				
			||||||
 | 
					          <InsertModal
 | 
				
			||||||
 | 
					            title="Custom Machine"
 | 
				
			||||||
 | 
					            description="Add custom comfyui machines to your account."
 | 
				
			||||||
 | 
					            serverAction={addMachine}
 | 
				
			||||||
 | 
					            formSchema={addMachineSchema}
 | 
				
			||||||
 | 
					          />
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
      <div className="rounded-md border overflow-x-auto w-full">
 | 
					      <div className="rounded-md border overflow-x-auto w-full">
 | 
				
			||||||
 | 
				
			|||||||
@ -29,7 +29,7 @@ export function PaginationControl(props: {
 | 
				
			|||||||
  );
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <Pagination>
 | 
					    <Pagination className="mt-2">
 | 
				
			||||||
      <PaginationContent>
 | 
					      <PaginationContent>
 | 
				
			||||||
        <PaginationPrevious
 | 
					        <PaginationPrevious
 | 
				
			||||||
          href={
 | 
					          href={
 | 
				
			||||||
 | 
				
			|||||||
@ -36,11 +36,15 @@ export interface ButtonProps
 | 
				
			|||||||
  extends React.ButtonHTMLAttributes<HTMLButtonElement>,
 | 
					  extends React.ButtonHTMLAttributes<HTMLButtonElement>,
 | 
				
			||||||
    VariantProps<typeof buttonVariants> {
 | 
					    VariantProps<typeof buttonVariants> {
 | 
				
			||||||
  asChild?: boolean;
 | 
					  asChild?: boolean;
 | 
				
			||||||
 | 
					  as?: React.ElementType;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
 | 
					const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
 | 
				
			||||||
  ({ className, variant, size, asChild = false, ...props }, ref) => {
 | 
					  (
 | 
				
			||||||
    const Comp = asChild ? Slot : "button";
 | 
					    { className, variant, size, asChild = false, as = "button", ...props },
 | 
				
			||||||
 | 
					    ref
 | 
				
			||||||
 | 
					  ) => {
 | 
				
			||||||
 | 
					    const Comp = asChild ? Slot : as;
 | 
				
			||||||
    return (
 | 
					    return (
 | 
				
			||||||
      <Comp
 | 
					      <Comp
 | 
				
			||||||
        className={cn(buttonVariants({ variant, size, className }))}
 | 
					        className={cn(buttonVariants({ variant, size, className }))}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user