read infos from package.json

Summary:
Adding the properties from a plugin's `package.json` as static properties to the class.
The name from `package.json` is used as it's `id`.

This allows us in the future to add meta information about a plugin to it's package.json and still use the data inside the app.

Reviewed By: priteshrnandgaonkar

Differential Revision: D13417288

fbshipit-source-id: 3d0a62d4cb0115153cce1aaee677b9680fefebf4
This commit is contained in:
Daniel Büchele
2018-12-18 08:27:25 -08:00
committed by Facebook Github Bot
parent e23da69db9
commit 6ffc027051
9 changed files with 54 additions and 47 deletions

View File

@@ -22,17 +22,14 @@ type RowData = {
id: ID,
};
type Props<T> = {|
title: string,
id: string,
icon: string,
type Props<T> = {
method: string,
resetMethod?: string,
columns: TableColumns,
columnSizes: TableColumnSizes,
renderSidebar: (row: T) => any,
buildRow: (row: T) => any,
|};
};
type PersistedState<T> = {|
rows: TableRows,
@@ -59,9 +56,6 @@ type State = {|
export function createTablePlugin<T: RowData>(props: Props<T>) {
// $FlowFixMe persistedStateReducer is fine to accept payload of type T, because it is of type RowData
return class extends FlipperPlugin<State, *, PersistedState<T>> {
static title = props.title;
static id = props.id;
static icon = props.icon;
static keyboardActions = ['clear', 'createPaste'];
static defaultPersistedState: PersistedState<T> = {
@@ -170,7 +164,7 @@ export function createTablePlugin<T: RowData>(props: Props<T>) {
return (
<FlexColumn grow={true}>
<SearchableTable
key={props.id}
key={this.constructor.id}
rowLineHeight={28}
floating={false}
multiline={true}