Make createTablePlugin strict
Summary: _typescript_ Reviewed By: danielbuechele Differential Revision: D17259739 fbshipit-source-id: a7d36482fc334fd05780fef56ebe3b2a981c2ac5
This commit is contained in:
committed by
Facebook Github Bot
parent
ce51458eb8
commit
71e2369b41
@@ -21,6 +21,7 @@ import createPaste from './fb-stubs/createPaste';
|
|||||||
import {List, Map as ImmutableMap} from 'immutable';
|
import {List, Map as ImmutableMap} from 'immutable';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {KeyboardActions} from './MenuBar';
|
import {KeyboardActions} from './MenuBar';
|
||||||
|
import {TableBodyRow} from './ui';
|
||||||
|
|
||||||
type ID = string;
|
type ID = string;
|
||||||
|
|
||||||
@@ -60,7 +61,6 @@ type State = {
|
|||||||
* the client in an unknown state.
|
* the client in an unknown state.
|
||||||
*/
|
*/
|
||||||
export function createTablePlugin<T extends RowData>(props: Props<T>) {
|
export function createTablePlugin<T extends RowData>(props: Props<T>) {
|
||||||
// @ts-ignore
|
|
||||||
return class extends FlipperPlugin<State, any, PersistedState<T>> {
|
return class extends FlipperPlugin<State, any, PersistedState<T>> {
|
||||||
static keyboardActions: KeyboardActions = ['clear', 'createPaste'];
|
static keyboardActions: KeyboardActions = ['clear', 'createPaste'];
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ export function createTablePlugin<T extends RowData>(props: Props<T>) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
state: State = {
|
||||||
selectedIds: [],
|
selectedIds: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ export function createTablePlugin<T extends RowData>(props: Props<T>) {
|
|||||||
|
|
||||||
createPaste = () => {
|
createPaste = () => {
|
||||||
let paste = '';
|
let paste = '';
|
||||||
const mapFn = row =>
|
const mapFn = (row: TableBodyRow) =>
|
||||||
Object.keys(props.columns)
|
Object.keys(props.columns)
|
||||||
.map(key => textContent(row.columns[key].value))
|
.map(key => textContent(row.columns[key].value))
|
||||||
.join('\t');
|
.join('\t');
|
||||||
@@ -129,7 +129,9 @@ export function createTablePlugin<T extends RowData>(props: Props<T>) {
|
|||||||
if (this.state.selectedIds.length > 0) {
|
if (this.state.selectedIds.length > 0) {
|
||||||
// create paste from selection
|
// create paste from selection
|
||||||
paste = this.props.persistedState.rows
|
paste = this.props.persistedState.rows
|
||||||
.filter(row => this.state.selectedIds.indexOf(row.key) > -1)
|
.filter(
|
||||||
|
(row: TableBodyRow) => this.state.selectedIds.indexOf(row.key) > -1,
|
||||||
|
)
|
||||||
.map(mapFn)
|
.map(mapFn)
|
||||||
.join('\n');
|
.join('\n');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user