mirror of
https://github.com/usebruno/bruno.git
synced 2025-06-20 11:48:03 +02:00
* fix collection headers in code generator * remove logs
This commit is contained in:
parent
d62982d52d
commit
d0c25d46c9
@ -8,12 +8,20 @@ import { useSelector } from 'react-redux';
|
|||||||
import { CopyToClipboard } from 'react-copy-to-clipboard';
|
import { CopyToClipboard } from 'react-copy-to-clipboard';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import { IconCopy } from '@tabler/icons';
|
import { IconCopy } from '@tabler/icons';
|
||||||
|
import { findCollectionByItemUid } from '../../../../../../../utils/collections/index';
|
||||||
|
|
||||||
const CodeView = ({ language, item }) => {
|
const CodeView = ({ language, item }) => {
|
||||||
const { storedTheme } = useTheme();
|
const { storedTheme } = useTheme();
|
||||||
const preferences = useSelector((state) => state.app.preferences);
|
const preferences = useSelector((state) => state.app.preferences);
|
||||||
const { target, client, language: lang } = language;
|
const { target, client, language: lang } = language;
|
||||||
const headers = item.draft ? get(item, 'draft.request.headers') : get(item, 'request.headers');
|
const requestHeaders = item.draft ? get(item, 'draft.request.headers') : get(item, 'request.headers');
|
||||||
|
const collection = findCollectionByItemUid(
|
||||||
|
useSelector((state) => state.collections.collections),
|
||||||
|
item.uid
|
||||||
|
);
|
||||||
|
|
||||||
|
const headers = [...collection?.root?.request?.headers, ...requestHeaders];
|
||||||
|
|
||||||
let snippet = '';
|
let snippet = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -91,6 +91,12 @@ export const findCollectionByPathname = (collections, pathname) => {
|
|||||||
return find(collections, (c) => c.pathname === pathname);
|
return find(collections, (c) => c.pathname === pathname);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const findCollectionByItemUid = (collections, itemUid) => {
|
||||||
|
return find(collections, (c) => {
|
||||||
|
return findItemInCollection(c, itemUid);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export const findItemByPathname = (items = [], pathname) => {
|
export const findItemByPathname = (items = [], pathname) => {
|
||||||
return find(items, (i) => i.pathname === pathname);
|
return find(items, (i) => i.pathname === pathname);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user