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

View File

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