Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Decouple data_visualizer from MapEmbeddable #181928

Merged
merged 13 commits into from
May 1, 2024

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ import React, { useMemo } from 'react';
import type { Feature, Point } from 'geojson';
import type { FieldDataRowProps } from '../../stats_table/types/field_data_row';
import { DocumentStatsTable } from '../../stats_table/components/field_data_expanded_row/document_stats';
import { EmbeddedMapComponent } from '../../embedded_map';
import { convertWKTGeoToLonLat, getGeoPointsLayer } from './format_utils';
import { ExpandedRowContent } from '../../stats_table/components/field_data_expanded_row/expanded_row_content';
import { ExamplesList } from '../../examples_list';
import { ExpandedRowPanel } from '../../stats_table/components/field_data_expanded_row/expanded_row_panel';
import { useDataVisualizerKibana } from '../../../../kibana_context';

export const DEFAULT_GEO_REGEX = RegExp('(?<lat>.+) (?<lon>.+)');

export const GeoPointContent: FC<FieldDataRowProps> = ({ config }) => {
const {
services: { maps: mapsService },
} = useDataVisualizerKibana();

const formattedResults = useMemo(() => {
const { stats } = config;

Expand Down Expand Up @@ -54,20 +58,18 @@ export const GeoPointContent: FC<FieldDataRowProps> = ({ config }) => {
if (geoPointsFeatures.length > 0) {
return {
examples: formattedExamples,
layerList: [getGeoPointsLayer(geoPointsFeatures)],
pointsLayer: getGeoPointsLayer(geoPointsFeatures),
};
}
}
}, [config]);
return (
<ExpandedRowContent dataTestSubj={'dataVisualizerGeoPointContent'}>
<DocumentStatsTable config={config} />
{formattedResults && Array.isArray(formattedResults.examples) && (
<ExamplesList examples={formattedResults.examples} />
)}
{formattedResults && Array.isArray(formattedResults.layerList) && (
{formattedResults?.examples && <ExamplesList examples={formattedResults.examples} />}
{mapsService && formattedResults?.pointsLayer && (
<ExpandedRowPanel className={'dvPanel__wrapper dvMap__wrapper'} grow={true}>
<EmbeddedMapComponent layerList={formattedResults.layerList} />
<mapsService.PassiveMap passiveLayer={formattedResults.pointsLayer} />
</ExpandedRowPanel>
)}
</ExpandedRowContent>
Expand Down
Loading