mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat: volume details
This commit is contained in:
@@ -3,7 +3,7 @@ import { volumeConfigSchema } from "@ironmount/schemas";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { type } from "arktype";
|
||||
import { CheckCircle, Loader2, XCircle } from "lucide-react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { testConnectionMutation } from "~/api-client/@tanstack/react-query.gen";
|
||||
import { slugify } from "~/lib/utils";
|
||||
@@ -28,21 +28,9 @@ type Props = {
|
||||
export const CreateVolumeForm = ({ onSubmit, mode = "create", initialValues, formId }: Props) => {
|
||||
const form = useForm<FormValues>({
|
||||
resolver: arktypeResolver(formSchema),
|
||||
defaultValues: {
|
||||
name: "",
|
||||
backend: "directory",
|
||||
},
|
||||
defaultValues: initialValues,
|
||||
});
|
||||
const { setValue, formState, watch, getValues } = form;
|
||||
const { isDirty } = formState;
|
||||
|
||||
useEffect(() => {
|
||||
if (initialValues && !isDirty) {
|
||||
for (const [key, value] of Object.entries(initialValues)) {
|
||||
setValue(key as keyof FormValues, value as string);
|
||||
}
|
||||
}
|
||||
}, [initialValues, isDirty, setValue]);
|
||||
const { watch, getValues } = form;
|
||||
|
||||
const watchedBackend = watch("backend");
|
||||
|
||||
@@ -108,7 +96,7 @@ export const CreateVolumeForm = ({ onSubmit, mode = "create", initialValues, for
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Backend</FormLabel>
|
||||
<Select onValueChange={field.onChange} defaultValue={field.value}>
|
||||
<Select onValueChange={field.onChange} defaultValue={field.value} value={field.value}>
|
||||
<FormControl>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Select a backend" />
|
||||
|
||||
20
apps/client/app/components/layout.tsx
Normal file
20
apps/client/app/components/layout.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Outlet } from "react-router";
|
||||
import { cn } from "~/lib/utils";
|
||||
|
||||
export default function Layout() {
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"absolute inset-0",
|
||||
"[background-size:40px_40px]",
|
||||
"[background-image:linear-gradient(to_right,#e4e4e7_1px,transparent_1px),linear-gradient(to_bottom,#e4e4e7_1px,transparent_1px)]",
|
||||
"dark:[background-image:linear-gradient(to_right,#262626_1px,transparent_1px),linear-gradient(to_bottom,#262626_1px,transparent_1px)]",
|
||||
)}
|
||||
>
|
||||
<div className="pointer-events-none absolute inset-0 flex items-center justify-center bg-white [mask-image:radial-gradient(ellipse_at_center,transparent_20%,black)] dark:bg-black"></div>
|
||||
<main className="relative flex flex-col pt-16 p-4 container mx-auto">
|
||||
<Outlet />
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
29
apps/client/app/components/ui/switch.tsx
Normal file
29
apps/client/app/components/ui/switch.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import * as React from "react"
|
||||
import * as SwitchPrimitive from "@radix-ui/react-switch"
|
||||
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
function Switch({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof SwitchPrimitive.Root>) {
|
||||
return (
|
||||
<SwitchPrimitive.Root
|
||||
data-slot="switch"
|
||||
className={cn(
|
||||
"peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<SwitchPrimitive.Thumb
|
||||
data-slot="switch-thumb"
|
||||
className={cn(
|
||||
"bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0"
|
||||
)}
|
||||
/>
|
||||
</SwitchPrimitive.Root>
|
||||
)
|
||||
}
|
||||
|
||||
export { Switch }
|
||||
Reference in New Issue
Block a user