diff --git a/packages/bruno-app/src/components/CollectionSettings/ProxySettings/index.js b/packages/bruno-app/src/components/CollectionSettings/ProxySettings/index.js index 3f0981f8d..fd3cc8986 100644 --- a/packages/bruno-app/src/components/CollectionSettings/ProxySettings/index.js +++ b/packages/bruno-app/src/components/CollectionSettings/ProxySettings/index.js @@ -1,24 +1,24 @@ import React, { useEffect } from 'react'; import { useFormik } from 'formik'; - +import Tooltip from 'components/Tooltip'; import StyledWrapper from './StyledWrapper'; import * as Yup from 'yup'; import toast from 'react-hot-toast'; const ProxySettings = ({ proxyConfig, onUpdate }) => { const proxySchema = Yup.object({ - enabled: Yup.string().oneOf(['global', 'enabled', 'disabled']), + use: Yup.string().oneOf(['global', 'true', 'false']), protocol: Yup.string().oneOf(['http', 'https', 'socks4', 'socks5']), hostname: Yup.string() - .when('enabled', { - is: 'enabled', + .when('use', { + is: true, then: (hostname) => hostname.required('Specify the hostname for your proxy.'), otherwise: (hostname) => hostname.nullable() }) .max(1024), port: Yup.number() - .when('enabled', { - is: 'enabled', + .when('use', { + is: true, then: (port) => port.required('Specify port between 1 and 65535').typeError('Specify port between 1 and 65535'), otherwise: (port) => port.nullable().transform((_, val) => (val ? Number(val) : null)) }) @@ -26,11 +26,11 @@ const ProxySettings = ({ proxyConfig, onUpdate }) => { .max(65535), auth: Yup.object() .when('enabled', { - is: 'enabled', + is: true, then: Yup.object({ enabled: Yup.boolean(), username: Yup.string() - .when(['enabled'], { + .when('enabled', { is: true, then: (username) => username.required('Specify username for proxy authentication.') }) @@ -44,12 +44,12 @@ const ProxySettings = ({ proxyConfig, onUpdate }) => { }) }) .optional(), - noProxy: Yup.string().optional().max(1024) + bypassProxy: Yup.string().optional().max(1024) }); const formik = useFormik({ initialValues: { - enabled: proxyConfig.enabled || 'global', + use: proxyConfig.use || 'global', protocol: proxyConfig.protocol || 'http', hostname: proxyConfig.hostname || '', port: proxyConfig.port || '', @@ -58,13 +58,20 @@ const ProxySettings = ({ proxyConfig, onUpdate }) => { username: proxyConfig.auth ? proxyConfig.auth.username || '' : '', password: proxyConfig.auth ? proxyConfig.auth.password || '' : '' }, - noProxy: proxyConfig.noProxy || '' + bypassProxy: proxyConfig.bypassProxy || '' }, validationSchema: proxySchema, onSubmit: (values) => { proxySchema .validate(values, { abortEarly: true }) .then((validatedProxy) => { + // serialize 'use' to boolean + if (validatedProxy.use === 'true') { + validatedProxy.use = true; + } else if (validatedProxy.use === 'false') { + validatedProxy.use = false; + } + onUpdate(validatedProxy); }) .catch((error) => { @@ -76,7 +83,7 @@ const ProxySettings = ({ proxyConfig, onUpdate }) => { useEffect(() => { formik.setValues({ - enabled: proxyConfig.enabled || 'global', + use: proxyConfig.use === true ? 'true' : proxyConfig.use === false ? 'false' : 'global', protocol: proxyConfig.protocol || 'http', hostname: proxyConfig.hostname || '', port: proxyConfig.port || '', @@ -85,32 +92,37 @@ const ProxySettings = ({ proxyConfig, onUpdate }) => { username: proxyConfig.auth ? proxyConfig.auth.username || '' : '', password: proxyConfig.auth ? proxyConfig.auth.password || '' : '' }, - noProxy: proxyConfig.noProxy || '' + bypassProxy: proxyConfig.bypassProxy || '' }); }, [proxyConfig]); return (

Proxy Settings

-
-
+ `} + tooltipId="request-var" + />
-
diff --git a/packages/bruno-app/src/components/Preferences/General/index.js b/packages/bruno-app/src/components/Preferences/General/index.js index 2c7bf0228..077ef39fa 100644 --- a/packages/bruno-app/src/components/Preferences/General/index.js +++ b/packages/bruno-app/src/components/Preferences/General/index.js @@ -33,7 +33,7 @@ const General = ({ close }) => {
{ }) }) .optional(), - noProxy: Yup.string().optional().max(1024) + bypassProxy: Yup.string().optional().max(1024) }); const formik = useFormik({ @@ -63,7 +63,7 @@ const ProxySettings = ({ close }) => { username: preferences.proxy.auth ? preferences.proxy.auth.username || '' : '', password: preferences.proxy.auth ? preferences.proxy.auth.password || '' : '' }, - noProxy: preferences.proxy.noProxy || '' + bypassProxy: preferences.proxy.bypassProxy || '' }, validationSchema: proxySchema, onSubmit: (values) => { @@ -101,21 +101,21 @@ const ProxySettings = ({ close }) => { username: preferences.proxy.auth ? preferences.proxy.auth.username || '' : '', password: preferences.proxy.auth ? preferences.proxy.auth.password || '' : '' }, - noProxy: preferences.proxy.noProxy || '' + bypassProxy: preferences.proxy.bypassProxy || '' }); }, [preferences]); return ( -

Proxy Settings

+

Global Proxy Settings

-
+
-
+
@@ -166,7 +166,7 @@ const ProxySettings = ({ close }) => {
-
+
@@ -186,7 +186,7 @@ const ProxySettings = ({ close }) => {
{formik.errors.hostname}
) : null}
-
+
@@ -206,7 +206,7 @@ const ProxySettings = ({ close }) => {
{formik.errors.port}
) : null}
-
+
@@ -218,7 +218,7 @@ const ProxySettings = ({ close }) => { />
-
+
@@ -238,7 +238,7 @@ const ProxySettings = ({ close }) => {
{formik.errors.auth.username}
) : null}
-
+
@@ -259,24 +259,24 @@ const ProxySettings = ({ close }) => { ) : null}
-
-