Merge branch 'usebruno:main' into main

This commit is contained in:
Júnior Sbrissa 2023-11-10 10:30:36 -03:00 committed by GitHub
commit c3895d65e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 36 additions and 9 deletions

View File

@ -35,6 +35,10 @@ const StyledWrapper = styled.div`
}
}
}
textarea.curl-command {
min-height: 150px;
}
`;
export default StyledWrapper;

View File

@ -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 (
<StyledWrapper>
<Modal size="md" title="New Request" confirmText="Create" handleConfirm={onSubmit} handleCancel={onClose}>
@ -174,7 +193,7 @@ const NewRequest = ({ collection, item, isEphemeral, onClose }) => {
Name
</label>
<input
id="collection-name"
id="request-name"
type="text"
name="requestName"
ref={inputRef}
@ -216,6 +235,7 @@ const NewRequest = ({ collection, item, isEphemeral, onClose }) => {
spellCheck="false"
onChange={formik.handleChange}
value={formik.values.requestUrl || ''}
onPaste={handlePaste}
/>
</div>
</div>
@ -232,8 +252,7 @@ const NewRequest = ({ collection, item, isEphemeral, onClose }) => {
<textarea
name="curlCommand"
placeholder="Enter cURL request here.."
className="block textbox w-full mt-4"
style={{ resize: 'none' }}
className="block textbox w-full mt-4 curl-command"
value={formik.values.curlCommand}
onChange={formik.handleChange}
></textarea>

View File

@ -105,7 +105,7 @@ const Sidebar = () => {
Star
</GitHubButton>
</div>
<div className="flex flex-grow items-center justify-end text-xs mr-2">v1.1.0</div>
<div className="flex flex-grow items-center justify-end text-xs mr-2">v1.1.1</div>
</div>
</div>
</div>

View File

@ -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, */*',

View File

@ -1,5 +1,9 @@
# Changelog
## 1.1.0
- Upgraded axios to 1.5.1
## 1.0.0
- Announcing Stable Release

View File

@ -1,6 +1,6 @@
{
"name": "@usebruno/cli",
"version": "1.0.0",
"version": "1.1.0",
"license": "MIT",
"main": "src/index.js",
"bin": {

View File

@ -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",