forked from extern/bruno
Merge branch 'usebruno:main' into main
This commit is contained in:
commit
c3895d65e1
@ -35,6 +35,10 @@ const StyledWrapper = styled.div`
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
textarea.curl-command {
|
||||||
|
min-height: 150px;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default StyledWrapper;
|
export default StyledWrapper;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useRef, useEffect } from 'react';
|
import React, { useRef, useEffect, useCallback } from 'react';
|
||||||
import { useFormik } from 'formik';
|
import { useFormik } from 'formik';
|
||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
@ -115,6 +115,25 @@ const NewRequest = ({ collection, item, isEphemeral, onClose }) => {
|
|||||||
|
|
||||||
const onSubmit = () => formik.handleSubmit();
|
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 (
|
return (
|
||||||
<StyledWrapper>
|
<StyledWrapper>
|
||||||
<Modal size="md" title="New Request" confirmText="Create" handleConfirm={onSubmit} handleCancel={onClose}>
|
<Modal size="md" title="New Request" confirmText="Create" handleConfirm={onSubmit} handleCancel={onClose}>
|
||||||
@ -174,7 +193,7 @@ const NewRequest = ({ collection, item, isEphemeral, onClose }) => {
|
|||||||
Name
|
Name
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
id="collection-name"
|
id="request-name"
|
||||||
type="text"
|
type="text"
|
||||||
name="requestName"
|
name="requestName"
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
@ -216,6 +235,7 @@ const NewRequest = ({ collection, item, isEphemeral, onClose }) => {
|
|||||||
spellCheck="false"
|
spellCheck="false"
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
value={formik.values.requestUrl || ''}
|
value={formik.values.requestUrl || ''}
|
||||||
|
onPaste={handlePaste}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -232,8 +252,7 @@ const NewRequest = ({ collection, item, isEphemeral, onClose }) => {
|
|||||||
<textarea
|
<textarea
|
||||||
name="curlCommand"
|
name="curlCommand"
|
||||||
placeholder="Enter cURL request here.."
|
placeholder="Enter cURL request here.."
|
||||||
className="block textbox w-full mt-4"
|
className="block textbox w-full mt-4 curl-command"
|
||||||
style={{ resize: 'none' }}
|
|
||||||
value={formik.values.curlCommand}
|
value={formik.values.curlCommand}
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
></textarea>
|
></textarea>
|
||||||
|
@ -105,7 +105,7 @@ const Sidebar = () => {
|
|||||||
Star
|
Star
|
||||||
</GitHubButton>
|
</GitHubButton>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -46,8 +46,8 @@ describe('curlToJson', () => {
|
|||||||
const result = curlToJson(curlCommand);
|
const result = curlToJson(curlCommand);
|
||||||
|
|
||||||
expect(result).toEqual({
|
expect(result).toEqual({
|
||||||
url: '%27https://www.usebruno.com%27',
|
url: 'https://www.usebruno.com',
|
||||||
raw_url: "'https://www.usebruno.com'",
|
raw_url: 'https://www.usebruno.com',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/json, text/plain, */*',
|
Accept: 'application/json, text/plain, */*',
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 1.1.0
|
||||||
|
|
||||||
|
- Upgraded axios to 1.5.1
|
||||||
|
|
||||||
## 1.0.0
|
## 1.0.0
|
||||||
|
|
||||||
- Announcing Stable Release
|
- Announcing Stable Release
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@usebruno/cli",
|
"name": "@usebruno/cli",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "v1.1.0",
|
"version": "v1.1.1",
|
||||||
"name": "bruno",
|
"name": "bruno",
|
||||||
"description": "Opensource API Client for Exploring and Testing APIs",
|
"description": "Opensource API Client for Exploring and Testing APIs",
|
||||||
"homepage": "https://www.usebruno.com",
|
"homepage": "https://www.usebruno.com",
|
||||||
|
Loading…
Reference in New Issue
Block a user