chore(#684): renamed use to enabled in collection proxy config

This commit is contained in:
Anoop M D 2023-10-23 01:37:30 +05:30
parent 49ea7f33e6
commit 296e067222
3 changed files with 18 additions and 18 deletions

View File

@ -7,17 +7,17 @@ import toast from 'react-hot-toast';
const ProxySettings = ({ proxyConfig, onUpdate }) => { const ProxySettings = ({ proxyConfig, onUpdate }) => {
const proxySchema = Yup.object({ const proxySchema = Yup.object({
use: Yup.string().oneOf(['global', 'true', 'false']), enabled: Yup.string().oneOf(['global', 'true', 'false']),
protocol: Yup.string().oneOf(['http', 'https', 'socks4', 'socks5']), protocol: Yup.string().oneOf(['http', 'https', 'socks4', 'socks5']),
hostname: Yup.string() hostname: Yup.string()
.when('use', { .when('enabled', {
is: true, is: true,
then: (hostname) => hostname.required('Specify the hostname for your proxy.'), then: (hostname) => hostname.required('Specify the hostname for your proxy.'),
otherwise: (hostname) => hostname.nullable() otherwise: (hostname) => hostname.nullable()
}) })
.max(1024), .max(1024),
port: Yup.number() port: Yup.number()
.when('use', { .when('enabled', {
is: true, is: true,
then: (port) => port.required('Specify port between 1 and 65535').typeError('Specify port between 1 and 65535'), 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)) otherwise: (port) => port.nullable().transform((_, val) => (val ? Number(val) : null))
@ -49,7 +49,7 @@ const ProxySettings = ({ proxyConfig, onUpdate }) => {
const formik = useFormik({ const formik = useFormik({
initialValues: { initialValues: {
use: proxyConfig.use || 'global', enabled: proxyConfig.enabled || 'global',
protocol: proxyConfig.protocol || 'http', protocol: proxyConfig.protocol || 'http',
hostname: proxyConfig.hostname || '', hostname: proxyConfig.hostname || '',
port: proxyConfig.port || '', port: proxyConfig.port || '',
@ -65,11 +65,11 @@ const ProxySettings = ({ proxyConfig, onUpdate }) => {
proxySchema proxySchema
.validate(values, { abortEarly: true }) .validate(values, { abortEarly: true })
.then((validatedProxy) => { .then((validatedProxy) => {
// serialize 'use' to boolean // serialize 'enabled' to boolean
if (validatedProxy.use === 'true') { if (validatedProxy.enabled === 'true') {
validatedProxy.use = true; validatedProxy.enabled = true;
} else if (validatedProxy.use === 'false') { } else if (validatedProxy.enabled === 'false') {
validatedProxy.use = false; validatedProxy.enabled = false;
} }
onUpdate(validatedProxy); onUpdate(validatedProxy);
@ -83,7 +83,7 @@ const ProxySettings = ({ proxyConfig, onUpdate }) => {
useEffect(() => { useEffect(() => {
formik.setValues({ formik.setValues({
use: proxyConfig.use === true ? 'true' : proxyConfig.use === false ? 'false' : 'global', enabled: proxyConfig.enabled === true ? 'true' : proxyConfig.enabled === false ? 'false' : 'global',
protocol: proxyConfig.protocol || 'http', protocol: proxyConfig.protocol || 'http',
hostname: proxyConfig.hostname || '', hostname: proxyConfig.hostname || '',
port: proxyConfig.port || '', port: proxyConfig.port || '',
@ -120,9 +120,9 @@ const ProxySettings = ({ proxyConfig, onUpdate }) => {
<label className="flex items-center"> <label className="flex items-center">
<input <input
type="radio" type="radio"
name="use" name="enabled"
value="global" value="global"
checked={formik.values.use === 'global'} checked={formik.values.enabled === 'global'}
onChange={formik.handleChange} onChange={formik.handleChange}
className="mr-1" className="mr-1"
/> />
@ -131,9 +131,9 @@ const ProxySettings = ({ proxyConfig, onUpdate }) => {
<label className="flex items-center ml-4"> <label className="flex items-center ml-4">
<input <input
type="radio" type="radio"
name="use" name="enabled"
value={'true'} value={'true'}
checked={formik.values.use === 'true'} checked={formik.values.enabled === 'true'}
onChange={formik.handleChange} onChange={formik.handleChange}
className="mr-1" className="mr-1"
/> />
@ -142,9 +142,9 @@ const ProxySettings = ({ proxyConfig, onUpdate }) => {
<label className="flex items-center ml-4"> <label className="flex items-center ml-4">
<input <input
type="radio" type="radio"
name="use" name="enabled"
value={'false'} value={'false'}
checked={formik.values.use === 'false'} checked={formik.values.enabled === 'false'}
onChange={formik.handleChange} onChange={formik.handleChange}
className="mr-1" className="mr-1"
/> />

View File

@ -52,7 +52,7 @@ const ImportCollection = ({ onClose, handleSubmit }) => {
Insomnia Collection Insomnia Collection
</div> </div>
<div className="text-link hover:underline cursor-pointer mt-2" onClick={handleImportOpenapiCollection}> <div className="text-link hover:underline cursor-pointer mt-2" onClick={handleImportOpenapiCollection}>
OpenAPI Collection OpenAPI V3 Spec
</div> </div>
</div> </div>
</Modal> </Modal>

View File

@ -120,7 +120,7 @@ const configureRequest = async (collectionUid, request, envVars, collectionVaria
// proxy configuration // proxy configuration
let proxyConfig = get(brunoConfig, 'proxy', {}); let proxyConfig = get(brunoConfig, 'proxy', {});
let proxyEnabled = get(proxyConfig, 'use', false); let proxyEnabled = get(proxyConfig, 'enabled', false);
if (proxyEnabled === 'global') { if (proxyEnabled === 'global') {
proxyConfig = preferencesUtil.getGlobalProxyConfig(); proxyConfig = preferencesUtil.getGlobalProxyConfig();
proxyEnabled = get(proxyConfig, 'enabled', false); proxyEnabled = get(proxyConfig, 'enabled', false);