mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-28 07:04:10 +00:00
* feat: inline create collection and workspace editor * refactor: use inline collection creation from workspace overview * fix: improve inline collection creation UX from workspace overview * fix: update E2E tests for inline collection creation flow * fix: update default location test for inline collection creation flow * fix: derive inline workspace/collection names from filesystem * feat: inline workspace create form manage workspace * feat: prefill create modal with name * fix: minor code style fixes --------- Co-authored-by: naman-bruno <naman@usebruno.com>
62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
const { ipcMain } = require('electron');
|
|
const path = require('node:path');
|
|
|
|
const {
|
|
browseDirectory,
|
|
browseFiles,
|
|
normalizeAndResolvePath,
|
|
isFile,
|
|
isDirectory
|
|
} = require('../utils/filesystem');
|
|
const { findUniqueFolderName } = require('../utils/collection-import');
|
|
|
|
const registerFilesystemIpc = (mainWindow) => {
|
|
ipcMain.handle('renderer:browse-directory', async (event, pathname, request) => {
|
|
try {
|
|
return await browseDirectory(mainWindow);
|
|
} catch (error) {
|
|
return Promise.reject(error);
|
|
}
|
|
});
|
|
|
|
ipcMain.handle('renderer:browse-files', async (_, filters, properties) => {
|
|
try {
|
|
return await browseFiles(mainWindow, filters, properties);
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
ipcMain.handle('renderer:exists-sync', async (_, filePath) => {
|
|
try {
|
|
const normalizedPath = normalizeAndResolvePath(filePath);
|
|
return isFile(normalizedPath);
|
|
} catch (error) {
|
|
return false;
|
|
}
|
|
});
|
|
|
|
ipcMain.handle('renderer:resolve-path', async (_, relativePath, basePath) => {
|
|
try {
|
|
const resolvedPath = path.resolve(basePath, relativePath);
|
|
return normalizeAndResolvePath(resolvedPath);
|
|
} catch (error) {
|
|
return relativePath;
|
|
}
|
|
});
|
|
|
|
ipcMain.handle('renderer:is-directory', async (_, pathname) => {
|
|
return isDirectory(pathname);
|
|
});
|
|
|
|
ipcMain.handle('renderer:find-unique-folder-name', async (_, baseName, location) => {
|
|
try {
|
|
return await findUniqueFolderName(baseName, location);
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
});
|
|
};
|
|
|
|
module.exports = registerFilesystemIpc;
|