Commit Graph

186 Commits

Author SHA1 Message Date
Pascal Hartig
bc0e5b3a11 Broaden notification message type definition
Summary:
Let's the notification render any React node.
Particularly useful when including links or wanting to
format messages.

Reviewed By: jknoxville

Differential Revision: D10488157

fbshipit-source-id: 06d3c6b4477c78e8bef78e3a3dc0e05bc67a2ef4
2018-10-22 15:47:49 -07:00
John Knox
f0262d91f0 Oneworld connectivity test
Summary:
Gets a oneworld device (just android for now), installs an app. Checks it connects and stays connected for 5s.

The app installed is in an array, we just need to add more targets for further tests.

Reviewed By: danielbuechele

Differential Revision: D10231083

fbshipit-source-id: c33fb091c1b7914a33690398a79fd700c445c06c
2018-10-22 11:38:36 -07:00
John Knox
764cdfe127 Move async work out of the Server constructor
Summary:
I feel like doing async stuff here isn't a good idea in general.
But more pressingly, it means you can't immediately call server.close() after new Server(), because the things to close haven't been created yet.

Reviewed By: danielbuechele

Differential Revision: D10488301

fbshipit-source-id: 76ebe91e0c09f353e0bdb9f2e4116757e757abb2
2018-10-22 11:38:36 -07:00
Daniel Büchele
086ab0188b rename fill attribute
Summary:
We were using `fill={true}` as an attribute to make flexbox containers fill the entire available space.

However, `fill` is an HTML attribute (see: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill) This caused warnings printed to the console.

This diff renames the attribute to `grow` with is also more in line with the Flexbox terminology.

Reviewed By: priteshrnandgaonkar

Differential Revision: D10488389

fbshipit-source-id: ed8553c6203cdf6df94d26c731164ecec4c9fbd2
2018-10-22 09:54:59 -07:00
Daniel Büchele
c8a7ce5cfb link to hub
Summary: Clicking on a notifications links to the Notification Hub highlighting the selected notification.

Reviewed By: jknoxville

Differential Revision: D10487822

fbshipit-source-id: ed907ec244bef970d1b30ddb719856949229d0c4
2018-10-22 06:59:52 -07: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
f1c6ebfbd5 disable GK
Summary: Adding a GK to be able to disable notifications remotely.

Reviewed By: passy

Differential Revision: D10467036

fbshipit-source-id: ee555bd73cb5c58d1113e28fe88fe605480865cf
2018-10-19 10:53:13 -07:00
John Knox
6cc7f60cde Add sample js and android plugin
Summary:
The start of an example plugin.

My intention is for this to be a place that we keep up to date with the current best practice for doing things.

For example, with the introduction on persistedStateReducer, there are two ways to receive incoming messages, but only one of them works in the background. This should act as a guideline.

For this reason, don't hold back on reviewing it. I want it to be 👌

Reviewed By: priteshrnandgaonkar

Differential Revision: D10448592

fbshipit-source-id: d5fa978c14e47a7fa3c9a29d0929d5a6109267af
2018-10-19 09:44:05 -07:00
Daniel Büchele
61d80b4bb9 network deeplink
Summary: Deep link from the QPL plugin into the network plugin

Reviewed By: passy

Differential Revision: D10462528

fbshipit-source-id: cc044863191fc4375390165f6b7b7d5c5e9c77e3
2018-10-19 08:39:51 -07:00
Daniel Büchele
9a43a00a80 Notifications UI
Summary:
- Adding hover buttons
- showing timestamp
- adjusting colors

Reviewed By: passy, priteshrnandgaonkar

Differential Revision: D10461877

fbshipit-source-id: 1a384428ab2ce5d22a0e619055b04c1afdcbcb63
2018-10-19 07:24:19 -07:00
Daniel Büchele
4f08fd8711 remove pluginStates on disconnect
Summary:
When a client disconnects, we want to remove all plugins states for this client, so the next time the client reconnects the plugins start with an empty state.

The main use case for this is when recompiling the app and launching it in the simulator, we don't want to show old network-requests or QPL events.

Reviewed By: passy

Differential Revision: D10447808

fbshipit-source-id: 5fb3f24ee37f564e8dc00315bff86a2bcd5f65f2
2018-10-19 05:14:17 -07:00
Daniel Büchele
a8a512fe44 network defaultPersistedState
Summary: using defaultPersistedState in network plugin to remove unnecessary null check

Reviewed By: passy

Differential Revision: D10446988

fbshipit-source-id: b0290e4b678c36c031ecd0fba88cdb9add24b46e
2018-10-19 05:14:17 -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
John Knox
d48f93edea Add method field to persistedStateReducer
Summary:
When sending a message from the mobile side, you call something like:

`send(method: string, params: Object)`

But when receiving it in the reducer, you only get the params. Adding method so you can distinguish them.

Reviewed By: passy

Differential Revision: D10447890

fbshipit-source-id: f1fe925e82355866f86b322ecd3c72c604ae86af
2018-10-19 03:37:59 -07:00
Daniel Büchele
f973bdd455 add notification API to network plugin
Summary: Trigger notifications for all network requests having an error status code.

Reviewed By: passy

Differential Revision: D10401402

fbshipit-source-id: 8fa63cbc251457142abd71845fb6f1c735b247cc
2018-10-18 02:47:53 -07:00
Daniel Büchele
38268fe4c9 whitelist persisted reducers
Summary:
We only want to persist certain reducers that are whitelisted.

Currently some parts of the `connections` reducer and everything from the other reducers was persisted. This changes the behavior to only persist what is explicitly whitelisted and not the other reducers.

These pars of the store are whitelisted:
- `connections.userPreferredDevice`
- `connections.userPreferredPlugin`
- `connections.userPreferredApp`

Reviewed By: jknoxville

Differential Revision: D10401403

fbshipit-source-id: e4aa4f2b2f8f6229b02dcf46798965fa1ae74df6
2018-10-18 02:47:53 -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
Pritesh Nandgaonkar
ce996ba8af Add listener in the renderer process for deeplink
Summary:
- Set userPrefferedPlugin for external deeplink
- Listen for deeplink in renderer process and navigate accordingly

Reviewed By: passy

Differential Revision: D10339035

fbshipit-source-id: 4de6249a0672f9ce02b0dfb78a4563302c308578
2018-10-17 06:21:01 -07:00
Daniel Büchele
fede0b854e iOS device availability
Summary: Apple seems to have changed the key for device availablility. We check for both now.

Reviewed By: jknoxville

Differential Revision: D10401073

fbshipit-source-id: 284a168a701eb2d5d9b3cbcac2aa6276ee1a2211
2018-10-16 06:36:06 -07:00
Daniel Mueller
12a2c0ee70 Add option to display network response as copyable json
Summary: This is meant to reduce the friction of getting network response payloads. Simple switch allows developers to go to "formatted" body ui which shows the json in a text blob.

Reviewed By: passy

Differential Revision: D10378877

fbshipit-source-id: 87aeff5318f0c2c6d3d91d7e3b491595794e69bf
2018-10-16 03:55:43 -07:00
Daniel Büchele
faf521aa87 use pastry for createPaste
Summary:
Moving from `arc` to `pastry` to create Pastes.
arc paste is deprecated and throws errors sometimes. Pastry seems to be the tool of choice now and has a nicer API anyways.

Reviewed By: passy

Differential Revision: D10302075

fbshipit-source-id: a846adf3768a2adf5c7ff73dc89b18c1e9169ac0
2018-10-15 03:08:58 -07:00
Daniel Büchele
e86a756e3c remove PortForwarder
Summary: Removing PortForwarderMacApp as it is not used anymore. Before it was used to allow us to debug physical iOS device. However, the support for physical iOS device was removed a while ago for security reasons. The PortForwarder was not in use anymore so it is safe to remove it.

Reviewed By: passy

Differential Revision: D10337888

fbshipit-source-id: 93f508ec524a0fc055141176c06d7e7169d83f16
2018-10-15 03:03:35 -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
233b7bcd3c Send deinit message even if the plugin runs in background
Summary: Put back deinit message and send deinit call even if the plugin is the background one

Reviewed By: danielbuechele

Differential Revision: D10300165

fbshipit-source-id: ef945282fe628e9196c21b5060a8e464e98bc94c
2018-10-11 15:23:22 -07:00
Pritesh Nandgaonkar
396e385651 Handle empty state for background plugin
Summary: Handles the case when persisted state is undefined which will be the case when the initially selected plugin is not the one running in background

Reviewed By: danielbuechele

Differential Revision: D10269073

fbshipit-source-id: b7a17b0daa37a486cc7f456338cb97123ad813b7
2018-10-11 15:23:22 -07:00
Pritesh Nandgaonkar
5adc0d0625 make network plugin running in background
Summary: implements `persistedStateReducer` for the network plugins to merge messages into the persistedState even when the plugin is not running.

Reviewed By: danielbuechele

Differential Revision: D10256311

fbshipit-source-id: 53011a2123342825e8404b1c2c798aeb550c596d
2018-10-11 15:23:22 -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
Itai Rosenberger
de85f9d455 Make dylib plugin error message more user friendly
Summary: Make dylib plugin error message more user friendly by making the URL linkable.

Reviewed By: dshahidehpour

Differential Revision: D10304489

fbshipit-source-id: 3d5c0d8da426e1b5580d431f07b5291dad068ffc
2018-10-10 18:56:05 -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
Alex Langenfeld
7527636a38 change device plugin support check
Summary: Invert the way device plugin <-> device support works with the long term goal of supporting user defined device plugins

Reviewed By: danielbuechele

Differential Revision: D10240765

fbshipit-source-id: 9e886518a2fbfd263c79daa4b805c088ab38ab87
2018-10-10 18:43:21 -07:00
Daniel Büchele
069f2be335 notifications] adding native notifications
Summary: Adds a notification disapatcher to the redux store which triggers native notifications.

Reviewed By: jknoxville

Differential Revision: D10301490

fbshipit-source-id: d926d9a5378359ebb98a8b5816100f41db1e13e6
2018-10-10 10:41:09 -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
Daniel Büchele
f7cb4667c4 fix icon size
Summary: Icon size passed to a button was ignored.

Reviewed By: passy

Differential Revision: D10301573

fbshipit-source-id: 00117a35622bbd490b74359f52ecc07929390205
2018-10-10 10:41:08 -07:00
John Knox
49e7f2dc8b Add notifications for failed network requests
Summary: Also acts as a model for using the computeNotifications api.

Reviewed By: passy

Differential Revision: D10240659

fbshipit-source-id: 610512de7484e10c9c0ed8e661913c2fe10869da
2018-10-09 08:27:06 -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
John Knox
1a5b127d58 Run adb reverse for emulators too
Summary:
Yesterday I made a change that switches from hardcoded IP address 10.0.2.2, to localhost for emulators on Android 5+.
This didn't work with flipper because it relies on port forwarding, and port forwarding was only done for physical devices, not emulators.

This corrects that, by port forwarding whenever possible. This will enable using localhost, which simplifies remote adb connection support.

Reviewed By: danielbuechele

Differential Revision: D10255554

fbshipit-source-id: 77a05eddf530e0e9495568f2a0901f390464345a
2018-10-09 06:25:59 -07:00
Pascal Hartig
2c67546ad1 Add test for pluginStates
Summary:
It's not super useful, to be honest, but it's to have one
open source `.node.js` test in place so `yarn test` doesn't
error out.

Reviewed By: danielbuechele

Differential Revision: D10217530

fbshipit-source-id: c0e17e48782174b856ef6d5fe94c5c042564e4f5
2018-10-09 03:56:13 -07:00
Hilal Alsibai
b40810080c Add support for multiple shared preference files
Summary: Adds the ability to view multiple shared preference files in Flipper

Reviewed By: danielbuechele

Differential Revision: D10181908

fbshipit-source-id: 723b71d7bd87c51c0fabc77204b5a26a2b7aa782
2018-10-06 11:41:34 -07:00
Alex Langenfeld
630982190b remove OculusDevice
Summary: Pretty sure this was meant to get removed before open sourcing, it isn't referenced anywhere.

Reviewed By: danielbuechele

Differential Revision: D10202081

fbshipit-source-id: 23d213b3a041acad85eb723d32b65f7da276003d
2018-10-06 11:18:18 -07:00
John Knox
4d50a5209c Skip failing test until oneworld is shipped
Summary:
The buck install command fails when xcode_dmg is used in sandcastle hosts, meaning xcode is mounted somewhere other than /Applications.
Skip the connection test for now. I'll get oneworld working with it instead.

Reviewed By: passy

Differential Revision: D10231097

fbshipit-source-id: 16e320070f8b3fd4f56ff919bdd3ec47355e342c
2018-10-06 06:12:51 -07:00
Hilal Alsibai
490f5e7f5a Fix Select onChange prop
Summary: Was passing in a Proxy instance before instead of a string. Now it passes the correct string that callers would expect.

Reviewed By: sjkirby

Differential Revision: D10181911

fbshipit-source-id: 8dfa677479a81de0f7b5be23f827ce7b52169931
2018-10-03 17:21:42 -07:00
John Knox
eebff1eb88 Run wilde on iOS emulator during electron tests
Summary:
Before running the test suite, build wilde and run it on a local emulator.

This takes about 15 mins on a lego-mac with a warm cache.
It's probably worth splitting out the normal unit tests into a separate job, so we get quicker feedback on them. I'll do that in a separate diff.

Lets run this for a while, and see how it goes, I'm wondering if it might get flaky because it will be building the master version of wilde, so potentially could be broken a lot, though it's passed evry time I've tried it so far.

If it's reliable, we can run the same thing with loads of other apps in parallel.

Reviewed By: passy

Differential Revision: D10110408

fbshipit-source-id: 61c549eb1b9d04729dcb5ed01271a484af4777f5
2018-10-02 06:57:38 -07:00
Daniel Büchele
5aefb989e0 run jest tests
Summary:
Adding support for JS testing. Currently there are two environments tests can run in: node and electron. To select which environment to run a test in, name your test file accordingly `*.node.js` or `*.electron.js` and put it in a `__tests__` folder.

- `yarn test` to run node based tests
- `yarn test-electron` to run electron tests

A basic snapshot test of the empty app is added to make sure the app is rendering as expected. A test for the server is added to make sure when Flipper is started the two servers (secure and insecure) are started and ready to accept connections.

Reviewed By: passy

Differential Revision: D10050212

fbshipit-source-id: 8ef7f931339b43251d9d423886bcaca99ae691e4
2018-10-02 04:29:51 -07:00
Daniel Büchele
9caddc2b8b Button icon variant
Summary: Allow setting the icon variant for icons on buttons

Reviewed By: jknoxville

Differential Revision: D10101603

fbshipit-source-id: 344afda2296479ffb8449a7ad8172b35f0dc95e4
2018-09-28 08:57:37 -07:00
Daniel Büchele
a455520ecb adding jest test setup
Summary:
Adds a test runner for jest test and adds three simple test cases:
- render the app
- start a server
- client connecting to the app

Test can be run using `yarn test`.

To make the test runner work, some changes needed to be made:
- remove the export of `init()` from `'flipper'`, because it was a cyclic dependency
- updating Button.js to the new ref-API

Reviewed By: jknoxville

Differential Revision: D10027078

fbshipit-source-id: 49107b0dd4dec666b92ecd841422fe7e6b3a7756
2018-09-28 06:42:08 -07:00
Daniel Büchele
ab4f4ed02b table filter and icons enhancements
Summary:
- Allows alignment of table columns
- fixes display of lager numbers in log counts
- fixes the alignment of `FilterRow`

Reviewed By: priteshrnandgaonkar

Differential Revision: D9850598

fbshipit-source-id: 106f4dc6a422f58e090f97857bd7be02e7c2c1d2
2018-09-21 10:52:02 -07:00
Daniel Büchele
9ef8d32053 flow fixes
Summary: Fixes a flow issue in the type definition of a filter. The color can be optional.

Reviewed By: passy

Differential Revision: D9850602

fbshipit-source-id: 1d74d0462baef58ad1a93e23152583679f51c177
2018-09-21 10:52:01 -07:00