mirror of
https://github.com/usebruno/bruno.git
synced 2025-01-21 13:18:41 +01:00
Added logic to select only one file.
This commit is contained in:
parent
145de02733
commit
b54b5ff19a
@ -1014,6 +1014,16 @@ export const browseFiles =
|
||||
});
|
||||
};
|
||||
|
||||
export const browseFile =
|
||||
(filters = []) =>
|
||||
(dispatch, getState) => {
|
||||
const { ipcRenderer } = window;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
ipcRenderer.invoke('renderer:browse-file', filters).then(resolve).catch(reject);
|
||||
});
|
||||
};
|
||||
|
||||
export const updateBrunoConfig = (brunoConfig, collectionUid) => (dispatch, getState) => {
|
||||
const state = getState();
|
||||
|
||||
|
@ -698,7 +698,6 @@ export const refreshUidsInItem = (item) => {
|
||||
each(get(item, 'request.params'), (param) => (param.uid = uuid()));
|
||||
each(get(item, 'request.body.multipartForm'), (param) => (param.uid = uuid()));
|
||||
each(get(item, 'request.body.formUrlEncoded'), (param) => (param.uid = uuid()));
|
||||
each(get(item, 'request.body.rawFile'), (param) => (param.uid = uuid()));
|
||||
|
||||
return item;
|
||||
};
|
||||
|
@ -11,6 +11,7 @@ const {
|
||||
isDirectory,
|
||||
browseDirectory,
|
||||
browseFiles,
|
||||
browseFile,
|
||||
createDirectory,
|
||||
searchForBruFiles,
|
||||
sanitizeDirectoryName
|
||||
@ -50,6 +51,17 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
||||
}
|
||||
});
|
||||
|
||||
// browse directory for one file
|
||||
ipcMain.handle('renderer:browse-file', async (event, pathname, request, filters) => {
|
||||
try {
|
||||
const filePath = await browseFile(mainWindow, filters);
|
||||
|
||||
return filePath;
|
||||
} catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
});
|
||||
|
||||
// create collection
|
||||
ipcMain.handle(
|
||||
'renderer:create-collection',
|
||||
|
@ -116,6 +116,17 @@ const browseFiles = async (win, filters) => {
|
||||
return filePaths.map((path) => normalizeAndResolvePath(path)).filter((path) => isFile(path));
|
||||
};
|
||||
|
||||
const browseFile = async (win, filters) => {
|
||||
const { filePath } = await dialog.showOpenDialog(win, {
|
||||
properties: ['openFile'],
|
||||
filters
|
||||
});
|
||||
|
||||
if(!filePath) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const chooseFileToSave = async (win, preferredFileName = '') => {
|
||||
const { filePath } = await dialog.showSaveDialog(win, {
|
||||
defaultPath: preferredFileName
|
||||
@ -161,6 +172,7 @@ module.exports = {
|
||||
createDirectory,
|
||||
browseDirectory,
|
||||
browseFiles,
|
||||
browseFile,
|
||||
chooseFileToSave,
|
||||
searchForFiles,
|
||||
searchForBruFiles,
|
||||
|
Loading…
Reference in New Issue
Block a user