From a38d09a1177e9b9dd047b60449f656b09221995f Mon Sep 17 00:00:00 2001 From: Mateusz Pietryga Date: Tue, 27 Aug 2024 12:39:19 +0200 Subject: [PATCH] feat: Store client certificate paths in collection settings as relative to collection and display them the UI. (#2421) #2420 --- .../ClientCertSettings/index.js | 19 ++++++++++++++++--- .../components/CollectionSettings/index.js | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js b/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js index 0baa9d39c..ba1debdec 100644 --- a/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js +++ b/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js @@ -10,8 +10,9 @@ import StyledWrapper from './StyledWrapper'; import { useRef } from 'react'; import path from 'path'; import slash from 'utils/common/slash'; +import { isWindowsOS } from 'utils/common/platform'; -const ClientCertSettings = ({ clientCertConfig, onUpdate, onRemove }) => { +const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => { const certFilePathInputRef = useRef(); const keyFilePathInputRef = useRef(); const pfxFilePathInputRef = useRef(); @@ -67,7 +68,15 @@ const ClientCertSettings = ({ clientCertConfig, onUpdate, onRemove }) => { }); const getFile = (e) => { - e.files?.[0]?.path && formik.setFieldValue(e.name, e.files?.[0]?.path); + if (e.files?.[0]?.path) { + let relativePath; + if (isWindowsOS()) { + relativePath = slash(path.win32.relative(root, e.files[0].path)); + } else { + relativePath = path.posix.relative(root, e.files[0].path); + } + formik.setFieldValue(e.name, relativePath); + } }; const resetFileInputFields = () => { @@ -102,10 +111,14 @@ const ClientCertSettings = ({ clientCertConfig, onUpdate, onRemove }) => { : clientCertConfig.map((clientCert) => (
  • -
    +
    {clientCert.domain}
    +
    + + {clientCert.type === 'cert' ? clientCert.certFilePath : clientCert.pfxFilePath} +
    diff --git a/packages/bruno-app/src/components/CollectionSettings/index.js b/packages/bruno-app/src/components/CollectionSettings/index.js index 6cc42a09d..ebf86f724 100644 --- a/packages/bruno-app/src/components/CollectionSettings/index.js +++ b/packages/bruno-app/src/components/CollectionSettings/index.js @@ -95,6 +95,7 @@ const CollectionSettings = ({ collection }) => { case 'clientCert': { return (