Change the export file extension type

Summary: This diff imports and exports data in a `.flipper` file extension. This diff also adds the support to open flipper app by double clicking on the `.flipper` file.

Reviewed By: danielbuechele

Differential Revision: D14042846

fbshipit-source-id: 17e6b55bf2796d9abdf985411fce799600f7792b
This commit is contained in:
Pritesh Nandgaonkar
2019-02-12 06:45:07 -08:00
committed by Facebook Github Bot
parent 73b816de16
commit 029377a849
7 changed files with 31 additions and 3 deletions

View File

@@ -23,7 +23,15 @@
"win": { "win": {
"publisherName": "Facebook, Inc." "publisherName": "Facebook, Inc."
}, },
"asar": false "asar": false,
"fileAssociations": [
{
"ext": [".flipper"],
"name": "Flipper Data",
"role": "Viewer",
"icon": "document-icons/document.icns"
}
]
}, },
"resolutions": { "resolutions": {
"@jest-runner/electron/electron": "3.0.0" "@jest-runner/electron/electron": "3.0.0"

View File

@@ -326,7 +326,7 @@ function getTemplate(
null, null,
{ {
title: 'FlipperExport', title: 'FlipperExport',
defaultPath: path.join(os.homedir(), 'FlipperExport.json'), defaultPath: path.join(os.homedir(), 'FlipperExport.flipper'),
}, },
file => { file => {
exportStoreToFile(file, store); exportStoreToFile(file, store);

View File

@@ -9,7 +9,7 @@ import {remote, ipcRenderer} from 'electron';
import type {Store} from '../reducers/index.js'; import type {Store} from '../reducers/index.js';
import type Logger from '../fb-stubs/Logger.js'; import type Logger from '../fb-stubs/Logger.js';
import {parseFlipperPorts} from '../utils/environmentVariables'; import {parseFlipperPorts} from '../utils/environmentVariables';
import {importFileToStore} from '../utils/exportData';
import {selectPlugin, userPreferredPlugin} from '../reducers/connections'; import {selectPlugin, userPreferredPlugin} from '../reducers/connections';
export const uriComponents = (url: string) => { export const uriComponents = (url: string) => {
if (!url) { if (!url) {
@@ -55,6 +55,11 @@ export default (store: Store, logger: Logger) => {
); );
} }
}); });
ipcRenderer.on('open-flipper-file', (event, url) => {
importFileToStore(url, store);
});
ipcRenderer.on('flipper-deeplink-preferred-plugin', (event, url) => { ipcRenderer.on('flipper-deeplink-preferred-plugin', (event, url) => {
// flipper://<client>/<pluginId>/<payload> // flipper://<client>/<pluginId>/<payload>
const match = uriComponents(url); const match = uriComponents(url);

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View File

@@ -66,6 +66,7 @@ let win;
let appReady = false; let appReady = false;
let pluginsCompiled = false; let pluginsCompiled = false;
let deeplinkURL = null; let deeplinkURL = null;
let filePath = null;
// tracking // tracking
setInterval(() => { setInterval(() => {
@@ -122,6 +123,15 @@ app.on('will-finish-launching', () => {
win.webContents.send('flipper-deeplink', deeplinkURL); win.webContents.send('flipper-deeplink', deeplinkURL);
} }
}); });
app.on('open-file', (event, path) => {
// When flipper app is running, and someone double clicks the import file, `componentDidMount` will not be called again and windows object will exist in that case. That's why calling `win.webContents.send('open-flipper-file', filePath);` again.
event.preventDefault();
filePath = path;
if (win) {
win.webContents.send('open-flipper-file', filePath);
filePath = null;
}
});
}); });
app.on('ready', function() { app.on('ready', function() {
@@ -145,6 +155,11 @@ ipcMain.on('componentDidMount', event => {
win.webContents.send('flipper-deeplink-preferred-plugin', deeplinkURL); win.webContents.send('flipper-deeplink-preferred-plugin', deeplinkURL);
deeplinkURL = null; deeplinkURL = null;
} }
if (filePath) {
// When flipper app is not running, the windows object might not exist in the callback of `open-file`, but after ``componentDidMount` it will definitely exist.
win.webContents.send('open-flipper-file', filePath);
filePath = null;
}
}); });
ipcMain.on('getLaunchTime', event => { ipcMain.on('getLaunchTime', event => {