diff --git a/desktop/app/src/index.tsx b/desktop/app/src/index.tsx index bc5d0031e..16938af1c 100644 --- a/desktop/app/src/index.tsx +++ b/desktop/app/src/index.tsx @@ -97,6 +97,7 @@ export { } from './ui/components/data-inspector/DataInspector'; export {default as DataInspector} from './ui/components/data-inspector/DataInspector'; export {default as ManagedDataInspector} from './ui/components/data-inspector/ManagedDataInspector'; +export {default as SearchableDataInspector} from './ui/components/data-inspector/SearchableDataInspector'; export {default as DataDescription} from './ui/components/data-inspector/DataDescription'; export {default as Tabs} from './ui/components/Tabs'; export {default as Tab} from './ui/components/Tab'; diff --git a/desktop/app/src/ui/components/data-inspector/ManagedDataInspector.tsx b/desktop/app/src/ui/components/data-inspector/ManagedDataInspector.tsx index bfe73ea0b..4fc1c5ca3 100644 --- a/desktop/app/src/ui/components/data-inspector/ManagedDataInspector.tsx +++ b/desktop/app/src/ui/components/data-inspector/ManagedDataInspector.tsx @@ -14,7 +14,7 @@ import React from 'react'; import {DataValueExtractor} from './DataPreview'; import {HighlightProvider} from '../Highlight'; -type ManagedDataInspectorProps = { +export type ManagedDataInspectorProps = { /** * Object to inspect. */ diff --git a/desktop/app/src/ui/components/data-inspector/SearchableDataInspector.tsx b/desktop/app/src/ui/components/data-inspector/SearchableDataInspector.tsx new file mode 100644 index 000000000..f8e76573c --- /dev/null +++ b/desktop/app/src/ui/components/data-inspector/SearchableDataInspector.tsx @@ -0,0 +1,45 @@ +/** + * 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 React from 'react'; +import debounceRender from 'react-debounce-render'; + +import ManagedDataInspector, { + ManagedDataInspectorProps, +} from './ManagedDataInspector'; +import Searchable, {SearchableProps} from '../searchable/Searchable'; + +type Props = ManagedDataInspectorProps & SearchableProps; + +function filter(data: any, searchTerm: string): any { + if (searchTerm === '') { + return data; + } + const res: any = {}; + const lowerSearch = searchTerm.toLowerCase(); + + for (const key in data) { + if (key.toLowerCase().indexOf(lowerSearch) != -1) { + res[key] = data[key]; + } + } + return res; +} + +// Naive shallow filters matching wrapper for ManagedDataInspector +function SearchableDataInspector(props: Props) { + return ( + + ); +} + +export default Searchable(debounceRender(SearchableDataInspector, 250, {})); diff --git a/desktop/app/src/ui/index.tsx b/desktop/app/src/ui/index.tsx index 3c458d499..7dd679ffc 100644 --- a/desktop/app/src/ui/index.tsx +++ b/desktop/app/src/ui/index.tsx @@ -49,6 +49,7 @@ export { } from './components/data-inspector/DataInspector'; export {default as DataInspector} from './components/data-inspector/DataInspector'; export {default as ManagedDataInspector} from './components/data-inspector/ManagedDataInspector'; +export {default as SearchableDataInspector} from './components/data-inspector/SearchableDataInspector'; export {default as DataDescription} from './components/data-inspector/DataDescription'; // tabs