Skip to content

Commit

Permalink
Revert "[Discover] Switch to lazy"
Browse files Browse the repository at this point in the history
This reverts commit 06e6415.
  • Loading branch information
jughosta committed Aug 9, 2024
1 parent 06e6415 commit 8bf4dd9
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 36 deletions.
7 changes: 1 addition & 6 deletions packages/kbn-unified-field-list/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@

export { FieldList, type FieldListProps } from './src/components/field_list';
export { FieldListGrouped, type FieldListGroupedProps } from './src/components/field_list_grouped';
export {
FieldListFilters,
type FieldListFiltersProps,
FieldTypeFilter,
type FieldTypeFilterProps,
} from './src/components/field_list_filters';
export { FieldListFilters, type FieldListFiltersProps } from './src/components/field_list_filters';
export { FieldItemButton, type FieldItemButtonProps } from './src/components/field_item_button';
export type {
FieldTopValuesBucketProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import React from 'react';
import { type DataViewField } from '@kbn/data-views-plugin/common';
import { FieldNameSearch, type FieldNameSearchProps } from './field_name_search';
import FieldTypeFilter, { type FieldTypeFilterProps } from './field_type_filter';
import { FieldTypeFilter, type FieldTypeFilterProps } from './field_type_filter';
import { type FieldListItem } from '../../types';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { EuiContextMenuItem } from '@elastic/eui';
import { stubLogstashDataView as dataView } from '@kbn/data-views-plugin/common/data_view.stub';
import { coreMock } from '@kbn/core/public/mocks';
import { type DataViewField } from '@kbn/data-views-plugin/common';
import FieldTypeFilter, { type FieldTypeFilterProps } from './field_type_filter';
import { FieldTypeFilter, type FieldTypeFilterProps } from './field_type_filter';

const docLinks = coreMock.createStart().docLinks;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export interface FieldTypeFilterProps<T extends FieldListItem> {
* @param onChange
* @constructor
*/
function FieldTypeFilterComponent<T extends FieldListItem = DataViewField>({
export function FieldTypeFilter<T extends FieldListItem = DataViewField>({
'data-test-subj': dataTestSubject,
docLinks,
allFields,
Expand Down Expand Up @@ -273,9 +273,3 @@ function FieldTypeFilterComponent<T extends FieldListItem = DataViewField>({
</EuiPopover>
);
}

export type GenericFieldTypeFilter = typeof FieldTypeFilterComponent;

// Necessary for React.lazy
// eslint-disable-next-line import/no-default-export
export default FieldTypeFilterComponent;
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
*/

import React, { Fragment } from 'react';
import type { DataViewField } from '@kbn/data-views-plugin/common';
import { type DataViewField } from '@kbn/data-views-plugin/common';
import type { FieldListFiltersProps, GenericFieldListFilters } from './field_list_filters';
import type { FieldTypeFilterProps, GenericFieldTypeFilter } from './field_type_filter';
import type { FieldListItem } from '../../types';
import { type FieldListItem } from '../../types';

const Fallback = () => <Fragment />;

Expand All @@ -30,20 +29,3 @@ function WrappedFieldListFilters<T extends FieldListItem = DataViewField>(

export const FieldListFilters = WrappedFieldListFilters;
export type { FieldListFiltersProps };

const LazyFieldTypeFilter = React.lazy(
() => import('./field_type_filter')
) as GenericFieldTypeFilter;

function WrappedFieldTypeFilter<T extends FieldListItem = DataViewField>(
props: FieldTypeFilterProps<T>
) {
return (
<React.Suspense fallback={<Fallback />}>
<LazyFieldTypeFilter<T> {...props} />
</React.Suspense>
);
}

export const FieldTypeFilter = WrappedFieldTypeFilter;
export type { FieldTypeFilterProps };
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { FieldListItem } from '@kbn/unified-field-list';
import {
FieldTypeFilter,
type FieldTypeFilterProps,
} from '@kbn/unified-field-list/src/components/field_list_filters';
} from '@kbn/unified-field-list/src/components/field_list_filters/field_type_filter';
import { getUnifiedDocViewerServices } from '../../plugin';

export const LOCAL_STORAGE_KEY_SEARCH_TERM = 'discover:searchText';
Expand Down

0 comments on commit 8bf4dd9

Please sign in to comment.