"use client"; import { SettingsFormCell, SettingsFormGrid } from "@app/components/Settings"; import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from "@app/components/ui/form"; import { Input } from "@app/components/ui/input"; import { useTranslations } from "next-intl"; import type { Control, UseFormWatch } from "react-hook-form"; type PrivateResourceAliasFieldProps = { control: Control; watch: UseFormWatch; labelPrefix?: "create" | "edit"; disabled?: boolean; }; export function PrivateResourceAliasField({ control, watch, labelPrefix = "edit", disabled = false }: PrivateResourceAliasFieldProps) { const t = useTranslations(); const aliasLabelKey = labelPrefix === "create" ? "createInternalResourceDialogAlias" : "editInternalResourceDialogAlias"; const aliasDescriptionKey = labelPrefix === "create" ? "createInternalResourceDialogAliasDescription" : "editInternalResourceDialogAliasDescription"; const aliasValue = watch("alias"); const aliasEndsWithLocal = typeof aliasValue === "string" && aliasValue.trim().toLowerCase().endsWith(".local"); return ( ( {t(aliasLabelKey)} {aliasEndsWithLocal && (

{t("internalResourceAliasLocalWarning")}

)} {t(aliasDescriptionKey)}
)} /> ); } type PrivateResourceHostDestinationFieldsProps = { control: Control; watch: UseFormWatch; labelPrefix?: "create" | "edit"; hideAlias?: boolean; }; type PrivateResourceInferenceDestinationFieldsProps = { control: Control; watch: UseFormWatch; labelPrefix?: "create" | "edit"; hideAlias?: boolean; }; export function PrivateResourceInferenceDestinationFields({ control, watch, labelPrefix = "edit" }: PrivateResourceInferenceDestinationFieldsProps) { const t = useTranslations(); const destinationLabelKey = labelPrefix === "create" ? "createInternalResourceDialogDestination" : "editInternalResourceDialogDestination"; return ( ); } export function PrivateResourceHostDestinationFields({ control, watch, labelPrefix = "edit", hideAlias = false }: PrivateResourceHostDestinationFieldsProps) { const t = useTranslations(); const destinationLabelKey = labelPrefix === "create" ? "createInternalResourceDialogDestination" : "editInternalResourceDialogDestination"; const destinationField = ( ( {t(destinationLabelKey)} field.onChange( e.target.value === "" ? null : e.target.value ) } /> )} /> ); if (hideAlias) { return destinationField; } return ( {destinationField} ); } export function PrivateResourceCidrDestinationField({ control, labelPrefix = "edit" }: { control: Control; labelPrefix?: "create" | "edit"; }) { const t = useTranslations(); const destinationLabelKey = labelPrefix === "create" ? "createInternalResourceDialogDestination" : "editInternalResourceDialogDestination"; return ( ( {t(destinationLabelKey)} field.onChange( e.target.value === "" ? null : e.target.value ) } /> )} /> ); }