mirror of
https://github.com/usebruno/bruno.git
synced 2025-01-22 05:38:40 +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) => {
|
export const updateBrunoConfig = (brunoConfig, collectionUid) => (dispatch, getState) => {
|
||||||
const state = 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.params'), (param) => (param.uid = uuid()));
|
||||||
each(get(item, 'request.body.multipartForm'), (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.formUrlEncoded'), (param) => (param.uid = uuid()));
|
||||||
each(get(item, 'request.body.rawFile'), (param) => (param.uid = uuid()));
|
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
};
|
};
|
||||||
|
@ -11,6 +11,7 @@ const {
|
|||||||
isDirectory,
|
isDirectory,
|
||||||
browseDirectory,
|
browseDirectory,
|
||||||
browseFiles,
|
browseFiles,
|
||||||
|
browseFile,
|
||||||
createDirectory,
|
createDirectory,
|
||||||
searchForBruFiles,
|
searchForBruFiles,
|
||||||
sanitizeDirectoryName
|
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
|
// create collection
|
||||||
ipcMain.handle(
|
ipcMain.handle(
|
||||||
'renderer:create-collection',
|
'renderer:create-collection',
|
||||||
|
@ -116,6 +116,17 @@ const browseFiles = async (win, filters) => {
|
|||||||
return filePaths.map((path) => normalizeAndResolvePath(path)).filter((path) => isFile(path));
|
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 chooseFileToSave = async (win, preferredFileName = '') => {
|
||||||
const { filePath } = await dialog.showSaveDialog(win, {
|
const { filePath } = await dialog.showSaveDialog(win, {
|
||||||
defaultPath: preferredFileName
|
defaultPath: preferredFileName
|
||||||
@ -161,6 +172,7 @@ module.exports = {
|
|||||||
createDirectory,
|
createDirectory,
|
||||||
browseDirectory,
|
browseDirectory,
|
||||||
browseFiles,
|
browseFiles,
|
||||||
|
browseFile,
|
||||||
chooseFileToSave,
|
chooseFileToSave,
|
||||||
searchForFiles,
|
searchForFiles,
|
||||||
searchForBruFiles,
|
searchForBruFiles,
|
||||||
|
Loading…
Reference in New Issue
Block a user