Remove fs.write from plugins
Summary: 1. Remove "fs.writeFile" from plugins 2. Remove "showSaveDialog" from "FlipperLib" 3. Add "exportFile" to "FlipperLib" and "RenderHost" As we are going to use Flipper in a browser as well, instead of providing low-level abstraction like "showSaveDialog", we should provide more high-level ones like "exportFile". In browsers it does not make too much sense to expose "showSaveDialog" as there is not way to use the returned file path to write to it. In the end, "exportFile" is going to trigger a file download for browsers and show the save dialog and write to the returned file path for Electron. Reviewed By: mweststrate Differential Revision: D32492149 fbshipit-source-id: 0673119bdb7670a5872f5982c7d82dfc44eb7906
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1b54a079f5
commit
2c7bc0a952
@@ -173,27 +173,9 @@ export function createNetworkManager(
|
||||
},
|
||||
exportRoutes() {
|
||||
getFlipperLib()
|
||||
.showSaveDialog?.({
|
||||
title: 'Export Routes',
|
||||
.exportFile(JSON.stringify(Object.values(routes.get()), null, 2), {
|
||||
defaultPath: 'NetworkPluginRoutesExport.json',
|
||||
})
|
||||
.then((file) => {
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
fs.writeFile(
|
||||
file,
|
||||
JSON.stringify(Object.values(routes.get()), null, 2),
|
||||
'utf8',
|
||||
(err) => {
|
||||
if (err) {
|
||||
message.error('Failed to store mock routes: ' + err);
|
||||
} else {
|
||||
message.info('Successfully exported mock routes');
|
||||
}
|
||||
},
|
||||
);
|
||||
})
|
||||
.catch((e) =>
|
||||
console.error('[network] exportRoutes saving failed:', e),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user