Commit Graph

31 Commits

Author SHA1 Message Date
Pritesh Nandgaonkar
fd022e3c73 Improvise UI of crash reporter plugin
Summary:
- New improved UI
- Instead of sending the callstack as a string from android, now sending it as an array
- Deeplink to Logs support just for android. In iOS crash is not automatically logged in Logs plugin, atleast thats what happens in sample app

Reviewed By: jknoxville

Differential Revision: D13216477

fbshipit-source-id: d8b77549c83572d0442e431ce88a8f01f42c9565
2018-11-30 05:28:46 -08:00
Panagiotis Vekris
e380fa7a08 Flow v0.86.0 in xplat/sonar
Summary: allow-large-files

Reviewed By: gabelevi, dsainati1

Differential Revision: D13105210

fbshipit-source-id: 462af926206a10618a725531f2e62da9f3291fc0
2018-11-19 12:14:51 -08:00
Panagiotis Vekris
b2b27b774e Back out "Flow v0.86.0 in xplat/sonar"
Summary: Original commit changeset: f0122c8c6d60

Reviewed By: avielg

Differential Revision: D13083312

fbshipit-source-id: 4b77fda5221feff5c721bb8a509b1350d60046d5
2018-11-15 08:24:00 -08:00
Daniel Büchele
7747a0714d plugin redux
Summary:
Plugins were loaded in `/plugins/index.js` which was loaded once at launch of the app. This moves the list of available plugins to redux. This way, plugins can be dynamically added. The redux store keeps to Maps of plugins (devicePlugins and clientPlugins) with their ID as key:

```
  devicePlugins: Map<string, Class<FlipperDevicePlugin<>>>,
  clientPlugins: Map<string, Class<FlipperPlugin<>>>,
```

On launch of the app, all plugins bundled with the app and the one found in `pluginsPath` are dynamically added.

This changes now allows to add new plugins at any time. All components that need to know which plugins are available (e.g. the sidebar) are connected to the redux store. This way, they will automatically update, whenever a new plugin is added.

- add `plugins` to the redux store to keep the list of available plugins
- add a plugins dispatcher, responsible for loading the plugins on launch
- connecting all React components that imported `plugins/index.js` before to the redux store to get the plugins from there.
- moved the updating of the MenuBar to the plugins dispatcher as it needs to update whenever a new plugin is added.

Reviewed By: jknoxville, passy

Differential Revision: D12449236

fbshipit-source-id: 6ef3e243e2c80443614b901ccbfde485fcb4301c
2018-11-15 07:30:05 -08:00
Panagiotis Vekris
6362188563 Flow v0.86.0 in xplat/sonar
Summary: allow-large-files

Reviewed By: zertosh

Differential Revision: D13067587

fbshipit-source-id: f0122c8c6d602750289121d2ab2fdb09cbb033bc
2018-11-14 15:39:25 -08:00
Daniel Büchele
7b9bd8560e update PluginContainer to new React API
Summary: React has a built in API for computing the state from props called `getDerivedStateFromProps`. So let's use this instead of our custom implementation.

Reviewed By: jknoxville

Differential Revision: D10484213

fbshipit-source-id: 4c434c5252dabfc2f6015cb6a50719b985c60446
2018-10-22 06:59:52 -07:00
Daniel Büchele
86c796a706 adding selectPlugin API to plugins
Summary:
Allow linking from one plugin to another. Adds a prop `selectPlugin` to the plugin that can be passed a pluginID and an optional `deepLinkPayload`.

The return value tells you if switching the plugin was successful.

```
selectPlugin: (pluginID: string, deepLinkPayload: ?string) => boolean,
```

Reviewed By: passy

Differential Revision: D10483925

fbshipit-source-id: 6f821277150b2db185b7d545c310214a11432eac
2018-10-22 06:59:52 -07:00
Daniel Büchele
4090c2d096 defaultPersistedState
Summary: adding a `static defaultPersistedState` which plugins can use to populate their persistedState for the first render.

Reviewed By: passy

Differential Revision: D10446987

fbshipit-source-id: eb37553db7bbec31edf5b4972176e71f303639fe
2018-10-19 05:14:17 -07:00
Daniel Büchele
51f70fd78c call notifications API
Summary:
Adding a static method plugins can implement to trigger notifications:

```
static getActiveNotifications: ?(persistedState: P) => Array<Notification>;
```

When the plugin's persisted state changes, this API is called from the `notification`-dispatcher which updates the notifications store.

Reviewed By: passy

Differential Revision: D10378434

fbshipit-source-id: 778fe3ad4229b03bd5ba14ebfdafa5020c25f34f
2018-10-18 02:47:52 -07:00
Daniel Büchele
22e3017cdc move NotificationHub from plugins to main folder
Summary: As all device plugins are now moved to the plugins folder, this was the last thing in this folder. I am moving it out and putting it next to the core UI parts of the app.

Reviewed By: jknoxville

Differential Revision: D10337838

fbshipit-source-id: 6fa699c28e5df8a53719179fbb760f2a140bafc4
2018-10-15 02:59:37 -07:00
Pascal Hartig
01020edbf2 Restore computeNotifications
Summary:
Restore the logic for setting and computing notifications that was
partially removed with D10300838.

Reviewed By: jknoxville

Differential Revision: D10361547

fbshipit-source-id: 4d229d5f4dbeda3139463e1c348909b9c5dba66f
2018-10-13 04:18:11 -07:00
Pritesh Nandgaonkar
ac7980993c FlipperBackgroundPlugin
Summary:
Adds a new type of plugin: `FlipperBackgroundPlugin`
Background plugins are not torn down when the user switches to another plugin so they keep receiving messages in the background.

Background plugins need to use persistedState to keep their data. To handle the messages received in the background they need to implement a static method that merges a message with the current state from redux. The plugin doesn't need to call this method itself, it is called from `client.js`.

```static persistedStateReducer = (
    persistedState: PersistedState,
    data: Object,
  ): PersistedState
```

This method is used to handle messages in both foreground and background.

Reviewed By: danielbuechele

Differential Revision: D10256305

fbshipit-source-id: d86da9caa1b75178841a9a347eb427112141eaa3
2018-10-11 15:23:21 -07:00
Pritesh Nandgaonkar
5bbfa58909 Setup sdk for background plugin
Summary:
This diff sets up flipper for running plugins in background. This diff does the following

- Adds a function named `runInBackground` to the interface `FlipperPlugin` to make the plugins opt in to be run in background, default is false
- Changes the javascript side of the flipper to store the messages received by the plugins in background
- Process the stored messages when the plugin in background becomes active
- Currently I have just turned on network plugin to be in background mode.

- Remove the buffering from the network plugin, as it will run in background
- Write a batching layer to batch the messages and send to flipper.

Note: I haven't tested the wilde app yet, but the sample app works. I will remove the "[WIP]" from the title once I have tested it in wilde

Reviewed By: danielbuechele

Differential Revision: D10301403

fbshipit-source-id: 034eebf659a545d6b480a4ac1b73b0aa4b2f9797
2018-10-11 15:23:21 -07:00
Alex Langenfeld
f3d2e0983e support user defined device plugins
Summary:
* move CPU and Logs plugin to plugins directory, set up package.json for them
* adjust plugins/index.js to expose device and client plugins in the same place, adding two new exports

Reviewed By: danielbuechele

Differential Revision: D10247606

fbshipit-source-id: 347bf8b3f9629987ad29d1d2ed025e0c88b9c967
2018-10-10 18:43:21 -07:00
Daniel Büchele
78252b2ef2 adding UI
Summary:
- Adds the Flipper notifications UI from the hackweek
- The notifications plugin is hidden behind a GK `flipper_notifications`
- Plugins currently can not dispatch any notifications

Reviewed By: jknoxville, passy

Differential Revision: D10300838

fbshipit-source-id: 2a3a823f09fee3370ce725b506b162e57751c382
2018-10-10 10:41:09 -07:00
John Knox
6df906ed5f Add computeNotifications method to FlipperBasePlugin
Summary:
Method `computeNotifications` added to the base plugin class.
Plugins should implement this to define a mapping from their state+props to the notifications they are emitting.

I've plugged this into componentDidUpdate, because we don't yet have the background plugin infra. When we do, we'll want some other incoming data hook to use so it's not tied to the react component rendering.

Example usage added to network plugin in the next commit.

Reviewed By: passy

Differential Revision: D10127875

fbshipit-source-id: efd4d8cfc0d3d33852a6cf9a290549a5f90d389d
2018-10-09 08:27:06 -07:00
Daniel Büchele
df0a0da744 DetailSidebar
Summary:
- rename `SonarSidebar` to `DetailSidebar`
- rename portal id from `#sonarSidebar` to `#detailSidebar`

Reviewed By: passy

Differential Revision: D9851703

fbshipit-source-id: 2d904d17b0c6255a2ec3a79f0ada9bf621693c2e
2018-09-18 07:01:16 -07:00
Daniel Büchele
66e77075be Rename package to 'flipper'
Summary:
- rename package `'sonar'` > `'flipper'`
- rename package `'sonar-static'` > `'flipper-static'`
- rename package export from `window.Sonar` to `window.Flipper`

Reviewed By: passy

Differential Revision: D9851181

fbshipit-source-id: 34d4447c3b287496b3d20ddb54471ce777ec74e1
2018-09-18 07:01:16 -07:00
Daniel Büchele
2e2924c979 SonarPlugin > FlipperPlugin
Summary:
Renaming:
- `SonarPlugin` > `FlipperPlugin`
- `SonarBasePlugin` > `FlipperBasePlugin`
- `SonarDevicePlugin` > `FlipperDevicePlugin`

Reviewed By: passy

Differential Revision: D9851075

fbshipit-source-id: d59df6952a42eb493c86c38895216c9985f1e14b
2018-09-18 07:01:16 -07:00
Daniel Büchele
afdc846a8b log listener
Summary:
The logs plugin opened a new log connection every time it was activated and never closed the connection.

This is now changed. Once a device is connected, a log connection is opened. The logs plugin subscribes and unsubscribes to this connection. This allows the logs plugin it even access the logs from when it was not activated and ensures to only open on connection to read the logs. Logs are persisted when switching away from the plugin.

Also removes the spinner from the logs plugin, as it loads much faster now.

Reviewed By: jknoxville

Differential Revision: D9613054

fbshipit-source-id: e37ea56c563450e7fc4e3c85a015292be1f2dbfc
2018-08-31 10:13:06 -07:00
Daniel Büchele
726966fdc0 convert to emotion
Summary:
My benchmarks have shown react-emotion to be faster than the current implementation of `styled`. For this reason, I am converting all styling to [emotion](https://emotion.sh).

Benchmark results:
{F136839093}

The syntax is very similar between the two libraries. The main difference is that emotion only allows a single function for the whole style attribute, whereas the old implementation had functions for every style-attirbute.

Before:
```
{
  color: props => props.color,
  fontSize: props => props.size,
}
```

After:
```
props => ({
  color: props.color,
  fontSize: props.size,
})
```

Reviewed By: jknoxville

Differential Revision: D9479893

fbshipit-source-id: 2c39e4618f7e52ceacb67bbec8ae26114025723f
2018-08-23 09:42:18 -07:00
Daniel Büchele
eb316be4e4 fixing tracking metrics
Summary:
- fixing dropped frames calculation
- fixing plugin activation time

Reviewed By: passy

Differential Revision: D9301759

fbshipit-source-id: 872e4d2edcafdbc67668f3d0b713dfbf55f068f5
2018-08-13 15:27:29 -07:00
Daniel Büchele
faf8afe9cd Track plugin activation time
Summary: Track the time from when the plugin is selected until its `init()` function finishes.

Reviewed By: passy

Differential Revision: D9239750

fbshipit-source-id: 569f236c9d58f70548f1ba6bf31a96047dcc8245
2018-08-10 09:41:47 -07:00
Daniel Büchele
1f977f4844 Store use selected plugin after reconnect
Summary:
Deselect plugin when app disconnects, but store the information that the users had the app selected. When the app conencts again, restore the user's selection.
This also stores the device seleced by the user and reselects the device if it connects.

Reviewed By: xiphirx

Differential Revision: D8833948

fbshipit-source-id: ad3ef54681550ae674bdd4e695d677aea5c14588
2018-07-31 07:58:33 -07:00
Daniel Büchele
9f95698492 disable auto publish
Summary: electro-builder automatically publishes when it detects builds on TravisCI. This disables this behaviour, as we want to manually publish releases.

Reviewed By: jknoxville

Differential Revision: D8783066

fbshipit-source-id: d8723c87b879b3ef7ee02585997a13cb55095e65
2018-07-11 08:03:57 -07:00
Daniel Büchele
c948e50c10 remove setup method in plugins
Summary:
Plugins had their custom setup method which needed to be called externally. That is what consturctors are for. This removes the setup method and moves ths logic to the constructor.
The setup method was called to late which caused the graphQL plugin to crash. With the logic now being in the constructor, it is ensured that it is called at the initialization.

Reviewed By: jknoxville

Differential Revision: D8769807

fbshipit-source-id: 7b4ab4815bbe397c80998adcb89ca361df6970d3
2018-07-10 07:17:08 -07:00
Daniel Büchele
f5dcaf02a4 persisted plugins state
Summary:
Two pros are passed into every plugin to persist state:
- `this.props.persistedState` which is the object of the persisted state
- `this.props.setPersistedState` which can be used to modify the persisted state

The state itself is stored in redux and therefore persisted when switching plugins.

The lifecycle hooks used a HOC are now implemented by the `ref`-function, which makes the code a little cleaner.

Reviewed By: jknoxville

Differential Revision: D8752097

fbshipit-source-id: d4f081f149cd840a29f1132bde91d72d3fba67ed
2018-07-10 02:33:51 -07:00
Daniel Büchele
7ed154c510 selected device
Summary: The redux store keeps a list of devices. For the active device, it stored the index in that list. This diff now stores a reference to the active device instead of the index in that array. This changes makes it easier to get the reference to the active device in a component.

Reviewed By: jknoxville

Differential Revision: D8767514

fbshipit-source-id: c740cf98d6039223ce8d5a47bcd277989fe70bc3
2018-07-09 07:19:23 -07:00
Daniel Buchele
5163f8b9a3 fbshipit-source-id: c71048dfea2a03cf83650b55aa9d1e463251920c 2018-07-04 07:19:44 -07:00
Daniel Büchele
cbab597236 show only one device in sidbar
Summary:
Refactors the plugin architecture of Sonar:
- Before plugin rendering had it's own implementation of the react lifecycle. This means the `render`-function was not called by react, but rather by the application it self. In this diff, the render method is now called from react, which enables better debugging and allows react to do optimizations.
- Business logic for querying emulators is moved away from the view components into its own dispatcher
- All plugin handling is moved from `App.js` to `PluginContainer`.
- The sidebar only shows one selected device. This allows us to add the screenshot feature as part of the Sonar main app and not a plugin.
- This also fixes the inconsistency between the devices button and the sidebar

Reviewed By: jknoxville

Differential Revision: D8186933

fbshipit-source-id: 46404443025bcf18d6eeba0679e098d5440822d5
2018-06-25 10:04:00 -07:00
Daniel Büchele
fbbf8cf16b Initial commit 🎉
fbshipit-source-id: b6fc29740c6875d2e78953b8a7123890a67930f2
Co-authored-by: Sebastian McKenzie <sebmck@fb.com>
Co-authored-by: John Knox <jknox@fb.com>
Co-authored-by: Emil Sjölander <emilsj@fb.com>
Co-authored-by: Pritesh Nandgaonkar <prit91@fb.com>
2018-06-01 11:03:58 +01:00