Restore copy on text
Summary: Some folks were missing the copy as text ManagedTable used to have, so introduced both the options to either copy as text (visible columns or custom copy handler) or as JSON Changelog: It is now possible to both copy as text or as JSON from data tables Reviewed By: jknoxville Differential Revision: D29712096 fbshipit-source-id: 27bd2e869a247bd0896ce2774c08651123fd531d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1e93055eb5
commit
d23ccfcd44
@@ -31,7 +31,7 @@ import {
|
||||
} from './reducers/notifications';
|
||||
import {selectPlugin} from './reducers/connections';
|
||||
import {State as StoreState} from './reducers/index';
|
||||
import textContent from './utils/textContent';
|
||||
import {textContent} from 'flipper-plugin';
|
||||
import createPaste from './fb-stubs/createPaste';
|
||||
import {getPluginTitle} from './utils/pluginUtils';
|
||||
import {getFlipperLib} from 'flipper-plugin';
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
updatePluginBlocklist,
|
||||
updateCategoryBlocklist,
|
||||
} from '../reducers/notifications';
|
||||
import {textContent} from '../utils/index';
|
||||
import {textContent} from 'flipper-plugin';
|
||||
import {getPluginTitle} from '../utils/pluginUtils';
|
||||
import {sideEffect} from '../utils/sideEffect';
|
||||
import {openNotification} from '../sandy-chrome/notification/Notification';
|
||||
|
||||
@@ -12,7 +12,7 @@ export {keyframes} from '@emotion/css';
|
||||
export {produce} from 'immer';
|
||||
|
||||
export * from './ui/index';
|
||||
export {textContent, sleep} from './utils/index';
|
||||
export {textContent, sleep} from 'flipper-plugin';
|
||||
export * from './utils/jsonTypes';
|
||||
export {default as GK, loadGKs, loadDistilleryGK} from './fb-stubs/GK';
|
||||
export {default as createPaste} from './fb-stubs/createPaste';
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
import {Filter} from './types';
|
||||
import React, {PureComponent} from 'react';
|
||||
import ContextMenu from '../ContextMenu';
|
||||
import textContent from '../../../utils/textContent';
|
||||
import {textContent} from 'flipper-plugin';
|
||||
import styled from '@emotion/styled';
|
||||
import {colors} from '../colors';
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import ManagedTable, {ManagedTableProps} from '../table/ManagedTable';
|
||||
import {TableBodyRow} from '../table/types';
|
||||
import Searchable, {SearchableProps} from './Searchable';
|
||||
import React, {PureComponent} from 'react';
|
||||
import textContent from '../../../utils/textContent';
|
||||
import {textContent} from 'flipper-plugin';
|
||||
import deepEqual from 'deep-equal';
|
||||
|
||||
type Props = {
|
||||
|
||||
@@ -31,9 +31,8 @@ import createPaste from '../../../fb-stubs/createPaste';
|
||||
import debounceRender from 'react-debounce-render';
|
||||
import {debounce} from 'lodash';
|
||||
import {DEFAULT_ROW_HEIGHT} from './types';
|
||||
import textContent from '../../../utils/textContent';
|
||||
import {notNull} from '../../../utils/typeUtils';
|
||||
import {getFlipperLib} from 'flipper-plugin';
|
||||
import {getFlipperLib, textContent} from 'flipper-plugin';
|
||||
|
||||
const EMPTY_OBJECT = {};
|
||||
Object.freeze(EMPTY_OBJECT);
|
||||
|
||||
@@ -7,6 +7,5 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
export {default as textContent} from './textContent';
|
||||
export {getStringFromErrorLike} from './errors';
|
||||
export {sleep} from './promiseTimeout';
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {ReactNode, ReactElement} from 'react';
|
||||
|
||||
function isReactElement(object: any) {
|
||||
return (
|
||||
typeof object === 'object' &&
|
||||
object !== null &&
|
||||
object.$$typeof === Symbol.for('react.element')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively walks through all children of a React element and returns
|
||||
* the string representation of the leafs concatenated.
|
||||
*/
|
||||
export default (node: ReactNode): string => {
|
||||
let res = '';
|
||||
const traverse = (node: ReactNode) => {
|
||||
if (typeof node === 'string' || typeof node === 'number') {
|
||||
// this is a leaf, add it to the result string
|
||||
res += node;
|
||||
} else if (Array.isArray(node)) {
|
||||
// traverse all array members and recursively stringify them
|
||||
node.forEach(traverse);
|
||||
} else if (isReactElement(node)) {
|
||||
// node is a react element access its children an recursively stringify them
|
||||
const {children} = (node as ReactElement).props;
|
||||
if (Array.isArray(children)) {
|
||||
children.forEach(traverse);
|
||||
} else {
|
||||
traverse(children);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
traverse(node);
|
||||
|
||||
return res;
|
||||
};
|
||||
Reference in New Issue
Block a user