Migrate LogWatcher to (strict) tsx

Summary: 1/2 for porting the DeviceLogs.

Reviewed By: danielbuechele

Differential Revision: D17156890

fbshipit-source-id: 4d2841b8f86fdb5f3a3c085482c37af79de4323a
This commit is contained in:
Pascal Hartig
2019-09-03 05:48:22 -07:00
committed by Facebook Github Bot
parent 937001f869
commit 6f14bb7dfa
2 changed files with 19 additions and 17 deletions

View File

@@ -5,7 +5,7 @@
* @format
*/
import type {TableBodyRow} from 'flipper';
import {TableBodyRow} from 'flipper';
import {
PureComponent,
@@ -19,22 +19,23 @@ import {
colors,
styled,
} from 'flipper';
import React from 'react';
export type Counter = {
expression: RegExp,
count: number,
notify: boolean,
label: string,
expression: RegExp;
count: number;
notify: boolean;
label: string;
};
type Props = {|
onChange: (counters: Array<Counter>) => void,
counters: Array<Counter>,
|};
type Props = {
onChange: (counters: Array<Counter>) => void;
counters: Array<Counter>;
};
type State = {
input: string,
highlightedRow: ?string,
input: string;
highlightedRow: string | null;
};
const ColumnSizes = {
@@ -93,7 +94,7 @@ export default class LogWatcher extends PureComponent<Props, State> {
highlightedRow: null,
};
_inputRef: ?HTMLInputElement;
_inputRef: HTMLInputElement | undefined;
onAdd = () => {
if (
@@ -116,7 +117,7 @@ export default class LogWatcher extends PureComponent<Props, State> {
this.setState({input: ''});
};
onChange = (e: SyntheticInputEvent<HTMLInputElement>) => {
onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
this.setState({
input: e.target.value,
});
@@ -169,7 +170,7 @@ export default class LogWatcher extends PureComponent<Props, State> {
});
};
onKeyDown = (e: SyntheticKeyboardEvent<>) => {
onKeyDown = (e: React.KeyboardEvent) => {
if (
(e.key === 'Delete' || e.key === 'Backspace') &&
this.state.highlightedRow != null
@@ -182,7 +183,7 @@ export default class LogWatcher extends PureComponent<Props, State> {
}
};
onSubmit = (e: SyntheticKeyboardEvent<>) => {
onSubmit = (e: React.KeyboardEvent) => {
if (e.key === 'Enter') {
this.onAdd();
}
@@ -194,6 +195,7 @@ export default class LogWatcher extends PureComponent<Props, State> {
<WatcherPanel
heading="Expression Watcher"
floating={false}
collapsable={true}
padded={false}>
<Toolbar>
<ExpressionInput

View File

@@ -11,7 +11,7 @@ import type {
TableColumnSizes,
TableColumns,
} from 'flipper';
import type {Counter} from './LogWatcher.js';
import type {Counter} from './LogWatcher.tsx';
import type {Props as PluginProps} from '../../plugin.tsx';
import type {DeviceLogEntry} from '../../devices/BaseDevice.tsx';
@@ -31,7 +31,7 @@ import {
createPaste,
textContent,
} from 'flipper';
import LogWatcher from './LogWatcher';
import LogWatcher from './LogWatcher.tsx';
const LOG_WATCHER_LOCAL_STORAGE_KEY = 'LOG_WATCHER_LOCAL_STORAGE_KEY';