diff --git a/messages/en-US.json b/messages/en-US.json index 2077ff56b..b55e2f6c5 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -280,7 +280,7 @@ "back": "Back", "cancel": "Cancel", "resourceConfig": "Configuration Snippets", - "resourceConfigDescription": "Copy and paste these configuration snippets to set up the TCP/UDP resource", + "resourceConfigDescription": "Copy and paste these configuration snippets to set up the TCP/UDP resource.", "resourceAddEntrypoints": "Traefik: Add Entrypoints", "resourceExposePorts": "Gerbil: Expose Ports in Docker Compose", "resourceLearnRaw": "Learn how to configure TCP/UDP resources", @@ -1844,9 +1844,9 @@ "accountSetupSuccess": "Account setup completed! Welcome to Pangolin!", "documentation": "Documentation", "saveAllSettings": "Save All Settings", - "saveResourceTargets": "Save Targets", + "saveResourceTargets": "Save Settings", "saveResourceHttp": "Save Settings", - "saveProxyProtocol": "Save Proxy protocol settings", + "saveProxyProtocol": "Save Settings", "settingsUpdated": "Settings updated", "settingsUpdatedDescription": "Settings updated successfully", "settingsErrorUpdate": "Failed to update settings", @@ -2972,9 +2972,10 @@ "enableProxyProtocol": "Enable Proxy Protocol", "proxyProtocolInfo": "Preserve client IP addresses for TCP backends", "proxyProtocolVersion": "Proxy Protocol Version", - "version1": " Version 1 (Recommended)", + "version1": "Version 1 (Recommended)", "version2": "Version 2", - "versionDescription": "Version 1 is text-based and widely supported. Version 2 is binary and more efficient but less compatible. Make sure servers transport is added to dynamic config.", + "version1Description": "Text-based and widely supported. Make sure servers transport is added to dynamic config.", + "version2Description": "Binary and more efficient but less compatible. Make sure servers transport is added to dynamic config.", "warning": "Warning", "proxyProtocolWarning": "The backend application must be configured to accept Proxy Protocol connections. If your backend doesn't support Proxy Protocol, enabling this will break all connections so only enable this if you know what you're doing. Make sure to configure your backend to trust Proxy Protocol headers from Traefik.", "restarting": "Restarting...", diff --git a/src/app/[orgId]/settings/resources/public/[niceId]/general/page.tsx b/src/app/[orgId]/settings/resources/public/[niceId]/general/page.tsx index 78775f81e..574dc27cb 100644 --- a/src/app/[orgId]/settings/resources/public/[niceId]/general/page.tsx +++ b/src/app/[orgId]/settings/resources/public/[niceId]/general/page.tsx @@ -153,7 +153,10 @@ export default function GeneralForm() { let resourcePolicyId: number | null | undefined; - if (showResourcePolicy) { + if ( + showResourcePolicy && + !["tcp", "udp"].includes(resource.mode) + ) { resourcePolicyId = selectedSharedPolicyId; } @@ -473,7 +476,10 @@ export default function GeneralForm() { )} - {showResourcePolicy && ( + {showResourcePolicy && + !["tcp", "udp"].includes( + resource.mode + ) && ( <> diff --git a/src/app/[orgId]/settings/resources/public/[niceId]/tcp/page.tsx b/src/app/[orgId]/settings/resources/public/[niceId]/tcp/page.tsx index 0e14ba9aa..cb038b40f 100644 --- a/src/app/[orgId]/settings/resources/public/[niceId]/tcp/page.tsx +++ b/src/app/[orgId]/settings/resources/public/[niceId]/tcp/page.tsx @@ -1,28 +1,27 @@ "use client"; import { Button } from "@/components/ui/button"; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue -} from "@/components/ui/select"; import { SettingsContainer, + SettingsFormCell, + SettingsFormGrid, SettingsSection, SettingsSectionBody, SettingsSectionDescription, + SettingsSectionFooter, SettingsSectionForm, SettingsSectionHeader, SettingsSectionTitle } from "@app/components/Settings"; import { SwitchInput } from "@app/components/SwitchInput"; +import { + StrategyOption, + StrategySelect +} from "@app/components/StrategySelect"; import { Alert, AlertDescription } from "@app/components/ui/alert"; import { Form, FormControl, - FormDescription, FormField, FormItem, FormLabel, @@ -49,6 +48,7 @@ import { useRouter } from "next/navigation"; import { use, useActionState, + useMemo } from "react"; import { useForm } from "react-hook-form"; import { z } from "zod"; @@ -131,6 +131,22 @@ function ProxyResourceProtocolForm({ const router = useRouter(); + const proxyProtocolVersionOptions = useMemo( + (): StrategyOption<"1" | "2">[] => [ + { + id: "1", + title: t("version1"), + description: t("version1Description") + }, + { + id: "2", + title: t("version2"), + description: t("version2Description") + } + ], + [t] + ); + const [, formAction, isSubmitting] = useActionState( saveProtocolSettings, null @@ -187,105 +203,118 @@ function ProxyResourceProtocolForm({ - +
- ( - - - { - field.onChange(val); - }} - /> - - - )} - /> - - {proxySettingsForm.watch("proxyProtocol") && ( - <> + + ( - - {t("proxyProtocolVersion")} - - + onCheckedChange={( + val + ) => { + field.onChange(val); + }} + /> - - {t("versionDescription")} - )} /> + - - - - {t("warning")}:{" "} - {t("proxyProtocolWarning")} - - - - )} + {proxySettingsForm.watch("proxyProtocol") && ( + <> + + + + + + {t("warning")}: + {" "} + {t("proxyProtocolWarning")} + + + + + + ( + + + {t( + "proxyProtocolVersion" + )} + + + + value={ + field.value === + 2 + ? "2" + : "1" + } + options={ + proxyProtocolVersionOptions + } + onChange={( + value + ) => + field.onChange( + parseInt( + value, + 10 + ) + ) + } + cols={2} + /> + + + + )} + /> + + + )} +
-
- -
+ + + ); } diff --git a/src/app/[orgId]/settings/resources/public/create/page.tsx b/src/app/[orgId]/settings/resources/public/create/page.tsx index 5ab1d912b..0c2b0f1f6 100644 --- a/src/app/[orgId]/settings/resources/public/create/page.tsx +++ b/src/app/[orgId]/settings/resources/public/create/page.tsx @@ -73,13 +73,8 @@ import { ProxyResourceTargetsForm } from "@app/app/[orgId]/settings/resources/public/ProxyResourceTargetsForm"; import { AxiosResponse } from "axios"; -import { - ChevronsUpDown, - ExternalLink, - SquareArrowOutUpRight -} from "lucide-react"; +import { ChevronsUpDown, ExternalLink } from "lucide-react"; import { useTranslations } from "next-intl"; -import Link from "next/link"; import { useParams, useRouter } from "next/navigation"; import { toASCII } from "punycode"; import { @@ -1446,54 +1441,61 @@ export default function Page() { {t("resourceConfig")} - {t("resourceConfigDescription")} + {t("resourceConfigDescription")}{" "} + + {t("learnMore")} + + -
-
-

- {t("resourceAddEntrypoints")} -

-

- {t( - "resourceAddEntrypointsEditFile" - )} -

+ + + + + {t("resourceAddEntrypoints")} + + + {t( + "resourceAddEntrypointsEditFile" + )} + + + + -
+ -
-

- {t("resourceExposePorts")} -

-

- {t( - "resourceExposePortsEditFile" - )} -

+ + + + {t("resourceExposePorts")} + + + {t( + "resourceExposePortsEditFile" + )} + + + + -
- - - {t("resourceLearnRaw")} - - -
+
+