From aab591cb126e8bdaabab3216149da1e9d7eae664 Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Thu, 9 Nov 2023 13:20:07 +0530 Subject: [PATCH 1/4] feat(#338): switch to curl mode if a curl cmd is pasted in new request modal --- .../Sidebar/NewRequest/StyledWrapper.js | 4 +++ .../components/Sidebar/NewRequest/index.js | 27 ++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/packages/bruno-app/src/components/Sidebar/NewRequest/StyledWrapper.js b/packages/bruno-app/src/components/Sidebar/NewRequest/StyledWrapper.js index 72d1d8a9..9845bd2e 100644 --- a/packages/bruno-app/src/components/Sidebar/NewRequest/StyledWrapper.js +++ b/packages/bruno-app/src/components/Sidebar/NewRequest/StyledWrapper.js @@ -35,6 +35,10 @@ const StyledWrapper = styled.div` } } } + + textarea.curl-command { + min-height: 150px; + } `; export default StyledWrapper; diff --git a/packages/bruno-app/src/components/Sidebar/NewRequest/index.js b/packages/bruno-app/src/components/Sidebar/NewRequest/index.js index 43d91430..377e6bb7 100644 --- a/packages/bruno-app/src/components/Sidebar/NewRequest/index.js +++ b/packages/bruno-app/src/components/Sidebar/NewRequest/index.js @@ -1,4 +1,4 @@ -import React, { useRef, useEffect } from 'react'; +import React, { useRef, useEffect, useCallback } from 'react'; import { useFormik } from 'formik'; import * as Yup from 'yup'; import toast from 'react-hot-toast'; @@ -115,6 +115,25 @@ const NewRequest = ({ collection, item, isEphemeral, onClose }) => { const onSubmit = () => formik.handleSubmit(); + const handlePaste = useCallback( + (event) => { + const clipboardData = event.clipboardData || window.clipboardData; + const pastedData = clipboardData.getData('Text'); + + // Check if pasted data looks like a cURL command + const curlCommandRegex = /^\s*curl\s/i; + if (curlCommandRegex.test(pastedData)) { + // Switch to the 'from-curl' request type + formik.setFieldValue('requestType', 'from-curl'); + formik.setFieldValue('curlCommand', pastedData); + + // Prevent the default paste behavior to avoid pasting into the textarea + event.preventDefault(); + } + }, + [formik] + ); + return ( @@ -174,7 +193,7 @@ const NewRequest = ({ collection, item, isEphemeral, onClose }) => { Name { spellCheck="false" onChange={formik.handleChange} value={formik.values.requestUrl || ''} + onPaste={handlePaste} /> @@ -232,8 +252,7 @@ const NewRequest = ({ collection, item, isEphemeral, onClose }) => { From a0196a01b3b04041befc41d277b7e65710b66b8b Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Thu, 9 Nov 2023 13:39:24 +0530 Subject: [PATCH 2/4] chore: bumped release version --- packages/bruno-app/src/components/Sidebar/index.js | 2 +- packages/bruno-electron/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/bruno-app/src/components/Sidebar/index.js b/packages/bruno-app/src/components/Sidebar/index.js index 0e6153f9..670d28d2 100644 --- a/packages/bruno-app/src/components/Sidebar/index.js +++ b/packages/bruno-app/src/components/Sidebar/index.js @@ -105,7 +105,7 @@ const Sidebar = () => { Star -
v1.1.0
+
v1.1.1
diff --git a/packages/bruno-electron/package.json b/packages/bruno-electron/package.json index 57dff832..d0c562a7 100644 --- a/packages/bruno-electron/package.json +++ b/packages/bruno-electron/package.json @@ -1,5 +1,5 @@ { - "version": "v1.1.0", + "version": "v1.1.1", "name": "bruno", "description": "Opensource API Client for Exploring and Testing APIs", "homepage": "https://www.usebruno.com", From 3e137ac6b4fe59b1b85f6a85a55b226a9e879c02 Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Thu, 9 Nov 2023 13:47:33 +0530 Subject: [PATCH 3/4] fix: fixed failing test --- packages/bruno-app/src/utils/curl/curl-to-json.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/bruno-app/src/utils/curl/curl-to-json.spec.js b/packages/bruno-app/src/utils/curl/curl-to-json.spec.js index bf7d836d..c8f7d1c0 100644 --- a/packages/bruno-app/src/utils/curl/curl-to-json.spec.js +++ b/packages/bruno-app/src/utils/curl/curl-to-json.spec.js @@ -46,8 +46,8 @@ describe('curlToJson', () => { const result = curlToJson(curlCommand); expect(result).toEqual({ - url: '%27https://www.usebruno.com%27', - raw_url: "'https://www.usebruno.com'", + url: 'https://www.usebruno.com', + raw_url: 'https://www.usebruno.com', method: 'post', headers: { Accept: 'application/json, text/plain, */*', From ba761098be216e802399e8888974377fbe6bbe4b Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Thu, 9 Nov 2023 16:12:33 +0530 Subject: [PATCH 4/4] chore(#827): bumped bruno cli version to 1.1.0 --- packages/bruno-cli/changelog.md | 4 ++++ packages/bruno-cli/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/bruno-cli/changelog.md b/packages/bruno-cli/changelog.md index adfa14c1..1d672930 100644 --- a/packages/bruno-cli/changelog.md +++ b/packages/bruno-cli/changelog.md @@ -1,5 +1,9 @@ # Changelog +## 1.1.0 + +- Upgraded axios to 1.5.1 + ## 1.0.0 - Announcing Stable Release diff --git a/packages/bruno-cli/package.json b/packages/bruno-cli/package.json index 88c6eb91..d2aa710f 100644 --- a/packages/bruno-cli/package.json +++ b/packages/bruno-cli/package.json @@ -1,6 +1,6 @@ { "name": "@usebruno/cli", - "version": "1.0.0", + "version": "1.1.0", "license": "MIT", "main": "src/index.js", "bin": {