diff options
| author | Tobias Järvelöv <tobias.jarvelov@mullvad.net> | 2025-09-03 08:19:51 +0200 |
|---|---|---|
| committer | Tobias Järvelöv <tobias.jarvelov@mullvad.net> | 2025-09-30 09:51:49 +0200 |
| commit | c83669f4f9ba3cc65d2feef041c399fd51ea3a72 (patch) | |
| tree | 819fa1a60f83e579ab1e302104df202f29cd7760 /desktop | |
| parent | ae40996e96ecf64a8e07901f5df87659145228ae (diff) | |
| download | mullvadvpn-c83669f4f9ba3cc65d2feef041c399fd51ea3a72.tar.xz mullvadvpn-c83669f4f9ba3cc65d2feef041c399fd51ea3a72.zip | |
Make NamedProxyForm more composable
Diffstat (limited to 'desktop')
| -rw-r--r-- | desktop/packages/mullvad-vpn/src/renderer/components/EditApiAccessMethod.tsx | 8 | ||||
| -rw-r--r-- | desktop/packages/mullvad-vpn/src/renderer/components/ProxyForm.tsx | 13 |
2 files changed, 11 insertions, 10 deletions
diff --git a/desktop/packages/mullvad-vpn/src/renderer/components/EditApiAccessMethod.tsx b/desktop/packages/mullvad-vpn/src/renderer/components/EditApiAccessMethod.tsx index f3c55965d8..4dbdf309b1 100644 --- a/desktop/packages/mullvad-vpn/src/renderer/components/EditApiAccessMethod.tsx +++ b/desktop/packages/mullvad-vpn/src/renderer/components/EditApiAccessMethod.tsx @@ -21,7 +21,7 @@ import { BackAction } from './KeyboardNavigation'; import { Layout, SettingsContainer, SettingsContent, SettingsNavigationScrollbars } from './Layout'; import { ModalAlert, ModalAlertType } from './Modal'; import { NavigationContainer } from './NavigationContainer'; -import { NamedProxyForm } from './ProxyForm'; +import { NamedProxyForm, ProxyFormButtons, ProxyFormInner, ProxyFormNameField } from './ProxyForm'; import SettingsHeader, { HeaderSubTitle, HeaderTitle } from './SettingsHeader'; export function EditApiAccessMethod() { @@ -108,7 +108,11 @@ function AccessMethodForm() { {id !== undefined && method === undefined ? ( <span>Failed to open method</span> ) : ( - <NamedProxyForm proxy={method} onSave={onSave} onCancel={pop} /> + <NamedProxyForm proxy={method} onSave={onSave} onCancel={pop}> + <ProxyFormNameField /> + <ProxyFormInner /> + <ProxyFormButtons /> + </NamedProxyForm> )} <TestingDialog diff --git a/desktop/packages/mullvad-vpn/src/renderer/components/ProxyForm.tsx b/desktop/packages/mullvad-vpn/src/renderer/components/ProxyForm.tsx index c800e3bfff..58b43dfc98 100644 --- a/desktop/packages/mullvad-vpn/src/renderer/components/ProxyForm.tsx +++ b/desktop/packages/mullvad-vpn/src/renderer/components/ProxyForm.tsx @@ -104,12 +104,13 @@ const namedProxyFormContext = React.createContext<NamedProxyFormContext>({ interface NamedProxyFormContainerProps extends Omit<ProxyFormContextProviderProps, 'proxy' | 'onSave'> { + children?: React.ReactNode; proxy?: NamedCustomProxy; onSave: (proxy: NamedCustomProxy) => void; } export function NamedProxyForm(props: NamedProxyFormContainerProps) { - const { onSave, ...otherProps } = props; + const { children, onSave, ...otherProps } = props; const [name, setName] = useState<string>(props.proxy?.name ?? ''); @@ -127,11 +128,7 @@ export function NamedProxyForm(props: NamedProxyFormContainerProps) { return ( <namedProxyFormContext.Provider value={nameContextValue}> <ProxyFormContextProvider {...otherProps} onSave={save}> - <SettingsForm> - <ProxyFormNameField /> - <ProxyFormInner /> - <ProxyFormButtons /> - </SettingsForm> + <SettingsForm>{children}</SettingsForm> </ProxyFormContextProvider> </namedProxyFormContext.Provider> ); @@ -141,7 +138,7 @@ type ProxyFormNameFieldProps = { inputProps?: Partial<SettingsTextInputProps>; }; -function ProxyFormNameField(props: ProxyFormNameFieldProps) { +export function ProxyFormNameField(props: ProxyFormNameFieldProps) { const { name, setName } = useContext(namedProxyFormContext); return ( @@ -184,7 +181,7 @@ export function ProxyFormButtons() { ); } -function ProxyFormInner() { +export function ProxyFormInner() { const { proxy, setProxy } = useContext(proxyFormContext); // Available custom proxies |
