mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-23 07:09:01 +01:00
commit
5a0e68073f
6
package-lock.json
generated
6
package-lock.json
generated
@ -16776,7 +16776,7 @@
|
||||
},
|
||||
"packages/bruno-cli": {
|
||||
"name": "@usebruno/cli",
|
||||
"version": "0.11.0",
|
||||
"version": "0.12.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@usebruno/js": "0.6.0",
|
||||
@ -16822,7 +16822,7 @@
|
||||
},
|
||||
"packages/bruno-electron": {
|
||||
"name": "bruno",
|
||||
"version": "v0.19.0",
|
||||
"version": "v0.20.0",
|
||||
"dependencies": {
|
||||
"@usebruno/js": "0.6.0",
|
||||
"@usebruno/lang": "0.5.0",
|
||||
@ -20107,7 +20107,7 @@
|
||||
"axios": "^1.5.1",
|
||||
"chai": "^4.3.7",
|
||||
"chalk": "^3.0.0",
|
||||
"decomment": "*",
|
||||
"decomment": "^0.9.5",
|
||||
"form-data": "^4.0.0",
|
||||
"fs-extra": "^10.1.0",
|
||||
"handlebars": "^4.7.8",
|
||||
|
@ -9,7 +9,7 @@ import { findEnvironmentInCollection } from 'utils/collections';
|
||||
|
||||
const interpolateUrl = ({ url, envVars, collectionVariables, processEnvVars }) => {
|
||||
if (!url || !url.length || typeof url !== 'string') {
|
||||
return str;
|
||||
return;
|
||||
}
|
||||
|
||||
const template = handlebars.compile(url, { noEscape: true });
|
||||
@ -74,9 +74,8 @@ const languages = [
|
||||
];
|
||||
|
||||
const GenerateCodeItem = ({ collection, item, onClose }) => {
|
||||
const url = get(item, 'request.url') || '';
|
||||
const url = get(item, 'draft.request.url') !== undefined ? get(item, 'draft.request.url') : get(item, 'request.url');
|
||||
const environment = findEnvironmentInCollection(collection, collection.activeEnvironmentUid);
|
||||
|
||||
let envVars = {};
|
||||
if (environment) {
|
||||
const vars = get(environment, 'variables', []);
|
||||
@ -92,7 +91,6 @@ const GenerateCodeItem = ({ collection, item, onClose }) => {
|
||||
collectionVariables: collection.collectionVariables,
|
||||
processEnvVars: collection.processEnvVariables
|
||||
});
|
||||
|
||||
const [selectedLanguage, setSelectedLanguage] = useState(languages[0]);
|
||||
return (
|
||||
<Modal size="lg" title="Generate Code" handleCancel={onClose} hideFooter={true}>
|
||||
@ -121,10 +119,16 @@ const GenerateCodeItem = ({ collection, item, onClose }) => {
|
||||
language={selectedLanguage}
|
||||
item={{
|
||||
...item,
|
||||
request: {
|
||||
...item.request,
|
||||
url: interpolatedUrl
|
||||
}
|
||||
request:
|
||||
item.request.url !== ''
|
||||
? {
|
||||
...item.request,
|
||||
url: interpolatedUrl
|
||||
}
|
||||
: {
|
||||
...item.draft.request,
|
||||
url: interpolatedUrl
|
||||
}
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
|
@ -21,7 +21,7 @@ import { isItemARequest, isItemAFolder, itemIsOpenedInTabs } from 'utils/tabs';
|
||||
import { doesRequestMatchSearchText, doesFolderHaveItemsMatchSearchText } from 'utils/collections/search';
|
||||
import { getDefaultRequestPaneTab } from 'utils/collections';
|
||||
import { hideHomePage } from 'providers/ReduxStore/slices/app';
|
||||
|
||||
import toast from 'react-hot-toast';
|
||||
import StyledWrapper from './StyledWrapper';
|
||||
|
||||
const CollectionItem = ({ item, collection, searchText }) => {
|
||||
@ -148,7 +148,15 @@ const CollectionItem = ({ item, collection, searchText }) => {
|
||||
const sortFolderItems = (items = []) => {
|
||||
return items.sort((a, b) => a.name.localeCompare(b.name));
|
||||
};
|
||||
|
||||
const handleGenerateCode = (e) => {
|
||||
e.stopPropagation();
|
||||
dropdownTippyRef.current.hide();
|
||||
if (item.request.url !== '' || (item.draft?.request.url !== undefined && item.draft?.request.url !== '')) {
|
||||
setGenerateCodeItemModalOpen(true);
|
||||
} else {
|
||||
toast.error('URL is required');
|
||||
}
|
||||
};
|
||||
const requestItems = sortRequestItems(filter(item.items, (i) => isItemARequest(i)));
|
||||
const folderItems = sortFolderItems(filter(item.items, (i) => isItemAFolder(i)));
|
||||
|
||||
@ -279,9 +287,7 @@ const CollectionItem = ({ item, collection, searchText }) => {
|
||||
<div
|
||||
className="dropdown-item"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
dropdownTippyRef.current.hide();
|
||||
setGenerateCodeItemModalOpen(true);
|
||||
handleGenerateCode(e);
|
||||
}}
|
||||
>
|
||||
Generate Code
|
||||
|
Loading…
Reference in New Issue
Block a user