From 28e4159c2125bd2e83bd701c591c7674300dfea3 Mon Sep 17 00:00:00 2001 From: Gustavo Ferreira da Silva Date: Sun, 21 Apr 2024 15:20:16 -0300 Subject: [PATCH] feat: toggle password visibility (#2127) * Toggle password in ProxySettings Input 'password' in ProxySettings (Preferences) can be toggled to be visible or not. * Solving button overlap - Button to toggle password won't cover the text; - Added toggle password feature in CollectionSettings (ClientCertSettings and ProxySettings). --- .../ClientCertSettings/StyledWrapper.js | 2 +- .../ClientCertSettings/index.js | 35 +++++++++++------ .../CollectionSettings/ProxySettings/index.js | 36 ++++++++++++------ .../Preferences/ProxySettings/index.js | 38 +++++++++++++------ 4 files changed, 75 insertions(+), 36 deletions(-) diff --git a/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/StyledWrapper.js b/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/StyledWrapper.js index 625bc98e6..621b2b86b 100644 --- a/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/StyledWrapper.js +++ b/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/StyledWrapper.js @@ -9,7 +9,7 @@ const StyledWrapper = styled.div` color: ${(props) => props.theme.colors.text.yellow}; } - input { + .non-passphrase-input { width: 300px; } diff --git a/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js b/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js index 2e860b1e3..c3e618edb 100644 --- a/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js +++ b/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js @@ -3,6 +3,8 @@ import { IconCertificate, IconTrash, IconWorld } from '@tabler/icons'; import { useFormik } from 'formik'; import { uuid } from 'utils/common'; import * as Yup from 'yup'; +import { IconEye, IconEyeOff } from '@tabler/icons'; +import { useState } from 'react'; import StyledWrapper from './StyledWrapper'; @@ -29,6 +31,8 @@ const ClientCertSettings = ({ clientCertConfig, onUpdate, onRemove }) => { formik.values[e.name] = e.files[0].path; }; + const [passwordVisible, setPasswordVisible] = useState(false); + return (
Add client certificates to be used for specific domains.
@@ -63,7 +67,7 @@ const ClientCertSettings = ({ clientCertConfig, onUpdate, onRemove }) => { type="text" name="domain" placeholder="*.example.org" - className="block textbox" + className="block textbox non-passphrase-input" onChange={formik.handleChange} value={formik.values.domain || ''} /> @@ -79,7 +83,7 @@ const ClientCertSettings = ({ clientCertConfig, onUpdate, onRemove }) => { id="certFilePath" type="file" name="certFilePath" - className="block" + className="block non-passphrase-input" onChange={(e) => getFile(e.target)} /> {formik.touched.certFilePath && formik.errors.certFilePath ? ( @@ -94,7 +98,7 @@ const ClientCertSettings = ({ clientCertConfig, onUpdate, onRemove }) => { id="keyFilePath" type="file" name="keyFilePath" - className="block" + className="block non-passphrase-input" onChange={(e) => getFile(e.target)} /> {formik.touched.keyFilePath && formik.errors.keyFilePath ? ( @@ -105,14 +109,23 @@ const ClientCertSettings = ({ clientCertConfig, onUpdate, onRemove }) => { - +
+ + +
{formik.touched.passphrase && formik.errors.passphrase ? (
{formik.errors.passphrase}
) : null} diff --git a/packages/bruno-app/src/components/CollectionSettings/ProxySettings/index.js b/packages/bruno-app/src/components/CollectionSettings/ProxySettings/index.js index 84ad82e70..3df200e88 100644 --- a/packages/bruno-app/src/components/CollectionSettings/ProxySettings/index.js +++ b/packages/bruno-app/src/components/CollectionSettings/ProxySettings/index.js @@ -4,6 +4,8 @@ import Tooltip from 'components/Tooltip'; import StyledWrapper from './StyledWrapper'; import * as Yup from 'yup'; import toast from 'react-hot-toast'; +import { IconEye, IconEyeOff } from '@tabler/icons'; +import { useState } from 'react'; const ProxySettings = ({ proxyConfig, onUpdate }) => { const proxySchema = Yup.object({ @@ -78,6 +80,7 @@ const ProxySettings = ({ proxyConfig, onUpdate }) => { }); } }); + const [passwordVisible, setPasswordVisible] = useState(false); useEffect(() => { formik.setValues({ @@ -277,18 +280,27 @@ const ProxySettings = ({ proxyConfig, onUpdate }) => { - +
+ + +
{formik.touched.auth?.password && formik.errors.auth?.password ? (
{formik.errors.auth.password}
) : null} diff --git a/packages/bruno-app/src/components/Preferences/ProxySettings/index.js b/packages/bruno-app/src/components/Preferences/ProxySettings/index.js index c079059de..849421661 100644 --- a/packages/bruno-app/src/components/Preferences/ProxySettings/index.js +++ b/packages/bruno-app/src/components/Preferences/ProxySettings/index.js @@ -6,6 +6,8 @@ import { savePreferences } from 'providers/ReduxStore/slices/app'; import StyledWrapper from './StyledWrapper'; import { useDispatch, useSelector } from 'react-redux'; +import { IconEye, IconEyeOff } from '@tabler/icons'; +import { useState } from 'react'; const ProxySettings = ({ close }) => { const preferences = useSelector((state) => state.app.preferences); @@ -88,6 +90,8 @@ const ProxySettings = ({ close }) => { }); }; + const [passwordVisible, setPasswordVisible] = useState(false); + useEffect(() => { formik.setValues({ enabled: preferences.proxy.enabled || false, @@ -164,6 +168,7 @@ const ProxySettings = ({ close }) => { +