From 4dd9a4ce29f8abd1a526e1f184cb6cdf4c068d6b Mon Sep 17 00:00:00 2001 From: Edmundas Ramanauskas Date: Sun, 17 Nov 2024 00:20:48 +0200 Subject: [PATCH 1/2] Add card with port forwarding to the settings page --- .../SettingsPage/BandwidthControlCard.tsx | 2 +- .../SettingsPage/PortForwardingCard.tsx | 52 +++++++++++++++++++ .../SettingsPage/SettingsPage.tsx | 3 ++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 src/pages/Authenticated/SettingsPage/PortForwardingCard.tsx diff --git a/src/pages/Authenticated/SettingsPage/BandwidthControlCard.tsx b/src/pages/Authenticated/SettingsPage/BandwidthControlCard.tsx index 0c0e4842..98abc65a 100644 --- a/src/pages/Authenticated/SettingsPage/BandwidthControlCard.tsx +++ b/src/pages/Authenticated/SettingsPage/BandwidthControlCard.tsx @@ -58,7 +58,7 @@ export const BandwidthControlCard = () => { }, []) return ( - +
diff --git a/src/pages/Authenticated/SettingsPage/PortForwardingCard.tsx b/src/pages/Authenticated/SettingsPage/PortForwardingCard.tsx new file mode 100644 index 00000000..9d5aad32 --- /dev/null +++ b/src/pages/Authenticated/SettingsPage/PortForwardingCard.tsx @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2024 BlockDev AG + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +import { useState } from 'react' +import errors from '../../../commons/errors' +import { useAppSelector } from '../../../commons/hooks' +import complexActions from '../../../redux/complex.actions' +import { selectors } from '../../../redux/selectors' +import Card from '../../../components/Cards/Card' +import Button from '../../../components/Buttons/Button' +import { Form } from '../../../components/Inputs/Form' +import { LabeledInput } from '../../../components/Inputs/LabeledInput' + +export default function PortForwardingCard() { + const config = useAppSelector(selectors.currentConfig) + const [loading, setLoading] = useState(false) + const [value, setValue] = useState(config.data.udp.ports) + async function handleConfigSave() { + setLoading(true) + try { + await complexActions.setUserConfig({ udp: { ports: value } }) + } catch (err) { + errors.parseToastError(err) + } finally { + setLoading(false) + } + } + return ( + +
+
+ setValue(val)} + errorMessagePadding={false} + /> +
+
+
+
+
+ ) +} diff --git a/src/pages/Authenticated/SettingsPage/SettingsPage.tsx b/src/pages/Authenticated/SettingsPage/SettingsPage.tsx index f788462b..972920b1 100644 --- a/src/pages/Authenticated/SettingsPage/SettingsPage.tsx +++ b/src/pages/Authenticated/SettingsPage/SettingsPage.tsx @@ -12,6 +12,7 @@ import Label from '../../../components/Typography/Label' import PasswordChangeCard from './PasswordChangeCard' import { NodeStatusControlCard } from './NodeStatusControlCard' import BandwidthControlCard from './BandwidthControlCard' +import PortForwardingCard from './PortForwardingCard' const SettingsPage = () => { return ( @@ -25,6 +26,8 @@ const SettingsPage = () => {