Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr 3734 improved #3829

Draft
wants to merge 26 commits into
base: feat/raw-file-body
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
844cc61
feat: add binary option in dropdown
marcosadsj Dec 18, 2024
3773cd7
feat: add resquest pane binary component
marcosadsj Dec 18, 2024
ec30fdd
refactor: prepare filepicker to choose only a single file
marcosadsj Dec 18, 2024
abb0cd9
feat: load file to send int request body
marcosadsj Dec 18, 2024
20b9adf
feat: complete all request cycle
marcosadsj Dec 29, 2024
45812a5
feat: add tests to binary file
marcosadsj Dec 29, 2024
b50841c
fix: remove binaryfiles from watch
marcosadsj Dec 29, 2024
e6cf24c
fix: add hydrate uuid to binary file
marcosadsj Dec 30, 2024
2dbb04d
fix: correct file path
marcosadsj Dec 30, 2024
b8b16a0
feat: create http request with binary file from curl
marcosadsj Jan 1, 2025
d0be1d0
fix: add state to handle local changes in radio group
marcosadsj Jan 6, 2025
0e3ce96
Merge branch 'main' into feat/binary-body
marcosadsj Jan 6, 2025
7711ae0
Merge branch 'main' into feat/binary-body
marcosadsj Jan 6, 2025
69a6034
fix: correct input type in styles
marcosadsj Jan 6, 2025
06e78f2
refactor: remove logs
marcosadsj Jan 6, 2025
8cce27c
fix: make codegenerator not crash
marcosadsj Jan 6, 2025
07690b1
fix: parse to json instead o buffer when content-type matchs
marcosadsj Jan 8, 2025
a0cb8d3
Merge branch 'main' into pr-3734
sanjaikumar-bruno Jan 16, 2025
cd59d3e
refactor: update `httpsnippet` version to `3.0.9` and enhance createP…
sanjaikumar-bruno Jan 16, 2025
dab4bb6
fix: hide env dropdown on configure (#3826)
naman-bruno Jan 17, 2025
3e6204e
Fix: Horizontal Rules missing in markdown docs preview (#3814)
naman-bruno Jan 17, 2025
8a71dfc
enhancement: moved collection click area from name to div (#3813)
naman-bruno Jan 17, 2025
53dfc20
refactor: simplify browseFiles function and IPC handler by removing u…
sanjaikumar-bruno Jan 17, 2025
99ca900
Merge branch 'pr-3734-improved' into feat/raw-file-body
sanjaikumar-bruno Jan 17, 2025
31b2818
fix: modal - provide default handleConfirm function and update depend…
sanish-bruno Jan 17, 2025
80250e2
Merge branch 'main' of https://github.com/usebruno/bruno into pr-3734…
sanjaikumar-bruno Jan 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/bruno-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"graphiql": "3.7.1",
"graphql": "^16.6.0",
"graphql-request": "^3.7.0",
"httpsnippet": "^3.0.6",
"httpsnippet": "^3.0.9",
"i18next": "24.1.2",
"idb": "^7.0.0",
"immer": "^9.0.15",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ const EnvironmentSelector = ({ collection }) => {
<IconDatabaseOff size={18} strokeWidth={1.5} />
<span className="ml-2">No Environment</span>
</div>
<div className="dropdown-item border-top" onClick={handleSettingsIconClick}>
<div className="dropdown-item border-top" onClick={() => {
handleSettingsIconClick();
dropdownTippyRef.current.hide();
}}>
<div className="pr-2 text-gray-600">
<IconSettings size={18} strokeWidth={1.5} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const StyledMarkdownBodyWrapper = styled.div`
height: 1px;
padding: 0;
margin: 24px 0;
background-color: var(--color-border-default);
background-color: var(--color-sidebar-collection-item-active-indent-border);
border: 0;
}

Expand Down
6 changes: 3 additions & 3 deletions packages/bruno-app/src/components/Modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const Modal = ({
confirmText,
cancelText,
handleCancel,
handleConfirm,
handleConfirm = () => {},
children,
confirmDisabled,
hideCancel,
Expand Down Expand Up @@ -92,7 +92,7 @@ const Modal = ({
};

useFocusTrap(modalRef);

const closeModal = (args) => {
setIsClosing(true);
setTimeout(() => handleCancel(args), closeModalFadeTimeout);
Expand All @@ -103,7 +103,7 @@ const Modal = ({
return () => {
document.removeEventListener('keydown', handleKeydown);
};
}, [disableEscapeKey, document]);
}, [disableEscapeKey, document, handleConfirm]);

let classes = 'bruno-modal';
if (isClosing) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ const Collection = ({ collection, searchText }) => {
<div className="flex py-1 collection-name items-center" ref={drop}>
<div
className="flex flex-grow items-center overflow-hidden"
onClick={handleCollapseCollection}
onContextMenu={handleRightClick}
>
<IconChevronRight
size={16}
Expand All @@ -160,9 +162,7 @@ const Collection = ({ collection, searchText }) => {
style={{ width: 16, minWidth: 16, color: 'rgb(160 160 160)' }}
onClick={handleClick}
/>
<div className="ml-1" id="sidebar-collection-name"
onClick={handleCollapseCollection}
onContextMenu={handleRightClick}>
<div className="ml-1" id="sidebar-collection-name">
{collection.name}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const ImportCollection = ({ onClose, handleSubmit }) => {
);
};
return (
<Modal size="sm" title="Import Collection" hideFooter={true} handleConfirm={onClose} handleCancel={onClose}>
<Modal size="sm" title="Import Collection" hideFooter={true} handleCancel={onClose}>
<div className="flex flex-col">
<h3 className="text-sm">Select the type of your existing collection :</h3>
<div className="mt-4 grid grid-rows-2 grid-flow-col gap-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1041,11 +1041,14 @@ export const browseDirectory = () => (dispatch, getState) => {

export const browseFiles =
(filters = [], properties = ['multiSelections']) =>
(dispatch, getState) => {
(_, _) => {
const { ipcRenderer } = window;

return new Promise((resolve, reject) => {
ipcRenderer.invoke('renderer:browse-files', undefined, undefined, undefined, filters, properties).then(resolve).catch(reject);
ipcRenderer
.invoke('renderer:browse-files', filters, properties)
.then(resolve)
.catch(reject);
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,19 +865,27 @@ export const collectionsSlice = createSlice({
}
}
},
moveMultipartFormParam: (state, action) => {
// Ensure item.draft is a deep clone of item if not already present
if (!item.draft) {
item.draft = cloneDeep(item);
}
moveMultipartFormParam: (state, action) => {
const collection = findCollectionByUid(state.collections, action.payload.collectionUid);

if (collection) {
const item = findItemInCollection(collection, action.payload.itemUid);

if (item && isItemARequest(item)) {
// Ensure item.draft is a deep clone of item if not already present
if (!item.draft) {
item.draft = cloneDeep(item);
}

// Extract payload data
const { updateReorderedItem } = action.payload;
const params = item.draft.request.body.multipartForm;
// Extract payload data
const { updateReorderedItem } = action.payload;
const params = item.draft.request.body.multipartForm;

item.draft.request.body.multipartForm = updateReorderedItem.map((uid) => {
return params.find((param) => param.uid === uid);
});
item.draft.request.body.multipartForm = updateReorderedItem.map((uid) => {
return params.find((param) => param.uid === uid);
});
}
}
},
addBinaryFile: (state, action) => {
const collection = findCollectionByUid(state.collections, action.payload.collectionUid);
Expand Down
22 changes: 18 additions & 4 deletions packages/bruno-app/src/utils/codegenerator/har.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ const createPostData = (body, type) => {

switch (body.mode) {
case 'formUrlEncoded':
return {
mimeType: contentType,
text: new URLSearchParams(
body[body.mode]
.filter((param) => param.enabled)
.reduce((acc, param) => {
acc[param.name] = param.value;
return acc;
}, {})
).toString(),
params: body[body.mode]
.filter((param) => param.enabled)
.map((param) => ({
name: param.name,
value: param.value
}))
};
case 'multipartForm':
return {
mimeType: contentType,
Expand All @@ -78,8 +95,7 @@ const createPostData = (body, type) => {
};
case 'binaryFile':
const binary = {
mimeType: 'application/octet-stream',
// mimeType: body[body.mode].filter((param) => param.enabled)[0].contentType,
mimeType: body[body.mode].filter((param) => param.enabled)[0].contentType,
params: body[body.mode]
.filter((param) => param.enabled)
.map((param) => ({
Expand All @@ -88,8 +104,6 @@ const createPostData = (body, type) => {
fileName: param.value
}))
};

console.log('curl-binary', binary);
return binary;
default:
return {
Expand Down
9 changes: 3 additions & 6 deletions packages/bruno-electron/src/ipc/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,11 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
});

// browse directory for file
ipcMain.handle('renderer:browse-files', async (event, pathname, request, filters, properties) => {
ipcMain.handle('renderer:browse-files', async (_, filters, properties) => {
try {

const filePaths = await browseFiles(mainWindow, filters, properties);

return filePaths;
return await browseFiles(mainWindow, filters, properties);
} catch (error) {
return Promise.reject(error);
throw error;
}
});

Expand Down