Skip to content

Commit

Permalink
add query for partition fields
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezmelissa87 committed Mar 29, 2022
1 parent 3bfae94 commit 56bdb87
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { ExplorerChartSingleMetric } from './explorer_chart_single_metric';
import { ExplorerChartLabel } from './components/explorer_chart_label';

import { CHART_TYPE } from '../explorer_constants';
import { SEARCH_QUERY_LANGUAGE } from '../../../../common/constants/search';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { MlTooltipComponent } from '../../components/chart_tooltip';
Expand Down Expand Up @@ -100,6 +101,14 @@ function ExplorerChartContainer({
} = useMlKibana();

const getMapsLink = useCallback(async () => {
const queryString = series.entityFields
?.map(({ fieldName, fieldValue }) => `${fieldName}:${fieldValue}`)
.join(' or ');
const query = {
language: SEARCH_QUERY_LANGUAGE.KUERY,
query: queryString,
};

const initialLayers = [];
const typicalStyle = {
type: 'VECTOR',
Expand Down Expand Up @@ -158,6 +167,7 @@ function ExplorerChartContainer({
const location = await locator.getLocation({
initialLayers: initialLayers,
timeRange: data.query.timefilter.timefilter.getTime(),
...(queryString !== undefined ? { query } : {}),
});

return location;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ jest.mock('../../contexts/kibana', () => ({
url: {
locators: {
get: jest.fn(() => {
return { getLocation: jest.fn(() => { path: '/#maps' }) };
})
}
}
return {
getLocation: jest.fn(() => ({ path: '/#maps' })),
};
}),
},
},
},
data: {
query: {
Expand All @@ -62,7 +64,7 @@ jest.mock('../../contexts/kibana', () => ({
},
},
application: {
navigateToApp: jest.fn()
navigateToApp: jest.fn(),
},
},
};
Expand Down

0 comments on commit 56bdb87

Please sign in to comment.