Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
qn895 committed Jun 3, 2024
1 parent 6eb7c03 commit 1feba9a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
getAssociatedSmartFieldsAsString,
SmartFieldFallbackTooltip,
} from '@kbn/unified-field-list';
import type { DataVisualizerTableItem } from '@kbn/data-visualizer-plugin/public/application/common/components/stats_table/data_visualizer_stats_table';
import type { DataVisualizerTableItem } from '@kbn/data-visualizer-plugin/public/application/common/components/stats_table/types';
import { useDiscoverServices } from '../../../../hooks/use_discover_services';
import { FIELD_STATISTICS_LOADED } from './constants';

Expand Down Expand Up @@ -84,37 +84,6 @@ export const FieldStatisticsTable = React.memo((props: FieldStatisticsTableProps
[additionalFieldGroups, allFallbackFields]
);

const visibleFields = useMemo(
() => convertFieldsToFallbackFields({ fields: columns, additionalFieldGroups }),
[additionalFieldGroups, columns]
);
const allFallbackFields = useMemo(
() => getAllFallbackFields(additionalFieldGroups),
[additionalFieldGroups]
);
const renderFieldName = useCallback(
(fieldName: string, item: DataVisualizerTableItem) => {
const displayName = item.displayName ?? item.fieldName;
const isDerivedAsPartOfSmartField = allFallbackFields.includes(fieldName);
const associatedSmartFields = isDerivedAsPartOfSmartField
? getAssociatedSmartFieldsAsString(fieldName, additionalFieldGroups)
: '';

return (
<>
{displayName}
{isDerivedAsPartOfSmartField ? (
<>
{' '}
<SmartFieldFallbackTooltip associatedSmartFields={associatedSmartFields} />
</>
) : null}
</>
);
},
[additionalFieldGroups, allFallbackFields]
);

const services = useDiscoverServices();

// Other apps consuming Discover UI might inject their own proxied data services
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ import { IndexBasedNumberContentPreview } from './components/field_data_row/numb

import { useTableSettings } from './use_table_settings';
import { TopValuesPreview } from './components/field_data_row/top_values_preview';
import type {
FieldVisConfig,
FileBasedFieldVisConfig,
} from '../../../../../common/types/field_vis_config';
import { isIndexBasedFieldVisConfig } from '../../../../../common/types/field_vis_config';
import { FileBasedNumberContentPreview } from '../field_data_row';
import { BooleanContentPreview } from './components/field_data_row';
Expand All @@ -47,12 +43,12 @@ import { DistinctValues } from './components/field_data_row/distinct_values';
import { FieldTypeIcon } from '../field_type_icon';
import './_index.scss';
import type { FieldStatisticTableEmbeddableProps } from '../../../index_data_visualizer/embeddables/grid_embeddable/types';
import type { DataVisualizerTableItem } from './types';

const FIELD_NAME = 'fieldName';

export type ItemIdToExpandedRowMap = Record<string, JSX.Element>;

export type DataVisualizerTableItem = FieldVisConfig | FileBasedFieldVisConfig;
interface DataVisualizerTableProps<T extends object> {
items: T[];
pageState: DataVisualizerTableState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
* 2.0.
*/
export type { FieldDataRowProps } from './field_data_row';
export type {
import type {
FieldVisConfig,
FileBasedFieldVisConfig,
MetricFieldVisStats,
} from '../../../../../../common/types/field_vis_config';

export type DataVisualizerTableItem = FieldVisConfig | FileBasedFieldVisConfig;

export type { FieldVisConfig, FileBasedFieldVisConfig, MetricFieldVisStats };
export {
isFileBasedFieldVisConfig,
isIndexBasedFieldVisConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type { DATA_VISUALIZER_INDEX_VIEWER } from '../../constants/index_data_vi
import type { DataVisualizerIndexBasedAppState } from '../../types/index_data_visualizer_state';
import type { DataVisualizerStartDependencies } from '../../../common/types/data_visualizer_plugin';
import type { ESQLQuery } from '../../search_strategy/requests/esql_utils';
import type { DataVisualizerTableItem } from '../../../common/components/stats_table/data_visualizer_stats_table';
import type { DataVisualizerTableItem } from '../../../common/components/stats_table/types';

export interface FieldStatisticTableEmbeddableProps {
/**
Expand Down

0 comments on commit 1feba9a

Please sign in to comment.