Summary:
Getting the behavior exactly right was tricky, now settled on the following:
* Don't automatically show the search history (the default) but introduce an explicit button to toggle it, as opening it by default was pretty obtrusive in testing
* Items are added to the history when using return / explicitly clicking search, to only get "clean" entries into the history, and not half complete searches. Needing to press enter might be to subtle since datatable will also search without that, but not searching on keypress felt as a regression as well.
* Introduced a menu item for clearing the search history
* Search history is persisted like search filters.
Yay to Antd's AutoComplete, which is really straightforward and cleanly composes with Input.Search.
Changelog: DataTable will now keep a history of search items when hitting <return> to search. Use the history button to bring up the history.
Reviewed By: aigoncharov
Differential Revision: D36736821
fbshipit-source-id: 8d18b85308a39bd1644057371040855d199545c7
Summary:
The `Control` button press, that hides the current search filter, had some specific logic to make sure that the current selection remained visible. Since this is now generically supported, this is no longer needed.
Also updated the `Control` button behavior to also toggle back the search filter if needed, which was never finished in the original implementation.
Changelog: DataTable: pressing the control key can be used to temporarily turn the current search filter on and off.
Reviewed By: aigoncharov
Differential Revision: D36736494
fbshipit-source-id: 2c4949efa0d6935735f61ee43f9268b7e27d1fcf
Summary:
During filter changes, DataTable would loose any selections made, which was posted multiple times as papercut
I didn't implement preserving multi line selections. That should be straightforward, but wasn't sure that'd be desirable or not.
Changelog: DataTable: Data tables will now preserve the current selection and scroll it into view when changing the search filter.
Reviewed By: aigoncharov
Differential Revision: D36736496
fbshipit-source-id: 401ef351c847f58a5d411cf9f352390f6a110b24
Summary:
This adds support for the key of DataTableColumn to be a dotted path into a nested object, e.g foo.bar. Currently the typescript types only allow a top level key to be set, making this feature currently unusuable from plugin code.
While this could be addressed in a future commit the intention of this is to allow the user to add custom fields into their table columns at run time
Note there is a side effect to free text search from this commit. Previously it would search all top keys in the object. Now it will only search in columns that are in the table.
changelog: Searching data table will now only search columns in the table, rather than all top level attributes of the object
Reviewed By: mweststrate
Differential Revision: D36663929
fbshipit-source-id: 3688e9f26aa7e1828f8e9ee69f8e6f86268c8a54
Summary:
When filter is applied for the first time we shouldn't debounce to avoid "flashing" on datatable loading when it is first loaded without filter and then filter applied after 250ms.
Changelog:
Fixed flashing on opening datatable-based plugin with a filter.
Reviewed By: timur-valiev
Differential Revision: D36602929
fbshipit-source-id: 8bd33f50c92036f2a5565f636f4f2fbe69d900f2
Summary:
As we persist column filters between sessions - sometimes it's not obvious that they are applied.
This diff adds "Reset filters" action just near message "No records match the current search / filter criteria" to make it obvious that some records are hidden because of filters and let user quickly disable filters to see all items.
The same action also added to datatable's context menu.
Changelog:
Quick action "Reset filters" for datatable-based plugins which is shown in context menu and in empty table when all items filtered out.
Reviewed By: timur-valiev
Differential Revision: D36600535
fbshipit-source-id: 782e7f863f2f52d7f6017685bdebcb1feeb97dbd
Summary:
Adding a feature to Flipper's Logs plugin where:
1) you search for something,
2) click on a line among the filtered search results,
3) press control,
4) get taken back to unfiltered list of all messages, centered on your selected line
This is to help debugging where the user may add a print statement but the error happens after it, and it's difficult to catch without a lot of scrolling.
Reviewed By: mweststrate
Differential Revision: D33446285
fbshipit-source-id: 19aa472a12de074e561dbe37b44821fc29bf5c91
Summary:
Changelog: most data tables allow for horizontal scrolling now if they run out of space
This diff introduces support for horizontal scrolling in datatables. Originally thought about making this a view option, but doing automatically works actually quite fine. By default the columns resize as they did, but if either a column is made bigger or the window is so small no space is left, a horizontal scrollbar can be used.
This adresses several usability issues reported in GH / workplace
fixes https://github.com/facebook/flipper/issues/2608
Reviewed By: antonk52
Differential Revision: D33368216
fbshipit-source-id: 206c761a5873cf0396af091f2cbdedc3e638afac
Summary:
Changelog: Data tables will now remember their configuration by default and share it across different applications
As reported, column configurations were often not remembered across restarts. This was caused by two things
1. persisting config was by default turned off
2. the persistence key was based on pluginKey, that includes device and client identification, rather than purely the plugin name.
Reviewed By: cekkaewnumchai
Differential Revision: D33364780
fbshipit-source-id: 6c38182dc35e3cce23b858f931d554111b080c97
Summary:
This diff adds `types` fields on the compiler config for every project. This way we can make sure that for example node types and packages are not available in flipper-ui-core. Without an explicit types field, all types would be shared between all packages, and implicitly included into the compilation of everything. For the same reason `types/index.d.ts` has been removed, we want to be intentional on which types are being used in which package.
This diff does most of the work, the next diff will fine tune the globals, and do some further cleanup.
As an alternative solution I first tried a `nohoist: **/node_modules/types/**` and make sure every package list explicitly the types used in package json, which works but is much more error prone, as for example two different react types versions in two packages will cause the most unreadable compiler error due to the types not being shared and not literally the same.
Reviewed By: lawrencelomax
Differential Revision: D33124441
fbshipit-source-id: c2b9d768f845ac28005d8331ef5fa1066c7e4cd7
Summary:
I've decided to migrate [a desktop plugin](https://github.com/bamlab/react-native-performance) to Sandy.
When doing so, I decided to rise to the challenge from the [Flipper docs](https://fbflipper.com/docs/tutorial/js-custom#testing-plugin-logic): `we are going to pretend that we always write unit tests first` 😅
However, I've realized that when creating a plugin with `npx flipper-pkg init`, running `yarn jest` directly after creation actually fails.
There are 3 issues solved in the different commits:
1. an absolute import seem to not be resolved, since all the other imports were relative in the file, I changed it as well
2. some dependencies are missing.
They used to be included in the `flipper` dependency but when migrating to use `flipper-plugin` instead, they're not present anymore.
I don't think this is an ideal fix, I would believe a dependency like a `flipper-dev-environment` including all of those would be more appropriate. So I'm open to suggestions to fix/remove of course
3. jest.config needs to be fixed to run in jsdom environment and ensure we can test the react component
## Changelog
Fix: ensure desktop plugin template tests run
Pull Request resolved: https://github.com/facebook/flipper/pull/3039
Test Plan:
I've cloned the repo and run:
```
cd flipper/desktop/pkg
yarn
cd ../../..
./flipper/desktop/pkg/bin/run init
```
I run the tests on the newly package created, but it actually still failed because of the first issue (since it still installed `flipper-plugin` from npm`)
However, by adding this patch, it now runs!
```patch
diff --git a/node_modules/flipper-plugin/lib/ui/data-table/DataTable.js b/node_modules/flipper-plugin/lib/ui/data-table/DataTable.js
index 2e07ff5..ff3181d 100644
--- a/node_modules/flipper-plugin/lib/ui/data-table/DataTable.js
+++ b/node_modules/flipper-plugin/lib/ui/data-table/DataTable.js
@@ -39,7 +39,7 @@ const useAssertStableRef_1 = require("../../utils/useAssertStableRef");
const PluginContext_1 = require("../../plugin/PluginContext");
const lodash_1 = require("lodash");
const useInUnitTest_1 = require("../../utils/useInUnitTest");
-const createDataSource_1 = require("flipper-plugin/src/state/createDataSource");
+const createDataSource_1 = require("../../state/createDataSource");
function DataTable(props) {
var _a, _b;
const { onRowStyle, onSelect, onCopyRows, onContextMenu } = props;
```
Reviewed By: aigoncharov
Differential Revision: D32358207
Pulled By: mweststrate
fbshipit-source-id: 7761b4150c24dd5379a24c3c1deeb78bf3dda4ee
Summary: Current implementation uses type `string` as a key for indexing items stored in datasource. However, users can provide any key as an index which means that the type of index item can be anything, not only string. This diff introduces a more refined types for the key. It adds another requirement to provide a key property to a generic which is used to infer the index type.
Reviewed By: mweststrate, aigoncharov
Differential Revision: D31895751
fbshipit-source-id: 19ba907bd6f35df87e3fa442db5fc5cec6af174d
Summary:
Changelog: Flipper message debugging moved from a separate device to the console tab
This makes message debugging easier accessible, and in production (recently requested at GH). Also it clears up a lot of infra that was created just to make flipper a self recursive inspection device + a separate plugin. While fun, a hardcoded setup is just a bit more simpler (no exception rules and better static verification)
Reviewed By: nikoant
Differential Revision: D29487811
fbshipit-source-id: b412adc3ef5bd831001333443b432b6c0f934a5e
Summary:
Changelog: Add support for negative filters in data tables
As requested per somewhere on workplace but couldn't find it back :)
Reviewed By: nikoant
Differential Revision: D29486096
fbshipit-source-id: 467c8598f6d09afc9a5ed85affb6c51840afe00c
Summary: There was an initialisation error possible if the crash reporter tried to start with an initial selection (after coming from a deeplink or the notification pane), which would cause an unending update loop.
Reviewed By: passy
Differential Revision: D29331127
fbshipit-source-id: 14e75e483c232039e6a80aa131fa5ce7c105b670
Summary:
With new abstraction, `DataList` matches what the plugin trying to render.
Should fix:
https://fb.workplace.com/groups/flippersupport/permalink/1145431339270856/
Changelog: [MobileConfig] Fix issues with scrolling not working and several other improvements
Reviewed By: cekkaewnumchai
Differential Revision: D28314408
fbshipit-source-id: 4d8fbe3d8e868f737750203cd568d94bae8b4108
Summary:
Re-introduced context menu to DataTable, due to popular demand.
Originally it wasn't there to better align with ant design principles, but in an app like Flipper it makes just too much sense to have it
See e.g. https://fb.workplace.com/groups/flippersupport/permalink/1138285579985432/
changelog: Restored context menu in data tables
Reviewed By: passy
Differential Revision: D28996137
fbshipit-source-id: 16ef4c90997c9313efa62da7576fd453a7853761
Summary: Fixed minor keyboard navigation annoyance: pressing arrow down on the last entry would remove selection, then jump to first row. Pressing up on first row would deselect then select first again. After this change the first/last item is kept selected in those cases
Reviewed By: passy
Differential Revision: D28958705
fbshipit-source-id: 01dbce3971ed965eae3b74e6706fef96aa86df66
Summary: some type simplifications, that makes it easier to reuse data sources and helps type inference
Reviewed By: passy
Differential Revision: D28413380
fbshipit-source-id: 261a8b981bf18a00edc3075926bd668322e1c37d
Summary:
Added a microbundle based build setup to the data-source folder to be able to package just that folder.
For simplicity / iteration speed, this is only used to publish externally. Our own code still references the source files directly.
More strict separation can be done later if there is external adoption.
Reviewed By: nikoant
Differential Revision: D28056699
fbshipit-source-id: a011b615cfffeff8ecb879bd7281a71085cea965
Summary:
To make the DataSource abstraction reusable for other teams and an upcoming talk, this diff moves all DataSource storage & virtualization logic in one folder.
Will set up a build process and demo project in later diffs.
Reviewed By: nikoant
Differential Revision: D28056700
fbshipit-source-id: 7cfe5b40bbbe387da711f765a604a45029d451c7
Summary:
Changelog: Standardized DataList component
This diff standardizes the DataList component, by reusing the DataList. This is done to be able to take full advantage of all its features like virtualisation, keyboard support, datasource support, etc.
Also cleaned up DataTable properties a bit, by prefixing all flags with `enableXXX` and setting clear defaults
Reviewed By: passy
Differential Revision: D28119721
fbshipit-source-id: b7b241ea18d788bfa035389cc8c6ae7ea95ecadb
Summary:
Noticed in reviews during the convertathon there is still quite some boilerplate in things that happen on the boundary of UI and plugin state, such as setting up menu entries and providing common functionality like clear, master/detail layout, etc.
This diff introduces the `MasterDetail` component, which takes a higher level approach by merely needing to provide the state atoms and desired features, and taking care of the wiring.
Applied it to createTablePlugin, to prove that going from `createTablePlugin` to `MasterDetail` will be a much smaller step now.
Verified on the funnel logger plugin
Reviewed By: passy
Differential Revision: D28090362
fbshipit-source-id: 146f8c315fea903901ad4e3e46711642f16cf0e6
Summary: Having time / async / non-blocking behavior in components in unit tests is really annoying, as it makes unit tests async without an easy way to determine 'done'. This diff makes sure that DataTable & DataInspector don't break down their work in smaller tasks, but do everything block if they are running in a unit test.
Reviewed By: nikoant
Differential Revision: D28054487
fbshipit-source-id: 72c3b519e092ad69ed71eb1731e1fed80022f91f
Summary:
Introduced the `scrollable={false}` option to DataTable, that gives the table its natural size, while still having all the other gimmicks of DataTable, like search, filter, etc etc.
To implement this, a non-virtualizing rendering is needed, which is handled by the `StaticDataSourceRenderer`
Also introduced the option to hide the searchbar.
Reviewed By: nikoant
Differential Revision: D28036469
fbshipit-source-id: 633c4f7f3fabfa99efa2839059aaa59b0a407ada
Summary: This diff allows using a DataTable without setting up a full datasource, which is simpler in case the dataset is small and/or fixed. For an continuously growing dataset a DataSource should still be set up.
Reviewed By: jknoxville
Differential Revision: D28037897
fbshipit-source-id: 2e56b1970e19f967c3752a78737b8f7a3f934b87
Summary:
Some styling fixes and minor improvements in DataTable, used by network plugin:
- be able to customise the context menu
- be able to customise how entire rows are copied and presented on the clipboard to be able to deviate from the standard JSON
- deeplink handling was made async, this gives the plugin the opportunity to first handle initial setup and rendering before trying to jump somewhere which is a typical use case for deeplinking
Reviewed By: passy
Differential Revision: D27947186
fbshipit-source-id: a56f081d60520c4bc2ad3c547a8ca5b9357e71a1
Summary: just a rename, as we will have `data-inspector` folder as well in next diffs.
Reviewed By: passy
Differential Revision: D27591891
fbshipit-source-id: b1fe92cbf4be1633e623e59b694efc3f687c3413